Modernize RenderStyleConstants.h - Part 3
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 May 2018 00:49:21 +0000 (00:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 May 2018 00:49:21 +0000 (00:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186015

Patch by Sam Weinig <sam@webkit.org> on 2018-05-27
Reviewed by Yusuke Suzuki.

Source/WebCore:

Modernized the third and final set of enums in RenderStyleConstants.h by:
    - Converting them to enum classes
    - Renaming them to remove unnecessary prefix 'E's
    - Renaming values to take advantage of enum class scoping (e.g. StyleDifferenceEqual -> StyleDifference::Equal)

Modernizes the following enums:
    TextDecoration
    TextDecorationSkip (renamed from TextDecorationSkipItems)
    TextUnderlinePosition
    HangingPunctuation
    SpeakAs (renamed from ESpeakAs)
    TextEmphasisPosition (renamed from TextEmphasisPositions)

This final set of enums are mostly (TextUnderlinePosition isn't really) used as bitmasks,
so this change also converts their uses to use OptionSet.

* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::speakAsProperty const):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::speakAsProperty const):
(WebCore::AccessibilityRenderObject::hasPlainText const):
(WebCore::AccessibilityRenderObject::hasUnderline const):
* accessibility/AccessibilityRenderObject.h:
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(AXAttributeStringSetStyle):
* accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
(-[WebAccessibilityObjectWrapperBase baseAccessibilitySpeechHint]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(AXAttributeStringSetStyle):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::renderTextDecorationFlagsToCSSValue):
(WebCore::renderTextDecorationSkipFlagsToCSSValue):
(WebCore::renderEmphasisPositionFlagsToCSSValue):
(WebCore::speakAsToCSSValue):
(WebCore::hangingPunctuationToCSSValue):
* css/CSSLineBoxContainValue.h:
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::operator HangingPunctuation const):
(WebCore::CSSPrimitiveValue::operator TextDecoration const):
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator TextUnderlinePosition const):
(WebCore::CSSPrimitiveValue::operator SpeakAs const):
(WebCore::CSSPrimitiveValue::operator ESpeakAs const): Deleted.
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertTextDecoration):
(WebCore::StyleBuilderConverter::valueToEmphasisPosition):
(WebCore::StyleBuilderConverter::convertTextEmphasisPosition):
(WebCore::StyleBuilderConverter::convertTextUnderlinePosition):
(WebCore::StyleBuilderConverter::valueToDecorationSkip):
(WebCore::StyleBuilderConverter::convertTextDecorationSkip):
(WebCore::StyleBuilderConverter::convertSpeakAs):
(WebCore::StyleBuilderConverter::convertHangingPunctuation):
* editing/cocoa/EditorCocoa.mm:
(WebCore::Editor::getTextDecorationAttributesRespectingTypingStyle const):
* editing/cocoa/HTMLConverter.mm:
(WebCore::editingAttributedStringFromRange):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::maxLogicalBottomForTextDecorationLine const):
(WebCore::InlineFlowBox::minLogicalTopForTextDecorationLine const):
* rendering/InlineFlowBox.h:
* rendering/InlineTextBox.cpp:
(WebCore::emphasisPositionHasNeitherLeftNorRight):
(WebCore::InlineTextBox::emphasisMarkExistsAndIsAbove const):
(WebCore::InlineTextBox::paint):
(WebCore::InlineTextBox::paintMarkedTextDecoration):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths const):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::setLogicalWidthForTextRun):
(WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::enclosingRendererWithTextDecoration const):
* rendering/RenderElement.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::addCell):
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseForStyle):
(WebCore::SimpleLineLayout::canUseForWithReason):
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::paintFlow):
* rendering/TextDecorationPainter.cpp:
(WebCore::TextDecorationPainter::TextDecorationPainter):
(WebCore::TextDecorationPainter::paintTextDecoration):
(WebCore::collectStylesForRenderer):
(WebCore::TextDecorationPainter::stylesForRenderer):
* rendering/TextDecorationPainter.h:
* rendering/TextPaintStyle.cpp:
(WebCore::computeTextPaintStyle):
* rendering/line/BreakingContext.h:
(WebCore::BreakingContext::handleText):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::RenderStyle):
(WebCore::RenderStyle::changeAffectsVisualOverflow const):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::textDecorationsInEffect const):
(WebCore::RenderStyle::textDecoration const):
(WebCore::RenderStyle::textDecorationSkip const):
(WebCore::RenderStyle::hangingPunctuation const):
(WebCore::RenderStyle::textEmphasisPosition const):
(WebCore::RenderStyle::speakAs const):
(WebCore::RenderStyle::addToTextDecorationsInEffect):
(WebCore::RenderStyle::setTextDecorationsInEffect):
(WebCore::RenderStyle::setTextDecoration):
(WebCore::RenderStyle::setTextDecorationSkip):
(WebCore::RenderStyle::setSpeakAs):
(WebCore::RenderStyle::setTextEmphasisPosition):
(WebCore::RenderStyle::setHangingPunctuation):
(WebCore::RenderStyle::initialHangingPunctuation):
(WebCore::RenderStyle::initialTextDecoration):
(WebCore::RenderStyle::initialTextDecorationSkip):
(WebCore::RenderStyle::initialTextUnderlinePosition):
(WebCore::RenderStyle::initialSpeakAs):
(WebCore::RenderStyle::initialTextEmphasisPosition):
* rendering/style/RenderStyleConstants.h:
(WebCore::operator|): Deleted.
(WebCore::operator|=): Deleted.
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
* rendering/style/StyleVisualData.cpp:
(WebCore::StyleVisualData::StyleVisualData):
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::paint):
(WebCore::positionOffsetForDecoration):
(WebCore::thicknessForDecoration):
(WebCore::findRendererDefininingTextDecoration):
(WebCore::SVGInlineTextBox::paintDecoration):
(WebCore::SVGInlineTextBox::paintDecorationWithStyle):
* rendering/svg/SVGInlineTextBox.h:
* style/InlineTextBoxStyle.cpp:
(WebCore::computeUnderlineOffset):
(WebCore::visualOverflowForDecorations):

Source/WebKitLegacy/mac:

* WebView/WebView.mm:
(-[WebView updateTextTouchBar]):
Update for new enum name.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232229 268f45cc-cd09-0410-ab3c-d52691b4dbfc

39 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.h
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSLineBoxContainValue.h
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/StyleBuilderConverter.h
Source/WebCore/editing/cocoa/EditorCocoa.mm
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/InlineFlowBox.h
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderTableSection.cpp
Source/WebCore/rendering/SimpleLineLayout.cpp
Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp
Source/WebCore/rendering/TextDecorationPainter.cpp
Source/WebCore/rendering/TextDecorationPainter.h
Source/WebCore/rendering/TextPaintStyle.cpp
Source/WebCore/rendering/line/BreakingContext.h
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/RenderStyleConstants.h
Source/WebCore/rendering/style/StyleRareInheritedData.cpp
Source/WebCore/rendering/style/StyleVisualData.cpp
Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
Source/WebCore/rendering/svg/SVGInlineTextBox.h
Source/WebCore/style/InlineTextBoxStyle.cpp
Source/WebCore/style/InlineTextBoxStyle.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebView.mm

index 6b088b9..dccb75f 100644 (file)
@@ -1,3 +1,142 @@
+2018-05-27  Sam Weinig  <sam@webkit.org>
+
+        Modernize RenderStyleConstants.h - Part 3
+        https://bugs.webkit.org/show_bug.cgi?id=186015
+
+        Reviewed by Yusuke Suzuki.
+
+        Modernized the third and final set of enums in RenderStyleConstants.h by:
+            - Converting them to enum classes
+            - Renaming them to remove unnecessary prefix 'E's
+            - Renaming values to take advantage of enum class scoping (e.g. StyleDifferenceEqual -> StyleDifference::Equal)
+
+        Modernizes the following enums:
+            TextDecoration
+            TextDecorationSkip (renamed from TextDecorationSkipItems)
+            TextUnderlinePosition
+            HangingPunctuation
+            SpeakAs (renamed from ESpeakAs)
+            TextEmphasisPosition (renamed from TextEmphasisPositions)
+
+        This final set of enums are mostly (TextUnderlinePosition isn't really) used as bitmasks,
+        so this change also converts their uses to use OptionSet. 
+
+        * accessibility/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::speakAsProperty const):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::speakAsProperty const):
+        (WebCore::AccessibilityRenderObject::hasPlainText const):
+        (WebCore::AccessibilityRenderObject::hasUnderline const):
+        * accessibility/AccessibilityRenderObject.h:
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (AXAttributeStringSetStyle):
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+        (-[WebAccessibilityObjectWrapperBase baseAccessibilitySpeechHint]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (AXAttributeStringSetStyle):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::renderTextDecorationFlagsToCSSValue):
+        (WebCore::renderTextDecorationSkipFlagsToCSSValue):
+        (WebCore::renderEmphasisPositionFlagsToCSSValue):
+        (WebCore::speakAsToCSSValue):
+        (WebCore::hangingPunctuationToCSSValue):
+        * css/CSSLineBoxContainValue.h:
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::operator HangingPunctuation const):
+        (WebCore::CSSPrimitiveValue::operator TextDecoration const):
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator TextUnderlinePosition const):
+        (WebCore::CSSPrimitiveValue::operator SpeakAs const):
+        (WebCore::CSSPrimitiveValue::operator ESpeakAs const): Deleted.
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::convertTextDecoration):
+        (WebCore::StyleBuilderConverter::valueToEmphasisPosition):
+        (WebCore::StyleBuilderConverter::convertTextEmphasisPosition):
+        (WebCore::StyleBuilderConverter::convertTextUnderlinePosition):
+        (WebCore::StyleBuilderConverter::valueToDecorationSkip):
+        (WebCore::StyleBuilderConverter::convertTextDecorationSkip):
+        (WebCore::StyleBuilderConverter::convertSpeakAs):
+        (WebCore::StyleBuilderConverter::convertHangingPunctuation):
+        * editing/cocoa/EditorCocoa.mm:
+        (WebCore::Editor::getTextDecorationAttributesRespectingTypingStyle const):
+        * editing/cocoa/HTMLConverter.mm:
+        (WebCore::editingAttributedStringFromRange):
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::maxLogicalBottomForTextDecorationLine const):
+        (WebCore::InlineFlowBox::minLogicalTopForTextDecorationLine const):
+        * rendering/InlineFlowBox.h:
+        * rendering/InlineTextBox.cpp:
+        (WebCore::emphasisPositionHasNeitherLeftNorRight):
+        (WebCore::InlineTextBox::emphasisMarkExistsAndIsAbove const):
+        (WebCore::InlineTextBox::paint):
+        (WebCore::InlineTextBox::paintMarkedTextDecoration):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths const):
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::setLogicalWidthForTextRun):
+        (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::enclosingRendererWithTextDecoration const):
+        * rendering/RenderElement.h:
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::addCell):
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseForStyle):
+        (WebCore::SimpleLineLayout::canUseForWithReason):
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::paintFlow):
+        * rendering/TextDecorationPainter.cpp:
+        (WebCore::TextDecorationPainter::TextDecorationPainter):
+        (WebCore::TextDecorationPainter::paintTextDecoration):
+        (WebCore::collectStylesForRenderer):
+        (WebCore::TextDecorationPainter::stylesForRenderer):
+        * rendering/TextDecorationPainter.h:
+        * rendering/TextPaintStyle.cpp:
+        (WebCore::computeTextPaintStyle):
+        * rendering/line/BreakingContext.h:
+        (WebCore::BreakingContext::handleText):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::RenderStyle):
+        (WebCore::RenderStyle::changeAffectsVisualOverflow const):
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::textDecorationsInEffect const):
+        (WebCore::RenderStyle::textDecoration const):
+        (WebCore::RenderStyle::textDecorationSkip const):
+        (WebCore::RenderStyle::hangingPunctuation const):
+        (WebCore::RenderStyle::textEmphasisPosition const):
+        (WebCore::RenderStyle::speakAs const):
+        (WebCore::RenderStyle::addToTextDecorationsInEffect):
+        (WebCore::RenderStyle::setTextDecorationsInEffect):
+        (WebCore::RenderStyle::setTextDecoration):
+        (WebCore::RenderStyle::setTextDecorationSkip):
+        (WebCore::RenderStyle::setSpeakAs):
+        (WebCore::RenderStyle::setTextEmphasisPosition):
+        (WebCore::RenderStyle::setHangingPunctuation):
+        (WebCore::RenderStyle::initialHangingPunctuation):
+        (WebCore::RenderStyle::initialTextDecoration):
+        (WebCore::RenderStyle::initialTextDecorationSkip):
+        (WebCore::RenderStyle::initialTextUnderlinePosition):
+        (WebCore::RenderStyle::initialSpeakAs):
+        (WebCore::RenderStyle::initialTextEmphasisPosition):
+        * rendering/style/RenderStyleConstants.h:
+        (WebCore::operator|): Deleted.
+        (WebCore::operator|=): Deleted.
+        * rendering/style/StyleRareInheritedData.cpp:
+        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
+        * rendering/style/StyleVisualData.cpp:
+        (WebCore::StyleVisualData::StyleVisualData):
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paint):
+        (WebCore::positionOffsetForDecoration):
+        (WebCore::thicknessForDecoration):
+        (WebCore::findRendererDefininingTextDecoration):
+        (WebCore::SVGInlineTextBox::paintDecoration):
+        (WebCore::SVGInlineTextBox::paintDecorationWithStyle):
+        * rendering/svg/SVGInlineTextBox.h:
+        * style/InlineTextBoxStyle.cpp:
+        (WebCore::computeUnderlineOffset):
+        (WebCore::visualOverflowForDecorations):
+
 2018-05-26  Zalan Bujtas  <zalan@apple.com>
 
         [LFC] Implement margin computation
index 135b320..f72845f 100644 (file)
@@ -1013,7 +1013,7 @@ public:
     bool supportsARIAAttributes() const;
     
     // CSS3 Speech properties.
