Changeset 266980 in webkit


Ignore:
Timestamp:
Sep 12, 2020 3:02:54 PM (4 years ago)
Author:
Simon Fraser
Message:

Convert TextStream::FormattingFlags to an OptionSet<>
https://bugs.webkit.org/show_bug.cgi?id=216443

Reviewed by Darin Adler.
Source/WebCore:

Use an OptionSet<> for FormattingFlags.

  • rendering/RenderTreeAsText.cpp:

(WebCore::externalRepresentation):
(WebCore::counterValueForElement):

Source/WTF:

Use an OptionSet<> for FormattingFlags.

  • wtf/text/TextStream.h:

(WTF::TextStream::TextStream):
(WTF::TextStream::formattingFlags const):
(WTF::TextStream::setFormattingFlags):
(WTF::TextStream::hasFormattingFlag const):

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r266973 r266980  
     12020-09-12  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Convert TextStream::FormattingFlags to an OptionSet<>
     4        https://bugs.webkit.org/show_bug.cgi?id=216443
     5
     6        Reviewed by Darin Adler.
     7
     8        Use an OptionSet<> for FormattingFlags.
     9
     10        * wtf/text/TextStream.h:
     11        (WTF::TextStream::TextStream):
     12        (WTF::TextStream::formattingFlags const):
     13        (WTF::TextStream::setFormattingFlags):
     14        (WTF::TextStream::hasFormattingFlag const):
     15
    1162020-09-11  Yusuke Suzuki  <ysuzuki@apple.com>
    217
  • trunk/Source/WTF/wtf/text/TextStream.h

    r259165 r266980  
    2828#include <wtf/Forward.h>
    2929#include <wtf/Markable.h>
     30#include <wtf/OptionSet.h>
    3031#include <wtf/Optional.h>
    3132#include <wtf/WeakPtr.h>
     
    4546    };
    4647   
    47     enum Formatting {
     48    enum class Formatting : uint8_t {
    4849        SVGStyleRect                = 1 << 0, // "at (0,0) size 10x10"
    4950        NumberRespectingIntegers    = 1 << 1,
    5051        LayoutUnitsAsIntegers       = 1 << 2,
    5152    };
    52    
    53     using FormattingFlags = unsigned;
    54    
     53
    5554    enum class LineMode { SingleLine, MultipleLine };
    56     TextStream(LineMode lineMode = LineMode::MultipleLine, FormattingFlags formattingFlags = 0)
     55    TextStream(LineMode lineMode = LineMode::MultipleLine, OptionSet<Formatting> formattingFlags = { })
    5756        : m_formattingFlags(formattingFlags)
    5857        , m_multiLineMode(lineMode == LineMode::MultipleLine)
     
    8180#endif
    8281
    83     FormattingFlags formattingFlags() const { return m_formattingFlags; }
    84     void setFormattingFlags(FormattingFlags flags) { m_formattingFlags = flags; }
    85 
    86     bool hasFormattingFlag(Formatting flag) const { return m_formattingFlags & flag; }
     82    OptionSet<Formatting> formattingFlags() const { return m_formattingFlags; }
     83    void setFormattingFlags(OptionSet<Formatting> flags) { m_formattingFlags = flags; }
     84
     85    bool hasFormattingFlag(Formatting flag) const { return m_formattingFlags.contains(flag); }
    8786
    8887    template<typename T>
     
    167166private:
    168167    StringBuilder m_text;
    169     FormattingFlags m_formattingFlags { 0 };
    170168    int m_indent { 0 };
     169    OptionSet<Formatting> m_formattingFlags;
    171170    bool m_multiLineMode { true };
    172171};
  • trunk/Source/WebCore/ChangeLog

    r266979 r266980  
     12020-09-12  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Convert TextStream::FormattingFlags to an OptionSet<>
     4        https://bugs.webkit.org/show_bug.cgi?id=216443
     5
     6        Reviewed by Darin Adler.
     7       
     8        Use an OptionSet<> for FormattingFlags.
     9
     10        * rendering/RenderTreeAsText.cpp:
     11        (WebCore::externalRepresentation):
     12        (WebCore::counterValueForElement):
     13
    1142020-09-12  Zalan Bujtas  <zalan@apple.com>
    215
  • trunk/Source/WebCore/rendering/RenderTreeAsText.cpp

    r266691 r266980  
    806806static String externalRepresentation(RenderBox& renderer, OptionSet<RenderAsTextFlag> behavior)
    807807{
    808     TextStream ts(TextStream::LineMode::MultipleLine, TextStream::Formatting::SVGStyleRect | TextStream::Formatting::LayoutUnitsAsIntegers);
     808    TextStream ts(TextStream::LineMode::MultipleLine, { TextStream::Formatting::SVGStyleRect, TextStream::Formatting::LayoutUnitsAsIntegers });
    809809    if (!renderer.hasLayer())
    810810        return ts.release();
     
    882882    RefPtr<Element> elementRef(element);
    883883    element->document().updateLayout();
    884     TextStream stream(TextStream::LineMode::MultipleLine, TextStream::Formatting::SVGStyleRect | TextStream::Formatting::LayoutUnitsAsIntegers);
     884    TextStream stream(TextStream::LineMode::MultipleLine, { TextStream::Formatting::SVGStyleRect, TextStream::Formatting::LayoutUnitsAsIntegers });
    885885    bool isFirstCounter = true;
    886886    // The counter renderers should be children of :before or :after pseudo-elements.
Note: See TracChangeset for help on using the changeset viewer.