Ignore:
Timestamp:
Mar 16, 2021, 7:12:13 PM (4 years ago)
Author:
[email protected]
Message:

Add CSSValuePair.h in preparation for Pair.h refactor
https://bugs.webkit.org/show_bug.cgi?id=223205

Patch by Tyler Wilcock <Tyler Wilcock> on 2021-03-16
Reviewed by Simon Fraser.

Add new CSSValuePair class, which is intended to replace Pair.h.
Pair.h has some problems, namely:

  1. It's not a sub-class of CSSValue, making it awkward to use.
  2. It can only contain CSSPrimitiveValues.

CSSValuePair will fix both of these shortcomings.

  • Sources.txt:

Add CSSValuePair.cpp.

  • css/CSSValue.cpp:

(WebCore::CSSValue::cssText const):
Handle new ValuePairClass value.
(WebCore::CSSValue::separatorCssText const):
Added.
(WebCore::CSSValue::destroy):
Handle new ValuePairClass value.

  • css/CSSValue.h:

(WebCore::CSSValue::isValuePair const):
Added.
(WebCore::CSSValue::CSSValue):
Add new ValuePairClass value. Rename m_valueListSeparator to m_valueSeparator,
ValueListSeparator to ValueSeparator, and
ValueListSeparatorBits to ValueSeparatorBits.

  • css/CSSValueList.cpp:

(WebCore::CSSValueList::CSSValueList):
(WebCore::CSSValueList::copy):
(WebCore::CSSValueList::customCSSText const):
Refactor to use new separatorCssText() function.
(WebCore::CSSValueList::equals const):
Rename m_valueListSeparator to m_valueSeparator,
ValueListSeparator to ValueSeparator, and
ValueListSeparatorBits to ValueSeparatorBits.

  • css/CSSValueList.h:

(WebCore::CSSValueList::separator const):
Rename m_valueListSeparator to m_valueSeparator.

  • css/CSSValuePair.cpp:

(WebCore::CSSValuePair::customCSSText const):
(WebCore::CSSValuePair::equals const):
Added.

  • css/CSSValuePair.h:

(WebCore::CSSValuePair::create):
(WebCore::CSSValuePair::first const):
(WebCore::CSSValuePair::second const):
(WebCore::CSSValuePair::CSSValuePair):
Added.

  • css/DeprecatedCSSOMValue.h:
  • css/DeprecatedCSSOMValueList.cpp:

(WebCore::DeprecatedCSSOMValueList::cssText const):

  • css/DeprecatedCSSOMValueList.h:

(WebCore::DeprecatedCSSOMValueList::DeprecatedCSSOMValueList):
Rename m_valueListSeparator to m_valueSeparator,
ValueListSeparator to ValueSeparator, and
ValueListSeparatorBits to ValueSeparatorBits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSValue.cpp

    r266686 r274546  
    6363#include "CSSUnsetValue.h"
    6464#include "CSSValueList.h"
     65#include "CSSValuePair.h"
    6566#include "CSSVariableReferenceValue.h"
    6667
     
    313314    case ValueListClass:
    314315        return downcast<CSSValueList>(*this).customCSSText();
     316    case ValuePairClass:
     317        return downcast<CSSValuePair>(*this).customCSSText();
    315318    case LineBoxContainClass:
    316319        return downcast<CSSLineBoxContainValue>(*this).customCSSText();
     
    339342}
    340343
     344String CSSValue::separatorCssText() const
     345{
     346    switch (m_valueSeparator) {
     347    case SpaceSeparator:
     348        return " "_s;
     349    case CommaSeparator:
     350        return ", "_s;
     351    case SlashSeparator:
     352        return " / "_s;
     353    default:
     354        ASSERT_NOT_REACHED();
     355    }
     356    return " "_s;
     357}
     358
    341359void CSSValue::destroy()
    342360{
     
    434452    case ValueListClass:
    435453        delete downcast<CSSValueList>(this);
     454        return;
     455    case ValuePairClass:
     456        delete downcast<CSSValuePair>(this);
    436457        return;
    437458    case LineBoxContainClass:
Note: See TracChangeset for help on using the changeset viewer.