-    virtual ESpeakAs speakAsProperty() const { return SpeakNormal; }
+    virtual OptionSet<SpeakAs> speakAsProperty() const { return OptionSet<SpeakAs> { }; }
 
     // Make this object visible by scrolling as many nested scrollable views as needed.
     virtual void scrollToMakeVisible() const;
index 4502c6d..897952f 100644 (file)
@@ -945,7 +945,7 @@ AccessibilityObject* AccessibilityRenderObject::internalLinkElement() const
     return firstAccessibleObjectFromNode(linkedNode);
 }
 
-ESpeakAs AccessibilityRenderObject::speakAsProperty() const
+OptionSet<SpeakAs> AccessibilityRenderObject::speakAsProperty() const
 {
     if (!m_renderer)
         return AccessibilityObject::speakAsProperty();
@@ -3600,7 +3600,7 @@ bool AccessibilityRenderObject::hasPlainText() const
     const RenderStyle& style = m_renderer->style();
     return style.fontDescription().weight() == normalWeightValue()
         && style.fontDescription().italic() == normalItalicValue()
-        && style.textDecorationsInEffect() == TextDecorationNone;
+        && style.textDecorationsInEffect().isEmpty();
 }
 
 bool AccessibilityRenderObject::hasSameFont(RenderObject* renderer) const
@@ -3632,7 +3632,7 @@ bool AccessibilityRenderObject::hasUnderline() const
     if (!m_renderer)
         return false;
     
-    return m_renderer->style().textDecorationsInEffect() & TextDecorationUnderline;
+    return m_renderer->style().textDecorationsInEffect().contains(TextDecoration::Underline);
 }
 
 String AccessibilityRenderObject::nameForMSAA() const
index 135eb14..81bb5be 100644 (file)
@@ -274,7 +274,7 @@ private:
     bool elementAttributeValue(const QualifiedName&) const;
     void setElementAttributeValue(const QualifiedName&, bool);
     
-    ESpeakAs speakAsProperty() const override;
+    OptionSet<SpeakAs> speakAsProperty() const override;
     
     const String liveRegionStatus() const override;
     const String liveRegionRelevant() const override;
index a5f4b9a..474756c 100644 (file)
@@ -162,11 +162,11 @@ static AtkAttributeSet* getAttributeSetForAccessibilityObject(const Accessibilit
         result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_JUSTIFICATION), "fill");
     }
 
-    result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_UNDERLINE), (style->textDecoration() & TextDecorationUnderline) ? "single" : "none");
+    result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_UNDERLINE), (style->textDecoration() & TextDecoration::Underline) ? "single" : "none");
 
     result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_STYLE), style->fontCascade().italic() ? "italic" : "normal");
 
-    result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_STRIKETHROUGH), (style->textDecoration() & TextDecorationLineThrough) ? "true" : "false");
+    result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_STRIKETHROUGH), (style->textDecoration() & TextDecoration::LineThrough) ? "true" : "false");
 
     result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_INVISIBLE), (style->visibility() == Visibility::Hidden) ? "true" : "false");
 
index afdc75a..9519ebe 100644 (file)
@@ -2265,8 +2265,8 @@ static void AXAttributeStringSetStyle(NSMutableAttributedString* attrString, Ren
     // set basic font info
     AXAttributeStringSetFont(attrString, style.fontCascade().primaryFont().getCTFont(), range);
                 
-    int decor = style.textDecorationsInEffect();
-    if (decor & TextDecorationUnderline)
+    auto decor = style.textDecorationsInEffect();
+    if (decor & TextDecoration::Underline)
         AXAttributeStringSetNumber(attrString, UIAccessibilityTokenUnderline, @YES, range);
 }
 
index d928736..8b45f0d 100644 (file)
@@ -405,18 +405,18 @@ NSArray *convertToNSArray(const AccessibilityObject::AccessibilityChildrenVector
 
 - (NSArray<NSString *> *)baseAccessibilitySpeechHint
 {
-    ESpeakAs speak = m_object->speakAsProperty();
+    auto speak = m_object->speakAsProperty();
     NSMutableArray<NSString *> *hints = [NSMutableArray array];
-    if (speak & SpeakSpellOut)
+    if (speak & SpeakAs::SpellOut)
         [hints addObject:@"spell-out"];
     else
         [hints addObject:@"normal"];
 
-    if (speak & SpeakDigits)
+    if (speak & SpeakAs::Digits)
         [hints addObject:@"digits"];
-    if (speak & SpeakLiteralPunctuation)
+    if (speak & SpeakAs::LiteralPunctuation)
         [hints addObject:@"literal-punctuation"];
-    if (speak & SpeakNoPunctuation)
+    if (speak & SpeakAs::NoPunctuation)
         [hints addObject:@"no-punctuation"];
     
     return hints;
index 5f76544..3f07417 100644 (file)
@@ -845,27 +845,27 @@ static void AXAttributeStringSetStyle(NSMutableAttributedString* attrString, Ren
         [attrString removeAttribute:NSAccessibilityShadowTextAttribute range:range];
     
     // set underline and strikethrough
-    int decor = style.textDecorationsInEffect();
-    if ((decor & TextDecorationUnderline) == 0) {
+    auto decor = style.textDecorationsInEffect();
+    if (!(decor & TextDecoration::Underline)) {
         [attrString removeAttribute:NSAccessibilityUnderlineTextAttribute range:range];
         [attrString removeAttribute:NSAccessibilityUnderlineColorTextAttribute range:range];
     }
     
-    if ((decor & TextDecorationLineThrough) == 0) {
+    if (!(decor & TextDecoration::LineThrough)) {
         [attrString removeAttribute:NSAccessibilityStrikethroughTextAttribute range:range];
         [attrString removeAttribute:NSAccessibilityStrikethroughColorTextAttribute range:range];
     }
-    
-    if ((decor & (TextDecorationUnderline | TextDecorationLineThrough)) != 0) {
+
+    if (decor & TextDecoration::Underline || decor & TextDecoration::LineThrough) {
         // FIXME: Should the underline style be reported here?
         auto decorationStyles = TextDecorationPainter::stylesForRenderer(*renderer, decor);
 
-        if ((decor & TextDecorationUnderline) != 0) {
+        if (decor & TextDecoration::Underline) {
             AXAttributeStringSetNumber(attrString, NSAccessibilityUnderlineTextAttribute, @YES, range);
             AXAttributeStringSetColor(attrString, NSAccessibilityUnderlineColorTextAttribute, nsColor(decorationStyles.underlineColor), range);
         }
         
-        if ((decor & TextDecorationLineThrough) != 0) {
+        if (decor & TextDecoration::LineThrough) {
             AXAttributeStringSetNumber(attrString, NSAccessibilityStrikethroughTextAttribute, @YES, range);
             AXAttributeStringSetColor(attrString, NSAccessibilityStrikethroughColorTextAttribute, nsColor(decorationStyles.linethroughColor), range);
         }
index 5be3cc6..9735dc1 100644 (file)
@@ -1756,19 +1756,19 @@ static Ref<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
     return CSSValuePool::singleton().createFontFamilyValue(family);
 }
 
-static Ref<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
+static Ref<CSSValue> renderTextDecorationFlagsToCSSValue(OptionSet<TextDecoration> textDecoration)
 {
     auto& cssValuePool = CSSValuePool::singleton();
     // Blink value is ignored.
     auto list = CSSValueList::createSpaceSeparated();
-    if (textDecoration & TextDecorationUnderline)
+    if (textDecoration & TextDecoration::Underline)
         list->append(cssValuePool.createIdentifierValue(CSSValueUnderline));
-    if (textDecoration & TextDecorationOverline)
+    if (textDecoration & TextDecoration::Overline)
         list->append(cssValuePool.createIdentifierValue(CSSValueOverline));
-    if (textDecoration & TextDecorationLineThrough)
+    if (textDecoration & TextDecoration::LineThrough)
         list->append(cssValuePool.createIdentifierValue(CSSValueLineThrough));
 #if ENABLE(LETTERPRESS)
-    if (textDecoration & TextDecorationLetterpress)
+    if (textDecoration & TextDecoration::Letterpress)
         list->append(cssValuePool.createIdentifierValue(CSSValueWebkitLetterpress));
 #endif
 
@@ -1796,16 +1796,17 @@ static Ref<CSSValue> renderTextDecorationStyleFlagsToCSSValue(TextDecorationStyl
     return CSSValuePool::singleton().createExplicitInitialValue();
 }
 
-static Ref<CSSValue> renderTextDecorationSkipFlagsToCSSValue(TextDecorationSkip textDecorationSkip)
+static Ref<CSSValue> renderTextDecorationSkipFlagsToCSSValue(OptionSet<TextDecorationSkip> textDecorationSkip)
 {
-    switch (textDecorationSkip) {
-    case TextDecorationSkipAuto:
+    // FIXME: This should probably return a CSSValueList with the set of all TextDecorationSkips.
+    switch (static_cast<TextDecorationSkip>(textDecorationSkip.toRaw())) {
+    case TextDecorationSkip::Auto:
         return CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
-    case TextDecorationSkipNone:
+    case TextDecorationSkip::None:
         return CSSValuePool::singleton().createIdentifierValue(CSSValueNone);
-    case TextDecorationSkipInk:
+    case TextDecorationSkip::Ink:
         return CSSValuePool::singleton().createIdentifierValue(CSSValueInk);
-    case TextDecorationSkipObjects:
+    case TextDecorationSkip::Objects:
         return CSSValuePool::singleton().createIdentifierValue(CSSValueObjects);
     }
 
@@ -1813,55 +1814,53 @@ static Ref<CSSValue> renderTextDecorationSkipFlagsToCSSValue(TextDecorationSkip
     return CSSValuePool::singleton().createExplicitInitialValue();
 }
 
-static Ref<CSSValue> renderEmphasisPositionFlagsToCSSValue(TextEmphasisPosition textEmphasisPosition)
+static Ref<CSSValue> renderEmphasisPositionFlagsToCSSValue(OptionSet<TextEmphasisPosition> textEmphasisPosition)
 {
-    ASSERT(!((textEmphasisPosition & TextEmphasisPositionOver) && (textEmphasisPosition & TextEmphasisPositionUnder)));
-    ASSERT(!((textEmphasisPosition & TextEmphasisPositionLeft) && (textEmphasisPosition & TextEmphasisPositionRight)));
+    ASSERT(!((textEmphasisPosition & TextEmphasisPosition::Over) && (textEmphasisPosition & TextEmphasisPosition::Under)));
+    ASSERT(!((textEmphasisPosition & TextEmphasisPosition::Left) && (textEmphasisPosition & TextEmphasisPosition::Right)));
     auto& cssValuePool = CSSValuePool::singleton();
     auto list = CSSValueList::createSpaceSeparated();
-    if (textEmphasisPosition & TextEmphasisPositionOver)
+    if (textEmphasisPosition & TextEmphasisPosition::Over)
         list->append(cssValuePool.createIdentifierValue(CSSValueOver));
-    if (textEmphasisPosition & TextEmphasisPositionUnder)
+    if (textEmphasisPosition & TextEmphasisPosition::Under)
         list->append(cssValuePool.createIdentifierValue(CSSValueUnder));
-    if (textEmphasisPosition & TextEmphasisPositionLeft)
+    if (textEmphasisPosition & TextEmphasisPosition::Left)
         list->append(cssValuePool.createIdentifierValue(CSSValueLeft));
-    if (textEmphasisPosition & TextEmphasisPositionRight)
+    if (textEmphasisPosition & TextEmphasisPosition::Right)
         list->append(cssValuePool.createIdentifierValue(CSSValueRight));
     if (!list->length())
         return cssValuePool.createIdentifierValue(CSSValueNone);
     return WTFMove(list);
 }
 
-static Ref<CSSValue> speakAsToCSSValue(ESpeakAs speakAs)
+static Ref<CSSValue> speakAsToCSSValue(OptionSet<SpeakAs> speakAs)
 {
     auto& cssValuePool = CSSValuePool::singleton();
     auto list = CSSValueList::createSpaceSeparated();
-    if (speakAs & SpeakNormal)
-        list->append(cssValuePool.createIdentifierValue(CSSValueNormal));
-    if (speakAs & SpeakSpellOut)
+    if (speakAs & SpeakAs::SpellOut)
         list->append(cssValuePool.createIdentifierValue(CSSValueSpellOut));
-    if (speakAs & SpeakDigits)
+    if (speakAs & SpeakAs::Digits)
         list->append(cssValuePool.createIdentifierValue(CSSValueDigits));
-    if (speakAs & SpeakLiteralPunctuation)
+    if (speakAs & SpeakAs::LiteralPunctuation)
         list->append(cssValuePool.createIdentifierValue(CSSValueLiteralPunctuation));
-    if (speakAs & SpeakNoPunctuation)
+    if (speakAs & SpeakAs::NoPunctuation)
         list->append(cssValuePool.createIdentifierValue(CSSValueNoPunctuation));
     if (!list->length())
         return cssValuePool.createIdentifierValue(CSSValueNormal);
     return WTFMove(list);
 }
     
-static Ref<CSSValue> hangingPunctuationToCSSValue(HangingPunctuation hangingPunctuation)
+static Ref<CSSValue> hangingPunctuationToCSSValue(OptionSet<HangingPunctuation> hangingPunctuation)
 {
     auto& cssValuePool = CSSValuePool::singleton();
     auto list = CSSValueList::createSpaceSeparated();
-    if (hangingPunctuation & FirstHangingPunctuation)
+    if (hangingPunctuation & HangingPunctuation::First)
         list->append(cssValuePool.createIdentifierValue(CSSValueFirst));
-    if (hangingPunctuation & AllowEndHangingPunctuation)
+    if (hangingPunctuation & HangingPunctuation::AllowEnd)
         list->append(cssValuePool.createIdentifierValue(CSSValueAllowEnd));
-    if (hangingPunctuation & ForceEndHangingPunctuation)
+    if (hangingPunctuation & HangingPunctuation::ForceEnd)
         list->append(cssValuePool.createIdentifierValue(CSSValueForceEnd));
-    if (hangingPunctuation & LastHangingPunctuation)
+    if (hangingPunctuation & HangingPunctuation::Last)
         list->append(cssValuePool.createIdentifierValue(CSSValueLast));
     if (!list->length())
         return cssValuePool.createIdentifierValue(CSSValueNone);
index d423b85..ce5f808 100644 (file)
@@ -32,8 +32,16 @@ namespace WebCore {
 
 class CSSPrimitiveValue;
 
-enum LineBoxContainFlags { LineBoxContainNone = 0x0, LineBoxContainBlock = 0x1, LineBoxContainInline = 0x2, LineBoxContainFont = 0x4, LineBoxContainGlyphs = 0x8,
-                           LineBoxContainReplaced = 0x10, LineBoxContainInlineBox = 0x20, LineBoxContainInitialLetter = 0x40 };
+enum LineBoxContainFlags {
+    LineBoxContainNone = 0x0,
+    LineBoxContainBlock = 0x1,
+    LineBoxContainInline = 0x2,
+    LineBoxContainFont = 0x4,
+    LineBoxContainGlyphs = 0x8,
+    LineBoxContainReplaced = 0x10,
+    LineBoxContainInlineBox = 0x20,
+    LineBoxContainInitialLetter = 0x40
+};
 typedef unsigned LineBoxContain;
 
 // Used for text-CSSLineBoxContain and box-CSSLineBoxContain
index 4f8fc04..255975e 100644 (file)
@@ -45,6 +45,7 @@
 #include "UnicodeBidi.h"
 #include "WritingMode.h"
 #include <wtf/MathExtras.h>
+#include <wtf/OptionSet.h>
 
 #if ENABLE(CSS_IMAGE_ORIENTATION)
 #include "ImageOrientation.h"
@@ -1635,27 +1636,27 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineBreak e)
     }
 }
 
-template<> inline CSSPrimitiveValue::operator HangingPunctuation() const
+template<> inline CSSPrimitiveValue::operator OptionSet<HangingPunctuation>() const
 {
     ASSERT(isValueID());
     
     switch (m_value.valueID) {
     case CSSValueNone:
-        return NoHangingPunctuation;
+        return OptionSet<HangingPunctuation> { };
     case CSSValueFirst:
-        return FirstHangingPunctuation;
+        return HangingPunctuation::First;
     case CSSValueLast:
-        return LastHangingPunctuation;
+        return HangingPunctuation::Last;
     case CSSValueAllowEnd:
-        return AllowEndHangingPunctuation;
+        return HangingPunctuation::AllowEnd;
     case CSSValueForceEnd:
-        return ForceEndHangingPunctuation;
+        return HangingPunctuation::ForceEnd;
     default:
         break;
     }
     
     ASSERT_NOT_REACHED();
-    return NoHangingPunctuation;
+    return OptionSet<HangingPunctuation> { };
 }
 
 template<> inline CSSPrimitiveValue::operator LineBreak() const
@@ -2579,31 +2580,31 @@ template<> inline CSSPrimitiveValue::operator TextJustify() const
 }
 #endif // CSS3_TEXT
 
-template<> inline CSSPrimitiveValue::operator TextDecoration() const
+template<> inline CSSPrimitiveValue::operator OptionSet<TextDecoration>() const
 {
     ASSERT(isValueID());
 
     switch (m_value.valueID) {
     case CSSValueNone:
-        return TextDecorationNone;
+        return OptionSet<TextDecoration> { };
     case CSSValueUnderline:
-        return TextDecorationUnderline;
+        return TextDecoration::Underline;
     case CSSValueOverline:
-        return TextDecorationOverline;
+        return TextDecoration::Overline;
     case CSSValueLineThrough:
-        return TextDecorationLineThrough;
+        return TextDecoration::LineThrough;
     case CSSValueBlink:
-        return TextDecorationBlink;
+        return TextDecoration::Blink;
 #if ENABLE(LETTERPRESS)
     case CSSValueWebkitLetterpress:
-        return TextDecorationLetterpress;
+        return TextDecoration::Letterpress;
 #endif
     default:
         break;
     }
 
     ASSERT_NOT_REACHED();
-    return TextDecorationNone;
+    return OptionSet<TextDecoration> { };
 }
 
 template<> inline CSSPrimitiveValue::operator TextDecorationStyle() const
@@ -2629,18 +2630,18 @@ template<> inline CSSPrimitiveValue::operator TextDecorationStyle() const
     return TextDecorationStyle::Solid;
 }
 
-template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextUnderlinePosition e)
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(OptionSet<TextUnderlinePosition> e)
     : CSSValue(PrimitiveClass)
 {
     m_primitiveUnitType = CSS_VALUE_ID;
-    switch (e) {
-    case TextUnderlinePositionAuto:
+    switch (static_cast<TextUnderlinePosition>(e.toRaw())) {
+    case TextUnderlinePosition::Auto:
         m_value.valueID = CSSValueAuto;
         break;
-    case TextUnderlinePositionAlphabetic:
+    case TextUnderlinePosition::Alphabetic:
         m_value.valueID = CSSValueAlphabetic;
         break;
-    case TextUnderlinePositionUnder:
+    case TextUnderlinePosition::Under:
         m_value.valueID = CSSValueUnder;
         break;
     }
@@ -2648,17 +2649,17 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextUnderlinePosition e)
     // FIXME: Implement support for 'under left' and 'under right' values.
 }
 
-template<> inline CSSPrimitiveValue::operator TextUnderlinePosition() const
+template<> inline CSSPrimitiveValue::operator OptionSet<TextUnderlinePosition>() const
 {
     ASSERT(isValueID());
 
     switch (m_value.valueID) {
     case CSSValueAuto:
-        return TextUnderlinePositionAuto;
+        return TextUnderlinePosition::Auto;
     case CSSValueAlphabetic:
-        return TextUnderlinePositionAlphabetic;
+        return TextUnderlinePosition::Alphabetic;
     case CSSValueUnder:
-        return TextUnderlinePositionUnder;
+        return TextUnderlinePosition::Under;
     default:
         break;
     }
@@ -2666,7 +2667,7 @@ template<> inline CSSPrimitiveValue::operator TextUnderlinePosition() const
     // FIXME: Implement support for 'under left' and 'under right' values.
 
     ASSERT_NOT_REACHED();
-    return TextUnderlinePositionAuto;
+    return TextUnderlinePosition::Auto;
 }
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextSecurity e)
@@ -3820,24 +3821,24 @@ template<> inline CSSPrimitiveValue::operator LineAlign() const
     return LineAlign::None;
 }
 
-template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ESpeakAs e)
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(SpeakAs e)
     : CSSValue(PrimitiveClass)
 {
     m_primitiveUnitType = CSS_VALUE_ID;
     switch (e) {
-    case SpeakNormal:
+    case SpeakAs::Normal:
         m_value.valueID = CSSValueNormal;
         break;
-    case SpeakSpellOut:
+    case SpeakAs::SpellOut:
         m_value.valueID = CSSValueSpellOut;
         break;
-    case SpeakDigits:
+    case SpeakAs::Digits:
         m_value.valueID = CSSValueDigits;
         break;
-    case SpeakLiteralPunctuation:
+    case SpeakAs::LiteralPunctuation:
         m_value.valueID = CSSValueLiteralPunctuation;
         break;
-    case SpeakNoPunctuation:
+    case SpeakAs::NoPunctuation:
         m_value.valueID = CSSValueNoPunctuation;
         break;
     }
@@ -3874,27 +3875,27 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Order e)
     }
 }
 
-template<> inline CSSPrimitiveValue::operator ESpeakAs() const
+template<> inline CSSPrimitiveValue::operator OptionSet<SpeakAs>() const
 {
     ASSERT(isValueID());
 
     switch (m_value.valueID) {
     case CSSValueNormal:
-        return SpeakNormal;
+        return OptionSet<SpeakAs> { };
     case CSSValueSpellOut:
-        return SpeakSpellOut;
+        return SpeakAs::SpellOut;
     case CSSValueDigits:
-        return SpeakDigits;
+        return SpeakAs::Digits;
     case CSSValueLiteralPunctuation:
-        return SpeakLiteralPunctuation;
+        return SpeakAs::LiteralPunctuation;
     case CSSValueNoPunctuation:
-        return SpeakNoPunctuation;
+        return SpeakAs::NoPunctuation;
     default:
         break;
     }
 
     ASSERT_NOT_REACHED();
-    return SpeakNormal;
+    return OptionSet<SpeakAs> { };
 }
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BlendMode blendMode)
index d52f602..6764178 100644 (file)
@@ -69,7 +69,7 @@ public:
     static float convertSpacing(StyleResolver&, const CSSValue&);
     static LengthSize convertRadius(StyleResolver&, const CSSValue&);
     static LengthPoint convertObjectPosition(StyleResolver&, const CSSValue&);
-    static TextDecoration convertTextDecoration(StyleResolver&, const CSSValue&);
+    static OptionSet<TextDecoration> convertTextDecoration(StyleResolver&, const CSSValue&);
     template<typename T> static T convertNumber(StyleResolver&, const CSSValue&);
     template<typename T> static T convertNumberOrAuto(StyleResolver&, const CSSValue&);
     static short convertWebkitHyphenateLimitLines(StyleResolver&, const CSSValue&);
@@ -80,19 +80,19 @@ public:
     static String convertString(StyleResolver&, const CSSValue&);
     static String convertStringOrAuto(StyleResolver&, const CSSValue&);
     static String convertStringOrNone(StyleResolver&, const CSSValue&);
-    static TextEmphasisPosition convertTextEmphasisPosition(StyleResolver&, const CSSValue&);
+    static OptionSet<TextEmphasisPosition> convertTextEmphasisPosition(StyleResolver&, const CSSValue&);
     static TextAlignMode convertTextAlign(StyleResolver&, const CSSValue&);
     static RefPtr<ClipPathOperation> convertClipPath(StyleResolver&, const CSSValue&);
     static Resize convertResize(StyleResolver&, const CSSValue&);
     static int convertMarqueeRepetition(StyleResolver&, const CSSValue&);
     static int convertMarqueeSpeed(StyleResolver&, const CSSValue&);
     static Ref<QuotesData> convertQuotes(StyleResolver&, const CSSValue&);
-    static TextUnderlinePosition convertTextUnderlinePosition(StyleResolver&, const CSSValue&);
+    static OptionSet<TextUnderlinePosition> convertTextUnderlinePosition(StyleResolver&, const CSSValue&);
     static RefPtr<StyleReflection> convertReflection(StyleResolver&, const CSSValue&);
     static IntSize convertInitialLetter(StyleResolver&, const CSSValue&);
     static float convertTextStrokeWidth(StyleResolver&, const CSSValue&);
     static LineBoxContain convertLineBoxContain(StyleResolver&, const CSSValue&);
-    static TextDecorationSkip convertTextDecorationSkip(StyleResolver&, const CSSValue&);
+    static OptionSet<TextDecorationSkip> convertTextDecorationSkip(StyleResolver&, const CSSValue&);
     static RefPtr<ShapeValue> convertShapeValue(StyleResolver&, CSSValue&);
 #if ENABLE(CSS_SCROLL_SNAP)
     static ScrollSnapType convertScrollSnapType(StyleResolver&, const CSSValue&);
@@ -144,9 +144,9 @@ public:
     static BreakBetween convertColumnBreakBetween(StyleResolver&, const CSSValue&);
     static BreakInside convertColumnBreakInside(StyleResolver&, const CSSValue&);
 
-    static HangingPunctuation convertHangingPunctuation(StyleResolver&, const CSSValue&);
+    static OptionSet<HangingPunctuation> convertHangingPunctuation(StyleResolver&, const CSSValue&);
 
-    static ESpeakAs convertSpeakAs(StyleResolver&, const CSSValue&);
+    static OptionSet<SpeakAs> convertSpeakAs(StyleResolver&, const CSSValue&);
 
     static Length convertPositionComponentX(StyleResolver&, const CSSValue&);
     static Length convertPositionComponentY(StyleResolver&, const CSSValue&);
@@ -157,8 +157,8 @@ private:
     friend class StyleBuilderCustom;
 
     static Length convertToRadiusLength(CSSToLengthConversionData&, const CSSPrimitiveValue&);
-    static TextEmphasisPosition valueToEmphasisPosition(const CSSPrimitiveValue&);
-    static TextDecorationSkip valueToDecorationSkip(const CSSPrimitiveValue&);
+    static OptionSet<TextEmphasisPosition> valueToEmphasisPosition(const CSSPrimitiveValue&);
+    static OptionSet<TextDecorationSkip> valueToDecorationSkip(const CSSPrimitiveValue&);
 #if ENABLE(CSS_SCROLL_SNAP)
     static Length parseSnapCoordinate(StyleResolver&, const CSSValue&);
 #endif
@@ -389,9 +389,9 @@ inline LengthPoint StyleBuilderConverter::convertObjectPosition(StyleResolver& s
     return LengthPoint(lengthX, lengthY);
 }
 
-inline TextDecoration StyleBuilderConverter::convertTextDecoration(StyleResolver&, const CSSValue& value)
+inline OptionSet<TextDecoration> StyleBuilderConverter::convertTextDecoration(StyleResolver&, const CSSValue& value)
 {
-    TextDecoration result = RenderStyle::initialTextDecoration();
+    auto result = RenderStyle::initialTextDecoration();
     if (is<CSSValueList>(value)) {
         for (auto& currentValue : downcast<CSSValueList>(value))
             result |= downcast<CSSPrimitiveValue>(currentValue.get());
@@ -470,19 +470,19 @@ inline String StyleBuilderConverter::convertStringOrNone(StyleResolver& styleRes
     return convertString(styleResolver, value);
 }
 
-inline TextEmphasisPosition StyleBuilderConverter::valueToEmphasisPosition(const CSSPrimitiveValue& primitiveValue)
+inline OptionSet<TextEmphasisPosition> StyleBuilderConverter::valueToEmphasisPosition(const CSSPrimitiveValue& primitiveValue)
 {
     ASSERT(primitiveValue.isValueID());
 
     switch (primitiveValue.valueID()) {
     case CSSValueOver:
-        return TextEmphasisPositionOver;
+        return TextEmphasisPosition::Over;
     case CSSValueUnder:
-        return TextEmphasisPositionUnder;
+        return TextEmphasisPosition::Under;
     case CSSValueLeft:
-        return TextEmphasisPositionLeft;
+        return TextEmphasisPosition::Left;
     case CSSValueRight:
-        return TextEmphasisPositionRight;
+        return TextEmphasisPosition::Right;
     default:
         break;
     }
@@ -491,12 +491,12 @@ inline TextEmphasisPosition StyleBuilderConverter::valueToEmphasisPosition(const
     return RenderStyle::initialTextEmphasisPosition();
 }
 
-inline TextEmphasisPosition StyleBuilderConverter::convertTextEmphasisPosition(StyleResolver&, const CSSValue& value)
+inline OptionSet<TextEmphasisPosition> StyleBuilderConverter::convertTextEmphasisPosition(StyleResolver&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value))
         return valueToEmphasisPosition(downcast<CSSPrimitiveValue>(value));
 
-    TextEmphasisPosition position = 0;
+    OptionSet<TextEmphasisPosition> position;
     for (auto& currentValue : downcast<CSSValueList>(value))
         position |= valueToEmphasisPosition(downcast<CSSPrimitiveValue>(currentValue.get()));
     return position;
@@ -637,18 +637,16 @@ inline Ref<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolver&, cons
     return QuotesData::create(quotes);
 }
 
-inline TextUnderlinePosition StyleBuilderConverter::convertTextUnderlinePosition(StyleResolver&, const CSSValue& value)
+inline OptionSet<TextUnderlinePosition> StyleBuilderConverter::convertTextUnderlinePosition(StyleResolver&, const CSSValue& value)
 {
     // This is true if value is 'auto' or 'alphabetic'.
     if (is<CSSPrimitiveValue>(value))
         return downcast<CSSPrimitiveValue>(value);
 
-    unsigned combinedPosition = 0;
-    for (auto& currentValue : downcast<CSSValueList>(value)) {
-        TextUnderlinePosition position = downcast<CSSPrimitiveValue>(currentValue.get());
-        combinedPosition |= position;
-    }
-    return static_cast<TextUnderlinePosition>(combinedPosition);
+    OptionSet<TextUnderlinePosition> combinedPosition;
+    for (auto& currentValue : downcast<CSSValueList>(value))
+        combinedPosition |= downcast<CSSPrimitiveValue>(currentValue.get());
+    return combinedPosition;
 }
 
 inline RefPtr<StyleReflection> StyleBuilderConverter::convertReflection(StyleResolver& styleResolver, const CSSValue& value)
@@ -727,33 +725,33 @@ inline LineBoxContain StyleBuilderConverter::convertLineBoxContain(StyleResolver
     return downcast<CSSLineBoxContainValue>(value).value();
 }
 
-inline TextDecorationSkip StyleBuilderConverter::valueToDecorationSkip(const CSSPrimitiveValue& primitiveValue)
+inline OptionSet<TextDecorationSkip> StyleBuilderConverter::valueToDecorationSkip(const CSSPrimitiveValue& primitiveValue)
 {
     ASSERT(primitiveValue.isValueID());
 
     switch (primitiveValue.valueID()) {
     case CSSValueAuto:
-        return TextDecorationSkipAuto;
+        return TextDecorationSkip::Auto;
     case CSSValueNone:
-        return TextDecorationSkipNone;
+        return OptionSet<TextDecorationSkip> { };
     case CSSValueInk:
-        return TextDecorationSkipInk;
+        return TextDecorationSkip::Ink;
     case CSSValueObjects:
-        return TextDecorationSkipObjects;
+        return TextDecorationSkip::Objects;
     default:
         break;
     }
 
     ASSERT_NOT_REACHED();
-    return TextDecorationSkipNone;
+    return OptionSet<TextDecorationSkip> { };
 }
 
-inline TextDecorationSkip StyleBuilderConverter::convertTextDecorationSkip(StyleResolver&, const CSSValue& value)
+inline OptionSet<TextDecorationSkip> StyleBuilderConverter::convertTextDecorationSkip(StyleResolver&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value))
         return valueToDecorationSkip(downcast<CSSPrimitiveValue>(value));
 
-    TextDecorationSkip skip = TextDecorationSkipNone;
+    OptionSet<TextDecorationSkip> skip;
     for (auto& currentValue : downcast<CSSValueList>(value))
         skip |= valueToDecorationSkip(downcast<CSSPrimitiveValue>(currentValue.get()));
     return skip;
@@ -1500,9 +1498,9 @@ inline BreakInside StyleBuilderConverter::convertColumnBreakInside(StyleResolver
     return primitiveValue;
 }
     
-inline ESpeakAs StyleBuilderConverter::convertSpeakAs(StyleResolver&, const CSSValue& value)
+inline OptionSet<SpeakAs> StyleBuilderConverter::convertSpeakAs(StyleResolver&, const CSSValue& value)
 {
-    ESpeakAs result = RenderStyle::initialSpeakAs();
+    auto result = RenderStyle::initialSpeakAs();
     if (is<CSSValueList>(value)) {
         for (auto& currentValue : downcast<CSSValueList>(value))
             result |= downcast<CSSPrimitiveValue>(currentValue.get());
@@ -1510,9 +1508,9 @@ inline ESpeakAs StyleBuilderConverter::convertSpeakAs(StyleResolver&, const CSSV
     return result;
 }
 
-inline HangingPunctuation StyleBuilderConverter::convertHangingPunctuation(StyleResolver&, const CSSValue& value)
+inline OptionSet<HangingPunctuation> StyleBuilderConverter::convertHangingPunctuation(StyleResolver&, const CSSValue& value)
 {
-    HangingPunctuation result = RenderStyle::initialHangingPunctuation();
+    auto result = RenderStyle::initialHangingPunctuation();
     if (is<CSSValueList>(value)) {
         for (auto& currentValue : downcast<CSSValueList>(value))
             result |= downcast<CSSPrimitiveValue>(currentValue.get());
index d01daf3..31d7b2e 100644 (file)
@@ -71,10 +71,10 @@ void Editor::getTextDecorationAttributesRespectingTypingStyle(const RenderStyle&
                 [result setObject:@(NSUnderlineStyleSingle) forKey:NSUnderlineStyleAttributeName];
         }
     } else {
-        int decoration = style.textDecorationsInEffect();
-        if (decoration & TextDecorationLineThrough)
+        auto decoration = style.textDecorationsInEffect();
+        if (decoration & TextDecoration::LineThrough)
             [result setObject:@(NSUnderlineStyleSingle) forKey:NSStrikethroughStyleAttributeName];
-        if (decoration & TextDecorationUnderline)
+        if (decoration & TextDecoration::Underline)
             [result setObject:@(NSUnderlineStyleSingle) forKey:NSUnderlineStyleAttributeName];
     }
 }
index 9e3f92b..9f3efa0 100644 (file)
@@ -2505,9 +2505,9 @@ NSAttributedString *editingAttributedStringFromRange(Range& range, IncludeImages
         if (!renderer)
             continue;
         const RenderStyle& style = renderer->style();
-        if (style.textDecorationsInEffect() & TextDecorationUnderline)
+        if (style.textDecorationsInEffect() & TextDecoration::Underline)
             [attrs.get() setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
-        if (style.textDecorationsInEffect() & TextDecorationLineThrough)
+        if (style.textDecorationsInEffect() & TextDecoration::LineThrough)
             [attrs.get() setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];
         if (auto font = style.fontCascade().primaryFont().getCTFont())
             [attrs.get() setObject:toNSFont(font) forKey:NSFontAttributeName];
index 7fbb1e7..80f3c91 100644 (file)
@@ -745,7 +745,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
     }
 }
 
-void InlineFlowBox::maxLogicalBottomForTextDecorationLine(float& maxLogicalBottom, const RenderElement* decorationRenderer, TextDecoration textDecoration) const
+void InlineFlowBox::maxLogicalBottomForTextDecorationLine(float& maxLogicalBottom, const RenderElement* decorationRenderer, OptionSet<TextDecoration> textDecoration) const
 {
     for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
         if (child->renderer().isOutOfFlowPositioned())
@@ -760,13 +760,13 @@ void InlineFlowBox::maxLogicalBottomForTextDecorationLine(float& maxLogicalBotto
         if (is<InlineFlowBox>(*child))
             downcast<InlineFlowBox>(*child).maxLogicalBottomForTextDecorationLine(maxLogicalBottom, decorationRenderer, textDecoration);
         else {
-            if (child->isInlineTextBox() || child->lineStyle().textDecorationSkip() == TextDecorationSkipNone)
+            if (child->isInlineTextBox() || child->lineStyle().textDecorationSkip().isEmpty())
                 maxLogicalBottom = std::max<float>(maxLogicalBottom, child->logicalBottom());
         }
     }
 }
 
-void InlineFlowBox::minLogicalTopForTextDecorationLine(float& minLogicalTop, const RenderElement* decorationRenderer, TextDecoration textDecoration) const
+void InlineFlowBox::minLogicalTopForTextDecorationLine(float& minLogicalTop, const RenderElement* decorationRenderer, OptionSet<TextDecoration> textDecoration) const
 {
     for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
         if (child->renderer().isOutOfFlowPositioned())
@@ -781,7 +781,7 @@ void InlineFlowBox::minLogicalTopForTextDecorationLine(float& minLogicalTop, con
         if (is<InlineFlowBox>(*child))
             downcast<InlineFlowBox>(*child).minLogicalTopForTextDecorationLine(minLogicalTop, decorationRenderer, textDecoration);
         else {
-            if (child->isInlineTextBox() || child->lineStyle().textDecorationSkip() == TextDecorationSkipNone)
+            if (child->isInlineTextBox() || child->lineStyle().textDecorationSkip().isEmpty())
                 minLogicalTop = std::min<float>(minLogicalTop, child->logicalTop());
         }
     }
index a02571a..6c4d58f 100644 (file)
@@ -293,9 +293,9 @@ public:
 
     void computeReplacedAndTextLineTopAndBottom(LayoutUnit& lineTop, LayoutUnit& lineBottom) const;
     
-    // Used to calculate the underline offset for TextUnderlinePositionUnder.
-    void maxLogicalBottomForTextDecorationLine(float& maxLogicalBottom, const RenderElement* decorationRenderer, TextDecoration) const;
-    void minLogicalTopForTextDecorationLine(float& minLogicalTop, const RenderElement* decorationRenderer, TextDecoration) const;
+    // Used to calculate the underline offset for TextUnderlinePosition::Under.
+    void maxLogicalBottomForTextDecorationLine(float& maxLogicalBottom, const RenderElement* decorationRenderer, OptionSet<TextDecoration>) const;
+    void minLogicalTopForTextDecorationLine(float& minLogicalTop, const RenderElement* decorationRenderer, OptionSet<TextDecoration>) const;
 
 private:
     bool isInlineFlowBox() const final { return true; }
index c3e3b3e..d537e55 100644 (file)
@@ -353,9 +353,9 @@ bool InlineTextBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
     return false;
 }
 
-static inline bool emphasisPositionHasNeitherLeftNorRight(TextEmphasisPosition emphasisPosition)
+static inline bool emphasisPositionHasNeitherLeftNorRight(OptionSet<TextEmphasisPosition> emphasisPosition)
 {
-    return !(emphasisPosition & TextEmphasisPositionLeft) && !(emphasisPosition & TextEmphasisPositionRight);
+    return !(emphasisPosition & TextEmphasisPosition::Left) && !(emphasisPosition & TextEmphasisPosition::Right);
 }
 
 bool InlineTextBox::emphasisMarkExistsAndIsAbove(const RenderStyle& style, bool& above) const
@@ -364,19 +364,19 @@ bool InlineTextBox::emphasisMarkExistsAndIsAbove(const RenderStyle& style, bool&
     if (style.textEmphasisMark() == TextEmphasisMark::None)
         return false;
 
-    TextEmphasisPosition emphasisPosition = style.textEmphasisPosition();
-    ASSERT(!((emphasisPosition & TextEmphasisPositionOver) && (emphasisPosition & TextEmphasisPositionUnder)));
-    ASSERT(!((emphasisPosition & TextEmphasisPositionLeft) && (emphasisPosition & TextEmphasisPositionRight)));
+    auto emphasisPosition = style.textEmphasisPosition();
+    ASSERT(!((emphasisPosition & TextEmphasisPosition::Over) && (emphasisPosition & TextEmphasisPosition::Under)));
+    ASSERT(!((emphasisPosition & TextEmphasisPosition::Left) && (emphasisPosition & TextEmphasisPosition::Right)));
     
     if (emphasisPositionHasNeitherLeftNorRight(emphasisPosition))
-        above = emphasisPosition & TextEmphasisPositionOver;
+        above = emphasisPosition.contains(TextEmphasisPosition::Over);
     else if (style.isHorizontalWritingMode())
-        above = emphasisPosition & TextEmphasisPositionOver;
+        above = emphasisPosition.contains(TextEmphasisPosition::Over);
     else
-        above = emphasisPosition & TextEmphasisPositionRight;
+        above = emphasisPosition.contains(TextEmphasisPosition::Right);
     
-    if ((style.isHorizontalWritingMode() && (emphasisPosition & TextEmphasisPositionUnder))
-        || (!style.isHorizontalWritingMode() && (emphasisPosition & TextEmphasisPositionLeft)))
+    if ((style.isHorizontalWritingMode() && (emphasisPosition & TextEmphasisPosition::Under))
+        || (!style.isHorizontalWritingMode() && (emphasisPosition & TextEmphasisPosition::Left)))
         return true; // Ruby text is always over, so it cannot suppress emphasis marks under.
 
     RenderBlock* containingBlock = renderer().containingBlock();
@@ -568,8 +568,8 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
     paintMarkedTexts(paintInfo, TextPaintPhase::Foreground, boxRect, coalescedStyledMarkedTexts);
 
     // Paint decorations
-    TextDecoration textDecorations = lineStyle.textDecorationsInEffect();
-    if (textDecorations != TextDecorationNone && paintInfo.phase != PaintPhaseSelection) {
+    auto textDecorations = lineStyle.textDecorationsInEffect();
+    if (!textDecorations.isEmpty() && paintInfo.phase != PaintPhaseSelection) {
         TextRun textRun = createTextRun();
         unsigned length = textRun.length();
         if (m_truncation != cNoTruncation)
@@ -1061,7 +1061,7 @@ void InlineTextBox::paintMarkedTextDecoration(PaintInfo& paintInfo, const FloatR
     }
 
     // 2. Paint
-    TextDecorationPainter decorationPainter { context, static_cast<unsigned>(lineStyle().textDecorationsInEffect()), renderer(), isFirstLine(), markedText.style.textDecorationStyles };
+    TextDecorationPainter decorationPainter { context, lineStyle().textDecorationsInEffect(), renderer(), isFirstLine(), markedText.style.textDecorationStyles };
     decorationPainter.setInlineTextBox(this);
     decorationPainter.setFont(lineFont());
     decorationPainter.setWidth(snappedSelectionRect.width());
index 194629e..e81d0a2 100644 (file)
@@ -4097,8 +4097,8 @@ void RenderBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical
     RenderObject* prevFloat = 0;
     bool isPrevChildInlineFlow = false;
     bool shouldBreakLineAfterText = false;
-    bool canHangPunctuationAtStart = styleToUse.hangingPunctuation() & FirstHangingPunctuation;
-    bool canHangPunctuationAtEnd = styleToUse.hangingPunctuation() & LastHangingPunctuation;
+    bool canHangPunctuationAtStart = styleToUse.hangingPunctuation().contains(HangingPunctuation::First);
+    bool canHangPunctuationAtEnd = styleToUse.hangingPunctuation().contains(HangingPunctuation::Last);
     RenderText* lastText = nullptr;
 
     bool addedStartPunctuationHang = false;
index 93f42c2..1ec11c3 100644 (file)
@@ -532,7 +532,7 @@ static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* ru
     }
 
     // Include text decoration visual overflow as part of the glyph overflow.
-    if (renderer.style().textDecorationsInEffect() != TextDecorationNone)
+    if (!renderer.style().textDecorationsInEffect().isEmpty())
         glyphOverflow.extendTo(visualOverflowForDecorations(run->box()->lineStyle(), downcast<InlineTextBox>(run->box())));
 
     if (!glyphOverflow.isEmpty()) {
@@ -830,8 +830,8 @@ BidiRun* RenderBlockFlow::computeInlineDirectionPositionsForSegment(RootInlineBo
     WordMeasurements& wordMeasurements)
 {
     bool needsWordSpacing = false;
-    bool canHangPunctuationAtStart = style().hangingPunctuation() & FirstHangingPunctuation;
-    bool canHangPunctuationAtEnd = style().hangingPunctuation() & LastHangingPunctuation;
+    bool canHangPunctuationAtStart = style().hangingPunctuation().contains(HangingPunctuation::First);
+    bool canHangPunctuationAtEnd = style().hangingPunctuation().contains(HangingPunctuation::Last);
     bool isLTR = style().isLeftToRightDirection();
     float totalLogicalWidth = lineBox->getFlowSpacingLogicalWidth();
     unsigned expansionOpportunityCount = 0;
index 849ce74..a4c0acc 100644 (file)
@@ -1539,7 +1539,7 @@ LayoutRect RenderElement::absoluteAnchorRect(bool* insideFixed) const
     return enclosingLayoutRect(FloatRect(upperLeft, lowerRight.expandedTo(upperLeft) - upperLeft));
 }
 
-const RenderElement* RenderElement::enclosingRendererWithTextDecoration(TextDecoration textDecoration, bool firstLine) const
+const RenderElement* RenderElement::enclosingRendererWithTextDecoration(OptionSet<TextDecoration> textDecoration, bool firstLine) const
 {
     const RenderElement* current = this;
     do {
index 877c55b..09db1a4 100644 (file)
@@ -195,7 +195,7 @@ public:
     bool hasCounterNodeMap() const { return m_hasCounterNodeMap; }
     void setHasCounterNodeMap(bool f) { m_hasCounterNodeMap = f; }
 
-    const RenderElement* enclosingRendererWithTextDecoration(TextDecoration, bool firstLine) const;
+    const RenderElement* enclosingRendererWithTextDecoration(OptionSet<TextDecoration>, bool firstLine) const;
     void drawLineForBoxSide(GraphicsContext&, const FloatRect&, BoxSide, Color, BorderStyle, float adjacentWidth1, float adjacentWidth2, bool antialias = false) const;
 
 #if ENABLE(TEXT_AUTOSIZING)
index 1f4a4f6..1607a12 100644 (file)
@@ -168,10 +168,10 @@ void RenderTableSection::addCell(RenderTableCell* cell, RenderTableRow* row)
 
     // ### mozilla still seems to do the old HTML way, even for strict DTD
     // (see the annotation on table cell layouting in the CSS specs and the testcase below:
-    // <DisplayType::Table border>
+    // <TABLE border>
     // <TR><TD>1 <TD rowspan="2">2 <TD>3 <TD>4
     // <TR><TD colspan="2">5
-    // </DisplayType::Table>
+    // </TABLE>
     while (m_cCol < nCols && (cellAt(insertionRow, m_cCol).hasCells() || cellAt(insertionRow, m_cCol).inColSpan))
         m_cCol++;
 
index ba0e3e3..e0c7bea 100644 (file)
@@ -200,7 +200,7 @@ static AvoidanceReasonFlags canUseForStyle(const RenderStyle& style, IncludeReas
     AvoidanceReasonFlags reasons = { };
     if (style.textOverflow() == TextOverflow::Ellipsis)
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasTextOverflow, reasons, includeReasons);
-    if ((style.textDecorationsInEffect() & TextDecorationUnderline) && style.textUnderlinePosition() == TextUnderlinePositionUnder)
+    if ((style.textDecorationsInEffect() & TextDecoration::Underline) && style.textUnderlinePosition() == TextUnderlinePosition::Under)
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasUnsupportedUnderlineDecoration, reasons, includeReasons);
     // Non-visible overflow should be pretty easy to support.
     if (style.overflowX() != Overflow::Visible || style.overflowY() != Overflow::Visible)
@@ -289,7 +289,7 @@ AvoidanceReasonFlags canUseForWithReason(const RenderBlockFlow& flow, IncludeRea
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasOutline, reasons, includeReasons);
     if (flow.isRubyText() || flow.isRubyBase())
         SET_REASON_AND_RETURN_IF_NEEDED(FlowIsRuby, reasons, includeReasons);
-    if (flow.style().hangingPunctuation() != NoHangingPunctuation)
+    if (!flow.style().hangingPunctuation().isEmpty())
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasHangingPunctuation, reasons, includeReasons);
     
     // Printing does pagination without a flow thread.
index 0292f91..9b9b635 100644 (file)
@@ -94,7 +94,7 @@ void paintFlow(const RenderBlockFlow& flow, const Layout& layout, PaintInfo& pai
     }
 
     std::optional<TextDecorationPainter> textDecorationPainter;
-    if (style.textDecorationsInEffect() != TextDecorationNone) {
+    if (!style.textDecorationsInEffect().isEmpty()) {
         const RenderText* textRenderer = childrenOfType<RenderText>(flow).first();
         if (textRenderer) {
             textDecorationPainter.emplace(paintInfo.context(), style.textDecorationsInEffect(), *textRenderer, false);
index ec6c9ef..82d1c92 100644 (file)
@@ -247,9 +247,9 @@ bool TextDecorationPainter::Styles::operator==(const Styles& other) const
         && underlineStyle == other.underlineStyle && overlineStyle == other.overlineStyle && linethroughStyle == other.linethroughStyle;
 }
 
-TextDecorationPainter::TextDecorationPainter(GraphicsContext& context, unsigned decorations, const RenderText& renderer, bool isFirstLine, std::optional<Styles> styles)
+TextDecorationPainter::TextDecorationPainter(GraphicsContext& context, OptionSet<TextDecoration> decorations, const RenderText& renderer, bool isFirstLine, std::optional<Styles> styles)
     : m_context { context }
-    , m_decorations { OptionSet<TextDecoration>::fromRaw(decorations) }
+    , m_decorations { decorations }
     , m_wavyOffset { wavyOffsetFromDecoration() }
     , m_isPrinting { renderer.document().printing() }
     , m_styles { styles ? *WTFMove(styles) : stylesForRenderer(renderer, decorations, isFirstLine, PseudoId::None) }
@@ -268,16 +268,16 @@ void TextDecorationPainter::paintTextDecoration(const TextRun& textRun, const Fl
     m_context.setStrokeThickness(textDecorationThickness);
     FloatPoint localOrigin = boxOrigin;
 
-    auto paintDecoration = [&] (TextDecoration decoration, TextDecorationStyle style, const Color& color, const FloatPoint& start, const FloatPoint& end, int offset) {
+    auto paintDecoration = [&] (OptionSet<TextDecoration> decoration, TextDecorationStyle style, const Color& color, const FloatPoint& start, const FloatPoint& end, int offset) {
         m_context.setStrokeColor(color);
 
         auto strokeStyle = textDecorationStyleToStrokeStyle(style);
 
         if (style == TextDecorationStyle::Wavy)
             strokeWavyTextDecoration(m_context, start, end, textDecorationThickness, m_lineStyle.computedFontPixelSize());
-        else if (decoration == TextDecorationUnderline || decoration == TextDecorationOverline) {
+        else if (decoration == TextDecoration::Underline || decoration == TextDecoration::Overline) {
 #if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
-            if ((m_lineStyle.textDecorationSkip() == TextDecorationSkipInk || m_lineStyle.textDecorationSkip() == TextDecorationSkipAuto) && m_isHorizontal) {
+            if ((m_lineStyle.textDecorationSkip() == TextDecorationSkip::Ink || m_lineStyle.textDecorationSkip() == TextDecorationSkip::Auto) && m_isHorizontal) {
                 if (!m_context.paintingDisabled())
                     drawSkipInkUnderline(m_context, *m_font, textRun, textOrigin, localOrigin, offset, m_width, m_isPrinting, style == TextDecorationStyle::Double, strokeStyle);
             } else
@@ -286,14 +286,14 @@ void TextDecorationPainter::paintTextDecoration(const TextRun& textRun, const Fl
                 m_context.drawLineForText(start, m_width, m_isPrinting, style == TextDecorationStyle::Double, strokeStyle);
             
         } else {
-            ASSERT(decoration == TextDecorationLineThrough);
+            ASSERT(decoration == TextDecoration::LineThrough);
             m_context.drawLineForText(start, m_width, m_isPrinting, style == TextDecorationStyle::Double, strokeStyle);
         }
     };
 
-    bool areLinesOpaque = !m_isPrinting && (!m_decorations.contains(TextDecorationUnderline) || m_styles.underlineColor.isOpaque())
-        && (!m_decorations.contains(TextDecorationOverline) || m_styles.overlineColor.isOpaque())
-        && (!m_decorations.contains(TextDecorationLineThrough) || m_styles.linethroughColor.isOpaque());
+    bool areLinesOpaque = !m_isPrinting && (!m_decorations.contains(TextDecoration::Underline) || m_styles.underlineColor.isOpaque())
+        && (!m_decorations.contains(TextDecoration::Overline) || m_styles.overlineColor.isOpaque())
+        && (!m_decorations.contains(TextDecoration::LineThrough) || m_styles.linethroughColor.isOpaque());
 
     int extraOffset = 0;
     bool clipping = !areLinesOpaque && m_shadow && m_shadow->next();
@@ -334,23 +334,23 @@ void TextDecorationPainter::paintTextDecoration(const TextRun& textRun, const Fl
         }
 
         // These decorations should match the visual overflows computed in visualOverflowForDecorations().
-        if (m_decorations.contains(TextDecorationUnderline)) {
+        if (m_decorations.contains(TextDecoration::Underline)) {
             int offset = computeUnderlineOffset(m_lineStyle.textUnderlinePosition(), m_lineStyle.fontMetrics(), m_inlineTextBox, textDecorationThickness);
             float wavyOffset = m_styles.underlineStyle == TextDecorationStyle::Wavy ? m_wavyOffset : 0;
             FloatPoint start = localOrigin + FloatSize(0, offset + wavyOffset);
             FloatPoint end = localOrigin + FloatSize(m_width, offset + wavyOffset);
-            paintDecoration(TextDecorationUnderline, m_styles.underlineStyle, m_styles.underlineColor, start, end, offset);
+            paintDecoration(TextDecoration::Underline, m_styles.underlineStyle, m_styles.underlineColor, start, end, offset);
         }
-        if (m_decorations.contains(TextDecorationOverline)) {
+        if (m_decorations.contains(TextDecoration::Overline)) {
             float wavyOffset = m_styles.overlineStyle == TextDecorationStyle::Wavy ? m_wavyOffset : 0;
             FloatPoint start = localOrigin - FloatSize(0, wavyOffset);
             FloatPoint end = localOrigin + FloatSize(m_width, -wavyOffset);
-            paintDecoration(TextDecorationOverline, m_styles.overlineStyle, m_styles.overlineColor, start, end, 0);
+            paintDecoration(TextDecoration::Overline, m_styles.overlineStyle, m_styles.overlineColor, start, end, 0);
         }
-        if (m_decorations.contains(TextDecorationLineThrough)) {
+        if (m_decorations.contains(TextDecoration::LineThrough)) {
             FloatPoint start = localOrigin + FloatSize(0, 2 * m_baseline / 3);
             FloatPoint end = localOrigin + FloatSize(m_width, 2 * m_baseline / 3);
-            paintDecoration(TextDecorationLineThrough, m_styles.linethroughStyle, m_styles.linethroughColor, start, end, 0);
+            paintDecoration(TextDecoration::LineThrough, m_styles.linethroughStyle, m_styles.linethroughColor, start, end, 0);
         }
     } while (shadow);
 
@@ -382,18 +382,18 @@ static void collectStylesForRenderer(TextDecorationPainter::Styles& result, cons
         auto color = decorationColor(style);
         auto decorationStyle = style.textDecorationStyle();
 
-        if (decorations.contains(TextDecorationUnderline)) {
-            remainingDecorations -= TextDecorationUnderline;
+        if (decorations.contains(TextDecoration::Underline)) {
+            remainingDecorations -= TextDecoration::Underline;
             result.underlineColor = color;
             result.underlineStyle = decorationStyle;
         }
-        if (decorations.contains(TextDecorationOverline)) {
-            remainingDecorations -= TextDecorationOverline;
+        if (decorations.contains(TextDecoration::Overline)) {
+            remainingDecorations -= TextDecoration::Overline;
             result.overlineColor = color;
             result.overlineStyle = decorationStyle;
         }
-        if (decorations.contains(TextDecorationLineThrough)) {
-            remainingDecorations -= TextDecorationLineThrough;
+        if (decorations.contains(TextDecoration::LineThrough)) {
+            remainingDecorations -= TextDecoration::LineThrough;
             result.linethroughColor = color;
             result.linethroughStyle = decorationStyle;
         }
@@ -412,7 +412,7 @@ static void collectStylesForRenderer(TextDecorationPainter::Styles& result, cons
     auto* current = &renderer;
     do {
         const auto& style = styleForRenderer(*current);
-        extractDecorations(style, OptionSet<TextDecoration>::fromRaw(style.textDecoration()));
+        extractDecorations(style, style.textDecoration());
 
         if (current->isRubyText())
             return;
@@ -431,12 +431,12 @@ static void collectStylesForRenderer(TextDecorationPainter::Styles& result, cons
         extractDecorations(styleForRenderer(*current), remainingDecorations);
 }
 
-auto TextDecorationPainter::stylesForRenderer(const RenderObject& renderer, unsigned requestedDecorations, bool firstLineStyle, PseudoId pseudoId) -> Styles
+auto TextDecorationPainter::stylesForRenderer(const RenderObject& renderer, OptionSet<TextDecoration> requestedDecorations, bool firstLineStyle, PseudoId pseudoId) -> Styles
 {
     Styles result;
-    collectStylesForRenderer(result, renderer, OptionSet<TextDecoration>::fromRaw(requestedDecorations), false, pseudoId);
+    collectStylesForRenderer(result, renderer, requestedDecorations, false, pseudoId);
     if (firstLineStyle)
-        collectStylesForRenderer(result, renderer, OptionSet<TextDecoration>::fromRaw(requestedDecorations), true, pseudoId);
+        collectStylesForRenderer(result, renderer, requestedDecorations, true, pseudoId);
     return result;
 }
 
index 42ad374..0294a46 100644 (file)
@@ -41,9 +41,8 @@ class TextRun;
     
 class TextDecorationPainter {
 public:
-    // FIXME: Make decorations an OptionSet<TextDecoration>. See <https://bugs.webkit.org/show_bug.cgi?id=176844>.
     struct Styles;
-    TextDecorationPainter(GraphicsContext&, unsigned decorations, const RenderText&, bool isFirstLine, std::optional<Styles> = std::nullopt);
+    TextDecorationPainter(GraphicsContext&, OptionSet<TextDecoration> decorations, const RenderText&, bool isFirstLine, std::optional<Styles> = std::nullopt);
     
     void setInlineTextBox(const InlineTextBox* inlineTextBox) { m_inlineTextBox = inlineTextBox; }
     void setFont(const FontCascade& font) { m_font = &font; }
@@ -66,8 +65,7 @@ public:
         TextDecorationStyle overlineStyle;
         TextDecorationStyle linethroughStyle;
     };
-    // FIXME: Make requestedDecorations an OptionSet<TextDecoration>. See <https://bugs.webkit.org/show_bug.cgi?id=176844>.
-    static Styles stylesForRenderer(const RenderObject&, unsigned requestedDecorations, bool firstLineStyle = false, PseudoId = PseudoId::None);
+    static Styles stylesForRenderer(const RenderObject&, OptionSet<TextDecoration> requestedDecorations, bool firstLineStyle = false, PseudoId = PseudoId::None);
 
 private:
     GraphicsContext& m_context;
index 7603f6f..3b4123a 100644 (file)
@@ -79,7 +79,7 @@ TextPaintStyle computeTextPaintStyle(const Frame& frame, const RenderStyle& line
     TextPaintStyle paintStyle;
 
 #if ENABLE(LETTERPRESS)
-    paintStyle.useLetterpressEffect = lineStyle.textDecorationsInEffect() & TextDecorationLetterpress;
+    paintStyle.useLetterpressEffect = lineStyle.textDecorationsInEffect().contains(TextDecoration::Letterpress);
 #endif
     auto viewportSize = frame.view() ? frame.view()->size() : IntSize();
     paintStyle.strokeWidth = lineStyle.computedStrokeWidth(viewportSize);
index 51935e7..fd919cf 100644 (file)
@@ -763,9 +763,9 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool
     const FontCascade& font = style.fontCascade();
     bool isFixedPitch = font.isFixedPitch();
     bool canHyphenate = style.hyphens() == Hyphens::Auto && WebCore::canHyphenate(style.locale());
-    bool canHangPunctuationAtStart = style.hangingPunctuation() & FirstHangingPunctuation;
-    bool canHangPunctuationAtEnd = style.hangingPunctuation() & LastHangingPunctuation;
-    bool canHangStopOrCommaAtLineEnd = style.hangingPunctuation() & AllowEndHangingPunctuation;
+    bool canHangPunctuationAtStart = style.hangingPunctuation().contains(HangingPunctuation::First);
+    bool canHangPunctuationAtEnd = style.hangingPunctuation().contains(HangingPunctuation::Last);
+    bool canHangStopOrCommaAtLineEnd = style.hangingPunctuation().contains(HangingPunctuation::AllowEnd);
     int endPunctuationIndex = canHangPunctuationAtEnd && m_collapseWhiteSpace ? renderText.lastCharacterIndexStrippingSpaces() : renderText.text().length() - 1;
     unsigned lastSpace = m_current.offset();
     float wordSpacing = m_currentStyle->fontCascade().wordSpacing();
index 658429d..f61988f 100644 (file)
@@ -147,7 +147,7 @@ RenderStyle::RenderStyle(CreateDefaultStyleTag)
     m_inheritedFlags.visibility = static_cast<unsigned>(initialVisibility());
     m_inheritedFlags.textAlign = static_cast<unsigned>(initialTextAlign());
     m_inheritedFlags.textTransform = static_cast<unsigned>(initialTextTransform());
-    m_inheritedFlags.textDecorations = initialTextDecoration();
+    m_inheritedFlags.textDecorations = initialTextDecoration().toRaw();
     m_inheritedFlags.cursor = static_cast<unsigned>(initialCursor());
 #if ENABLE(CURSOR_VISIBILITY)
     m_inheritedFlags.cursorVisibility = static_cast<unsigned>(initialCursorVisibility());
@@ -539,8 +539,8 @@ inline bool RenderStyle::changeAffectsVisualOverflow(const RenderStyle& other) c
         || m_rareNonInheritedData->textDecorationStyle != other.m_rareNonInheritedData->textDecorationStyle) {
         // Underlines are always drawn outside of their textbox bounds when text-underline-position: under;
         // is specified. We can take an early out here.
-        if (textUnderlinePosition() == TextUnderlinePositionUnder
-            || other.textUnderlinePosition() == TextUnderlinePositionUnder)
+        if (textUnderlinePosition() == TextUnderlinePosition::Under
+            || other.textUnderlinePosition() == TextUnderlinePosition::Under)
             return true;
         return visualOverflowForDecorations(*this, nullptr) != visualOverflowForDecorations(other, nullptr);
     }
index be9d0a1..b95d769 100644 (file)
@@ -69,6 +69,7 @@
 #include <memory>
 #include <wtf/Forward.h>
 #include <wtf/NeverDestroyed.h>
+#include <wtf/OptionSet.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/Vector.h>
 
@@ -365,11 +366,11 @@ public:
     const Length& textIndent() const { return m_rareInheritedData->indent; }
     TextAlignMode textAlign() const { return static_cast<TextAlignMode>(m_inheritedFlags.textAlign); }
     TextTransform textTransform() const { return static_cast<TextTransform>(m_inheritedFlags.textTransform); }
-    TextDecoration textDecorationsInEffect() const { return static_cast<TextDecoration>(m_inheritedFlags.textDecorations); }
-    TextDecoration textDecoration() const { return static_cast<TextDecoration>(m_visualData->textDecoration); }
+    OptionSet<TextDecoration> textDecorationsInEffect() const { return OptionSet<TextDecoration>::fromRaw(m_inheritedFlags.textDecorations); }
+    OptionSet<TextDecoration> textDecoration() const { return OptionSet<TextDecoration>::fromRaw(m_visualData->textDecoration); }
     TextDecorationStyle textDecorationStyle() const { return static_cast<TextDecorationStyle>(m_rareNonInheritedData->textDecorationStyle); }
-    TextDecorationSkip textDecorationSkip() const { return static_cast<TextDecorationSkip>(m_rareInheritedData->textDecorationSkip); }
-    TextUnderlinePosition textUnderlinePosition() const { return static_cast<TextUnderlinePosition>(m_rareInheritedData->textUnderlinePosition); }
+    OptionSet<TextDecorationSkip> textDecorationSkip() const { return OptionSet<TextDecorationSkip>::fromRaw(m_rareInheritedData->textDecorationSkip); }
+    OptionSet<TextUnderlinePosition> textUnderlinePosition() const { return OptionSet<TextUnderlinePosition>::fromRaw(m_rareInheritedData->textUnderlinePosition); }
 
 #if ENABLE(CSS3_TEXT)
     TextIndentLine textIndentLine() const { return static_cast<TextIndentLine>(m_rareInheritedData->textIndentLine); }
@@ -488,7 +489,7 @@ public:
     BreakBetween breakBefore() const { return static_cast<BreakBetween>(m_rareNonInheritedData->breakBefore); }
     BreakBetween breakAfter() const { return static_cast<BreakBetween>(m_rareNonInheritedData->breakAfter); }
 
-    HangingPunctuation hangingPunctuation() const { return static_cast<HangingPunctuation>(m_rareInheritedData->hangingPunctuation); }
+    OptionSet<HangingPunctuation> hangingPunctuation() const { return OptionSet<HangingPunctuation>::fromRaw(m_rareInheritedData->hangingPunctuation); }
 
     float outlineOffset() const;
     const ShadowData* textShadow() const { return m_rareInheritedData->textShadow.get(); }
@@ -620,7 +621,7 @@ public:
     TextEmphasisFill textEmphasisFill() const { return static_cast<TextEmphasisFill>(m_rareInheritedData->textEmphasisFill); }
     TextEmphasisMark textEmphasisMark() const;
     const AtomicString& textEmphasisCustomMark() const { return m_rareInheritedData->textEmphasisCustomMark; }
-    TextEmphasisPosition textEmphasisPosition() const { return static_cast<TextEmphasisPosition>(m_rareInheritedData->textEmphasisPosition); }
+    OptionSet<TextEmphasisPosition> textEmphasisPosition() const { return OptionSet<TextEmphasisPosition>::fromRaw(m_rareInheritedData->textEmphasisPosition); }
     const AtomicString& textEmphasisMarkString() const;
 
     RubyPosition rubyPosition() const { return static_cast<RubyPosition>(m_rareInheritedData->rubyPosition); }
@@ -746,7 +747,7 @@ public:
     float imageResolution() const { return m_rareInheritedData->imageResolution; }
 #endif
     
-    ESpeakAs speakAs() const { return static_cast<ESpeakAs>(m_rareInheritedData->speakAs); }
+    OptionSet<SpeakAs> speakAs() const { return OptionSet<SpeakAs>::fromRaw(m_rareInheritedData->speakAs); }
 
     FilterOperations& mutableFilter() { return m_rareNonInheritedData.access().filter.access().operations; }
     const FilterOperations& filter() const { return m_rareNonInheritedData->filter->operations; }
@@ -915,12 +916,12 @@ public:
     void setTextIndent(Length&& length) { SET_VAR(m_rareInheritedData, indent, WTFMove(length)); }
     void setTextAlign(TextAlignMode v) { m_inheritedFlags.textAlign = static_cast<unsigned>(v); }
     void setTextTransform(TextTransform v) { m_inheritedFlags.textTransform = static_cast<unsigned>(v); }
-    void addToTextDecorationsInEffect(TextDecoration v) { m_inheritedFlags.textDecorations |= v; }
-    void setTextDecorationsInEffect(TextDecoration v) { m_inheritedFlags.textDecorations = v; }
-    void setTextDecoration(TextDecoration v) { SET_VAR(m_visualData, textDecoration, v); }
+    void addToTextDecorationsInEffect(OptionSet<TextDecoration> v) { m_inheritedFlags.textDecorations |= static_cast<unsigned>(v.toRaw()); }
+    void setTextDecorationsInEffect(OptionSet<TextDecoration> v) { m_inheritedFlags.textDecorations = v.toRaw(); }
+    void setTextDecoration(OptionSet<TextDecoration> v) { SET_VAR(m_visualData, textDecoration, v.toRaw()); }
     void setTextDecorationStyle(TextDecorationStyle v) { SET_VAR(m_rareNonInheritedData, textDecorationStyle, static_cast<unsigned>(v)); }
-    void setTextDecorationSkip(TextDecorationSkip skip) { SET_VAR(m_rareInheritedData, textDecorationSkip, static_cast<unsigned>(skip)); }
-    void setTextUnderlinePosition(TextUnderlinePosition v) { SET_VAR(m_rareInheritedData, textUnderlinePosition, static_cast<unsigned>(v)); }
+    void setTextDecorationSkip(OptionSet<TextDecorationSkip> skip) { SET_VAR(m_rareInheritedData, textDecorationSkip, skip.toRaw()); }
+    void setTextUnderlinePosition(OptionSet<TextUnderlinePosition> v) { SET_VAR(m_rareInheritedData, textUnderlinePosition, v.toRaw()); }
     void setDirection(TextDirection v) { m_inheritedFlags.direction = static_cast<unsigned>(v); }
     void setHasExplicitlySetDirection(bool v) { m_nonInheritedFlags.hasExplicitlySetDirection = v; }
     void setLineHeight(Length&&);
@@ -1145,14 +1146,14 @@ public:
     void setTransformOriginZ(float f) { SET_NESTED_VAR(m_rareNonInheritedData, transform, z, f); }
     void setTransformBox(TransformBox box) { SET_NESTED_VAR(m_rareNonInheritedData, transform, transformBox, box); }
 
-    void setSpeakAs(ESpeakAs s) { SET_VAR(m_rareInheritedData, speakAs, s); }
+    void setSpeakAs(OptionSet<SpeakAs> s) { SET_VAR(m_rareInheritedData, speakAs, s.toRaw()); }
     void setTextCombine(TextCombine v) { SET_VAR(m_rareNonInheritedData, textCombine, static_cast<unsigned>(v)); }
     void setTextDecorationColor(const Color& c) { SET_VAR(m_rareNonInheritedData, textDecorationColor, c); }
     void setTextEmphasisColor(const Color& c) { SET_VAR(m_rareInheritedData, textEmphasisColor, c); }
     void setTextEmphasisFill(TextEmphasisFill fill) { SET_VAR(m_rareInheritedData, textEmphasisFill, static_cast<unsigned>(fill)); }
     void setTextEmphasisMark(TextEmphasisMark mark) { SET_VAR(m_rareInheritedData, textEmphasisMark, static_cast<unsigned>(mark)); }
     void setTextEmphasisCustomMark(const AtomicString& mark) { SET_VAR(m_rareInheritedData, textEmphasisCustomMark, mark); }
-    void setTextEmphasisPosition(TextEmphasisPosition position) { SET_VAR(m_rareInheritedData, textEmphasisPosition, position); }
+    void setTextEmphasisPosition(OptionSet<TextEmphasisPosition> position) { SET_VAR(m_rareInheritedData, textEmphasisPosition, static_cast<unsigned>(position.toRaw())); }
     bool setTextOrientation(TextOrientation);
 
     void setObjectFit(ObjectFit fit) { SET_VAR(m_rareNonInheritedData, objectFit, static_cast<unsigned>(fit)); }
@@ -1173,7 +1174,7 @@ public:
     void setBreakAfter(BreakBetween breakBehavior) { SET_VAR(m_rareNonInheritedData, breakAfter, static_cast<unsigned>(breakBehavior)); }
     void setBreakInside(BreakInside breakBehavior) { SET_VAR(m_rareNonInheritedData, breakInside, static_cast<unsigned>(breakBehavior)); }
     
-    void setHangingPunctuation(HangingPunctuation punctuation) { SET_VAR(m_rareInheritedData, hangingPunctuation, static_cast<unsigned>(punctuation)); }
+    void setHangingPunctuation(OptionSet<HangingPunctuation> punctuation) { SET_VAR(m_rareInheritedData, hangingPunctuation, punctuation.toRaw()); }
 
     // End CSS3 Setters
 
@@ -1434,7 +1435,7 @@ public:
     static Float initialFloating() { return Float::No; }
     static BreakBetween initialBreakBetween() { return BreakBetween::Auto; }
     static BreakInside initialBreakInside() { return BreakInside::Auto; }
-    static HangingPunctuation initialHangingPunctuation() { return NoHangingPunctuation; }
+    static OptionSet<HangingPunctuation> initialHangingPunctuation() { return OptionSet<HangingPunctuation> { }; }
     static TableLayoutType initialTableLayout() { return TableLayoutType::Auto; }
     static BorderCollapse initialBorderCollapse() { return BorderCollapse::Separate; }
     static BorderStyle initialBorderStyle() { return BorderStyle::None; }
@@ -1479,10 +1480,10 @@ public:
     static short initialOrphans() { return 2; }
     static Length initialLineHeight() { return Length(-100.0f, Percent); }
     static TextAlignMode initialTextAlign() { return TextAlignMode::Start; }
-    static TextDecoration initialTextDecoration() { return TextDecorationNone; }
+    static OptionSet<TextDecoration> initialTextDecoration() { return OptionSet<TextDecoration> { }; }
     static TextDecorationStyle initialTextDecorationStyle() { return TextDecorationStyle::Solid; }
-    static TextDecorationSkip initialTextDecorationSkip() { return TextDecorationSkipAuto; }
-    static TextUnderlinePosition initialTextUnderlinePosition() { return TextUnderlinePositionAuto; }
+    static OptionSet<TextDecorationSkip> initialTextDecorationSkip() { return TextDecorationSkip::Auto; }
+    static OptionSet<TextUnderlinePosition> initialTextUnderlinePosition() { return TextUnderlinePosition::Auto; }
     static float initialZoom() { return 1.0f; }
     static TextZoom initialTextZoom() { return TextZoom::Normal; }
     static float initialOutlineOffset() { return 0; }
@@ -1523,7 +1524,7 @@ public:
     static OverflowWrap initialOverflowWrap() { return OverflowWrap::Normal; }
     static NBSPMode initialNBSPMode() { return NBSPMode::Normal; }
     static LineBreak initialLineBreak() { return LineBreak::Auto; }
-    static ESpeakAs initialSpeakAs() { return SpeakNormal; }
+    static OptionSet<SpeakAs> initialSpeakAs() { return OptionSet<SpeakAs> { }; }
     static Hyphens initialHyphens() { return Hyphens::Manual; }
     static short initialHyphenationLimitBefore() { return -1; }
     static short initialHyphenationLimitAfter() { return -1; }
@@ -1558,7 +1559,7 @@ public:
     static TextEmphasisFill initialTextEmphasisFill() { return TextEmphasisFill::Filled; }
     static TextEmphasisMark initialTextEmphasisMark() { return TextEmphasisMark::None; }
     static const AtomicString& initialTextEmphasisCustomMark() { return nullAtom(); }
-    static TextEmphasisPosition initialTextEmphasisPosition() { return TextEmphasisPositionOver | TextEmphasisPositionRight; }
+    static OptionSet<TextEmphasisPosition> initialTextEmphasisPosition() { return { TextEmphasisPosition::Over, TextEmphasisPosition::Right }; }
     static RubyPosition initialRubyPosition() { return RubyPosition::Before; }
     static LineBoxContain initialLineBoxContain() { return LineBoxContainBlock | LineBoxContainInline | LineBoxContainReplaced; }
     static ImageOrientationEnum initialImageOrientation() { return OriginTopLeft; }
index a21c5c1..9f0c413 100644 (file)
@@ -687,18 +687,16 @@ static const size_t TextDecorationBits = 5;
 #else
 static const size_t TextDecorationBits = 4;
 #endif
-enum TextDecoration {
-    TextDecorationNone          = 0,
-    TextDecorationUnderline     = 1 << 0,
-    TextDecorationOverline      = 1 << 1,
-    TextDecorationLineThrough   = 1 << 2,
-    TextDecorationBlink         = 1 << 3,
+enum class TextDecoration {
+    None          = 0,
+    Underline     = 1 << 0,
+    Overline      = 1 << 1,
+    LineThrough   = 1 << 2,
+    Blink         = 1 << 3,
 #if ENABLE(LETTERPRESS)
-    TextDecorationLetterpress   = 1 << 4,
+    Letterpress   = 1 << 4,
 #endif
 };
-inline TextDecoration operator|(TextDecoration a, TextDecoration b) { return TextDecoration(int(a) | int(b)); }
-inline TextDecoration& operator|=(TextDecoration& a, TextDecoration b) { return a = a | b; }
 
 enum class TextDecorationStyle {
     Solid,
@@ -727,19 +725,19 @@ enum class TextJustify {
 };
 #endif // CSS3_TEXT
 
-enum TextDecorationSkipItems {
-    TextDecorationSkipNone      = 0,
-    TextDecorationSkipInk       = 1 << 0,
-    TextDecorationSkipObjects   = 1 << 1,
-    TextDecorationSkipAuto      = 1 << 2
+enum class TextDecorationSkip {
+    None      = 0,
+    Ink       = 1 << 0,
+    Objects   = 1 << 1,
+    Auto      = 1 << 2
 };
-typedef unsigned TextDecorationSkip;
 
-enum TextUnderlinePosition {
+// FIXME: There is no reason for the values in the enum to be powers of two.
+enum class TextUnderlinePosition {
     // FIXME: Implement support for 'under left' and 'under right' values.
-    TextUnderlinePositionAuto       = 1 << 0,
-    TextUnderlinePositionAlphabetic = 1 << 1,
-    TextUnderlinePositionUnder      = 1 << 2
+    Auto       = 1 << 0,
+    Alphabetic = 1 << 1,
+    Under      = 1 << 2
 };
 
 enum class TextZoom {
@@ -768,15 +766,13 @@ enum class BreakInside {
     AvoidPage
 };
 
-enum HangingPunctuation {
-    NoHangingPunctuation        = 0,
-    FirstHangingPunctuation     = 1 << 0,
-    LastHangingPunctuation      = 1 << 1,
-    AllowEndHangingPunctuation  = 1 << 2,
-    ForceEndHangingPunctuation  = 1 << 3
+enum class HangingPunctuation {
+    None      = 0,
+    First     = 1 << 0,
+    Last      = 1 << 1,
+    AllowEnd  = 1 << 2,
+    ForceEnd  = 1 << 3
 };
-inline HangingPunctuation operator|(HangingPunctuation a, HangingPunctuation b) { return HangingPunctuation(int(a) | int(b)); }
-inline HangingPunctuation& operator|=(HangingPunctuation& a, HangingPunctuation b) { return a = a | b; }
 
 enum class EmptyCell {
     Show,
@@ -929,15 +925,13 @@ enum class Hyphens {
     Auto
 };
 
-enum ESpeakAs {
-    SpeakNormal             = 0,
-    SpeakSpellOut           = 1 << 0,
-    SpeakDigits             = 1 << 1,
-    SpeakLiteralPunctuation = 1 << 2,
-    SpeakNoPunctuation      = 1 << 3
+enum class SpeakAs {
+    Normal             = 0,
+    SpellOut           = 1 << 0,
+    Digits             = 1 << 1,
+    LiteralPunctuation = 1 << 2,
+    NoPunctuation      = 1 << 3
 };
-inline ESpeakAs operator|(ESpeakAs a, ESpeakAs b) { return ESpeakAs(int(a) | int(b)); }
-inline ESpeakAs& operator|=(ESpeakAs& a, ESpeakAs b) { return a = a | b; }
 
 enum class TextEmphasisFill {
     Filled,
@@ -955,13 +949,12 @@ enum class TextEmphasisMark {
     Custom
 };
 
-enum TextEmphasisPositions {
-    TextEmphasisPositionOver  = 1 << 0,
-    TextEmphasisPositionUnder = 1 << 1,
-    TextEmphasisPositionLeft  = 1 << 2,
-    TextEmphasisPositionRight = 1 << 3
+enum class TextEmphasisPosition {
+    Over  = 1 << 0,
+    Under = 1 << 1,
+    Left  = 1 << 2,
+    Right = 1 << 3
 };
-typedef unsigned TextEmphasisPosition;
 
 enum class TextOrientation {
     Mixed,
index a5c0717..cbef75e 100644 (file)
@@ -87,11 +87,11 @@ StyleRareInheritedData::StyleRareInheritedData()
     , nbspMode(static_cast<unsigned>(NBSPMode::Normal))
     , lineBreak(static_cast<unsigned>(LineBreak::Auto))
     , userSelect(static_cast<unsigned>(RenderStyle::initialUserSelect()))
-    , speakAs(static_cast<unsigned>(SpeakNormal))
+    , speakAs(RenderStyle::initialSpeakAs().toRaw())
     , hyphens(static_cast<unsigned>(Hyphens::Manual))
     , textEmphasisFill(static_cast<unsigned>(TextEmphasisFill::Filled))
     , textEmphasisMark(static_cast<unsigned>(TextEmphasisMark::None))
-    , textEmphasisPosition(static_cast<unsigned>(TextEmphasisPositionOver | TextEmphasisPositionRight))
+    , textEmphasisPosition(static_cast<unsigned>(RenderStyle::initialTextEmphasisPosition().toRaw()))
     , textOrientation(static_cast<unsigned>(TextOrientation::Mixed))
 #if ENABLE(CSS3_TEXT)
     , textIndentLine(RenderStyle::initialTextIndentLine())
@@ -115,8 +115,8 @@ StyleRareInheritedData::StyleRareInheritedData()
     , textAlignLast(RenderStyle::initialTextAlignLast())
     , textJustify(RenderStyle::initialTextJustify())
 #endif
-    , textDecorationSkip(RenderStyle::initialTextDecorationSkip())
-    , textUnderlinePosition(RenderStyle::initialTextUnderlinePosition())
+    , textDecorationSkip(RenderStyle::initialTextDecorationSkip().toRaw())
+    , textUnderlinePosition(RenderStyle::initialTextUnderlinePosition().toRaw())
     , rubyPosition(static_cast<unsigned>(RenderStyle::initialRubyPosition()))
     , textZoom(static_cast<unsigned>(RenderStyle::initialTextZoom()))
 #if PLATFORM(IOS)
@@ -125,7 +125,7 @@ StyleRareInheritedData::StyleRareInheritedData()
 #if ENABLE(CSS_TRAILING_WORD)
     , trailingWord(static_cast<unsigned>(RenderStyle::initialTrailingWord()))
 #endif
-    , hangingPunctuation(RenderStyle::initialHangingPunctuation())
+    , hangingPunctuation(RenderStyle::initialHangingPunctuation().toRaw())
     , paintOrder(static_cast<unsigned>(RenderStyle::initialPaintOrder()))
     , capStyle(RenderStyle::initialCapStyle())
     , joinStyle(RenderStyle::initialJoinStyle())
index dd97ffd..10a447b 100644 (file)
@@ -28,7 +28,7 @@ namespace WebCore {
 
 StyleVisualData::StyleVisualData()
     : hasClip(false)
-    , textDecoration(RenderStyle::initialTextDecoration())
+    , textDecoration(RenderStyle::initialTextDecoration().toRaw())
     , zoom(RenderStyle::initialZoom())
 {
 }
index f147a58..3805c8a 100644 (file)
@@ -294,11 +294,11 @@ void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse
             paintInfo.context().concatCTM(fragmentTransform);
 
         // Spec: All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these decorations.
-        int decorations = style.textDecorationsInEffect();
-        if (decorations & TextDecorationUnderline)
-            paintDecoration(paintInfo.context(), TextDecorationUnderline, fragment);
-        if (decorations & TextDecorationOverline)
-            paintDecoration(paintInfo.context(), TextDecorationOverline, fragment);
+        auto decorations = style.textDecorationsInEffect();
+        if (decorations & TextDecoration::Underline)
+            paintDecoration(paintInfo.context(), TextDecoration::Underline, fragment);
+        if (decorations & TextDecoration::Overline)
+            paintDecoration(paintInfo.context(), TextDecoration::Overline, fragment);
 
         auto paintOrder = RenderStyle::paintTypesForPaintOrder(style.paintOrder());
         for (unsigned i = 0; i < paintOrder.size(); ++i) {
@@ -323,8 +323,8 @@ void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse
         }
 
         // Spec: Line-through should be drawn after the text is filled and stroked; thus, the line-through is rendered on top of the text.
-        if (decorations & TextDecorationLineThrough)
-            paintDecoration(paintInfo.context(), TextDecorationLineThrough, fragment);
+        if (decorations & TextDecoration::LineThrough)
+            paintDecoration(paintInfo.context(), TextDecoration::LineThrough, fragment);
 
         setPaintingResourceMode(RenderSVGResourceMode::ApplyToDefault);
     }
@@ -432,22 +432,22 @@ bool SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates(const SVGText
     return true;
 }
 
-static inline float positionOffsetForDecoration(TextDecoration decoration, const FontMetrics& fontMetrics, float thickness)
+static inline float positionOffsetForDecoration(OptionSet<TextDecoration> decoration, const FontMetrics& fontMetrics, float thickness)
 {
     // FIXME: For SVG Fonts we need to use the attributes defined in the <font-face> if specified.
     // Compatible with Batik/Opera.
-    if (decoration == TextDecorationUnderline)
+    if (decoration == TextDecoration::Underline)
         return fontMetrics.floatAscent() + thickness * 1.5f;
-    if (decoration == TextDecorationOverline)
+    if (decoration == TextDecoration::Overline)
         return thickness;
-    if (decoration == TextDecorationLineThrough)
+    if (decoration == TextDecoration::LineThrough)
         return fontMetrics.floatAscent() * 5 / 8.0f;
 
     ASSERT_NOT_REACHED();
     return 0.0f;
 }
 
-static inline float thicknessForDecoration(TextDecoration, const FontCascade& font)
+static inline float thicknessForDecoration(OptionSet<TextDecoration>, const FontCascade& font)
 {
     // FIXME: For SVG Fonts we need to use the attributes defined in the <font-face> if specified.
     // Compatible with Batik/Opera
@@ -461,7 +461,7 @@ static inline RenderBoxModelObject& findRendererDefininingTextDecoration(InlineF
     while (parentBox) {
         renderer = &parentBox->renderer();
 
-        if (renderer->style().textDecoration() != TextDecorationNone)
+        if (!renderer->style().textDecoration().isEmpty())
             break;
 
         parentBox = parentBox->parent();
@@ -471,9 +471,9 @@ static inline RenderBoxModelObject& findRendererDefininingTextDecoration(InlineF
     return *renderer;
 }
 
-void SVGInlineTextBox::paintDecoration(GraphicsContext& context, TextDecoration decoration, const SVGTextFragment& fragment)
+void SVGInlineTextBox::paintDecoration(GraphicsContext& context, OptionSet<TextDecoration> decoration, const SVGTextFragment& fragment)
 {
-    if (renderer().style().textDecorationsInEffect() == TextDecorationNone)
+    if (renderer().style().textDecorationsInEffect().isEmpty())
         return;
 
     // Find out which render style defined the text-decoration, as its fill/stroke properties have to be used for drawing instead of ours.
@@ -499,7 +499,7 @@ void SVGInlineTextBox::paintDecoration(GraphicsContext& context, TextDecoration
     }
 }
 
-void SVGInlineTextBox::paintDecorationWithStyle(GraphicsContext& context, TextDecoration decoration, const SVGTextFragment& fragment, RenderBoxModelObject& decorationRenderer)
+void SVGInlineTextBox::paintDecorationWithStyle(GraphicsContext& context, OptionSet<TextDecoration> decoration, const SVGTextFragment& fragment, RenderBoxModelObject& decorationRenderer)
 {
     ASSERT(!m_paintingResource);
     ASSERT(paintingResourceMode() != RenderSVGResourceMode::ApplyToDefault);
index 7c5036f..fde1f38 100644 (file)
@@ -81,8 +81,8 @@ private:
     bool prepareGraphicsContextForTextPainting(GraphicsContext*&, float scalingFactor, const RenderStyle&);
     void restoreGraphicsContextAfterTextPainting(GraphicsContext*&);
 
-    void paintDecoration(GraphicsContext&, TextDecoration, const SVGTextFragment&);
-    void paintDecorationWithStyle(GraphicsContext&, TextDecoration, const SVGTextFragment&, RenderBoxModelObject& decorationRenderer);
+    void paintDecoration(GraphicsContext&, OptionSet<TextDecoration>, const SVGTextFragment&);
+    void paintDecorationWithStyle(GraphicsContext&, OptionSet<TextDecoration>, const SVGTextFragment&, RenderBoxModelObject& decorationRenderer);
     void paintTextWithShadows(GraphicsContext&, const RenderStyle&, TextRun&, const SVGTextFragment&, unsigned startPosition, unsigned endPosition);
     void paintText(GraphicsContext&, const RenderStyle&, const RenderStyle& selectionStyle, const SVGTextFragment&, bool hasSelection, bool paintSelectedTextOnly);
 
index 09902af..136f31a 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
     
-int computeUnderlineOffset(TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, int textDecorationThickness)
+int computeUnderlineOffset(OptionSet<TextUnderlinePosition> underlinePosition, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, int textDecorationThickness)
 {
     // This represents the gap between the baseline and the closest edge of the underline.
     int gap = std::max<int>(1, ceilf(textDecorationThickness / 2.0));
@@ -40,43 +40,43 @@ int computeUnderlineOffset(TextUnderlinePosition underlinePosition, const FontMe
     // FIXME: The code for visual overflow detection passes in a null inline text box. This means it is now
     // broken for the case where auto needs to behave like "under".
     
-    // According to the specification TextUnderlinePositionAuto should avoid drawing through glyphs in
+    // According to the specification TextUnderlinePosition::Auto should avoid drawing through glyphs in
     // scripts where it would not be appropriate (e.g., ideographs).
     // Strictly speaking this can occur whenever the line contains ideographs
     // even if it is horizontal, but detecting this has performance implications. For now we only work with
     // vertical text, since we already determined the baseline type to be ideographic in that
     // case.
     
-    TextUnderlinePosition resolvedUnderlinePosition = underlinePosition;
-    if (resolvedUnderlinePosition == TextUnderlinePositionAuto) {
+    auto resolvedUnderlinePosition = underlinePosition;
+    if (resolvedUnderlinePosition == TextUnderlinePosition::Auto) {
         if (inlineTextBox)
-            resolvedUnderlinePosition = inlineTextBox->root().baselineType() == IdeographicBaseline ? TextUnderlinePositionUnder : TextUnderlinePositionAlphabetic;
+            resolvedUnderlinePosition = inlineTextBox->root().baselineType() == IdeographicBaseline ? TextUnderlinePosition::Under : TextUnderlinePosition::Alphabetic;
         else
-            resolvedUnderlinePosition = TextUnderlinePositionAlphabetic;
+            resolvedUnderlinePosition = TextUnderlinePosition::Alphabetic;
     }
     
-    switch (resolvedUnderlinePosition) {
-    case TextUnderlinePositionAlphabetic:
+    switch (static_cast<TextUnderlinePosition>(resolvedUnderlinePosition.toRaw())) {
+    case TextUnderlinePosition::Alphabetic:
         return fontMetrics.ascent() + gap;
-    case TextUnderlinePositionUnder: {
+    case TextUnderlinePosition::Under: {
         ASSERT(inlineTextBox);
         // Position underline relative to the bottom edge of the lowest element's content box.
         const RootInlineBox& rootBox = inlineTextBox->root();
-        const RenderElement* decorationRenderer = inlineTextBox->parent()->renderer().enclosingRendererWithTextDecoration(TextDecorationUnderline, inlineTextBox->isFirstLine());
+        const RenderElement* decorationRenderer = inlineTextBox->parent()->renderer().enclosingRendererWithTextDecoration(TextDecoration::Underline, inlineTextBox->isFirstLine());
         
         float offset;
         if (inlineTextBox->renderer().style().isFlippedLinesWritingMode()) {
             offset = inlineTextBox->logicalTop();
-            rootBox.minLogicalTopForTextDecorationLine(offset, decorationRenderer, TextDecorationUnderline);
+            rootBox.minLogicalTopForTextDecorationLine(offset, decorationRenderer, TextDecoration::Underline);
             offset = inlineTextBox->logicalTop() - offset;
         } else {
             offset = inlineTextBox->logicalBottom();
-            rootBox.maxLogicalBottomForTextDecorationLine(offset, decorationRenderer, TextDecorationUnderline);
+            rootBox.maxLogicalBottomForTextDecorationLine(offset, decorationRenderer, TextDecoration::Underline);
             offset -= inlineTextBox->logicalBottom();
         }
         return inlineTextBox->logicalHeight() + gap + std::max<float>(offset, 0);
     }
-    case TextUnderlinePositionAuto:
+    case TextUnderlinePosition::Auto:
         ASSERT_NOT_REACHED();
     }
 
@@ -106,10 +106,10 @@ GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const I
 {
     ASSERT(!inlineTextBox || inlineTextBox->lineStyle() == lineStyle);
     
-    TextDecoration decoration = lineStyle.textDecorationsInEffect();
-    if (decoration == TextDecorationNone)
+    auto decoration = lineStyle.textDecorationsInEffect();
+    if (decoration.isEmpty())
         return GlyphOverflow();
-    
+
     float strokeThickness = textDecorationStrokeThickness(lineStyle.computedFontPixelSize());
     float controlPointDistance = 0;
     float step;
@@ -127,7 +127,7 @@ GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const I
     }
 
     // These metrics must match where underlines get drawn.
-    if (decoration & TextDecorationUnderline) {
+    if (decoration & TextDecoration::Underline) {
         // Compensate for the integral ceiling in GraphicsContext::computeLineBoundsAndAntialiasingModeForText()
         int underlineOffset = 1;
         underlineOffset += computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), inlineTextBox, strokeThickness);
@@ -139,7 +139,7 @@ GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const I
             extendIntToFloat(overflowResult.top, -underlineOffset);
         }
     }
-    if (decoration & TextDecorationOverline) {
+    if (decoration & TextDecoration::Overline) {
         if (decorationStyle == TextDecorationStyle::Wavy) {
             extendIntToFloat(overflowResult.bottom, -wavyOffset + controlPointDistance + strokeThickness - height);
             extendIntToFloat(overflowResult.top, wavyOffset + controlPointDistance + strokeThickness);
@@ -148,7 +148,7 @@ GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const I
             // top is untouched
         }
     }
-    if (decoration & TextDecorationLineThrough) {
+    if (decoration & TextDecoration::LineThrough) {
         float baseline = lineStyle.fontMetrics().floatAscent();
         if (decorationStyle == TextDecorationStyle::Wavy) {
             extendIntToFloat(overflowResult.bottom, 2 * baseline / 3 + controlPointDistance + strokeThickness - height);
index a8525a4..cc5312a 100644 (file)
@@ -46,6 +46,6 @@ inline float wavyOffsetFromDecoration()
 
 GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const InlineTextBox*);
 void getWavyStrokeParameters(float fontSize, float& controlPointDistance, float& step);
-int computeUnderlineOffset(TextUnderlinePosition, const FontMetrics&, const InlineTextBox*, int textDecorationThickness);
+int computeUnderlineOffset(OptionSet<TextUnderlinePosition>, const FontMetrics&, const InlineTextBox*, int textDecorationThickness);
     
 } // namespace WebCore
index e01b453..444ffa1 100644 (file)
@@ -1,3 +1,14 @@
+2018-05-27  Sam Weinig  <sam@webkit.org>
+
+        Modernize RenderStyleConstants.h - Part 3
+        https://bugs.webkit.org/show_bug.cgi?id=186015
+
+        Reviewed by Yusuke Suzuki.
+
+        * WebView/WebView.mm:
+        (-[WebView updateTextTouchBar]):
+        Update for new enum name.
+
 2018-05-25  Chris Dumez  <cdumez@apple.com>
 
         Minor ApplicationCacheStorage clean up
index d5e39ac..b4020d9 100644 (file)
@@ -9920,7 +9920,7 @@ static NSTextAlignment nsTextAlignmentFromRenderStyle(const RenderStyle* style)
                     String value = typingStyle->style()->getPropertyValue(CSSPropertyWebkitTextDecorationsInEffect);
                     [_private->_textTouchBarItemController setTextIsUnderlined:value.contains("underline")];
                 } else
-                    [_private->_textTouchBarItemController setTextIsUnderlined:(style->textDecorationsInEffect() & TextDecorationUnderline)];
+                    [_private->_textTouchBarItemController setTextIsUnderlined:style->textDecorationsInEffect().contains(TextDecoration::Underline)];
 
                 Color textColor = style->visitedDependentColor(CSSPropertyColor);
                 if (textColor.isValid())