Changeset 234811 in webkit


Ignore:
Timestamp:
Aug 13, 2018 12:16:10 PM (6 years ago)
Author:
Antti Koivisto
Message:

Meaning of OptionSet::contains is unclear when used with OptionSet argument
https://bugs.webkit.org/show_bug.cgi?id=188501

Reviewed by Anders Carlsson.

Source/WebCore:

  • dom/DocumentMarkerController.cpp:

(WebCore::DocumentMarkerController::possiblyHasMarkers):

  • dom/DocumentMarkerController.h:

(WebCore::DocumentMarkerController::hasMarkers const):

  • platform/FileSystem.h:

(WebCore::FileSystem::openAndLockFile):

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::selectionColor const):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::paintForegroundForFragments):

Source/WTF:

The existing behavior is "contains any" but it is not very clear from the name.

  • wtf/OptionSet.h:

(WTF::OptionSet::contains const):

This is now for testing a single option only.

(WTF::OptionSet::containsAny const):
(WTF::OptionSet::containsAll const):

Add separate functions for OptionSet argument.

Tools:

  • TestWebKitAPI/Tests/WTF/OptionSet.cpp:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r234810 r234811  
     12018-08-13  Antti Koivisto  <antti@apple.com>
     2
     3        Meaning of OptionSet::contains is unclear when used with OptionSet argument
     4        https://bugs.webkit.org/show_bug.cgi?id=188501
     5
     6        Reviewed by Anders Carlsson.
     7
     8        The existing behavior is "contains any" but it is not very clear from the name.
     9
     10        * wtf/OptionSet.h:
     11        (WTF::OptionSet::contains const):
     12
     13        This is now for testing a single option only.
     14
     15        (WTF::OptionSet::containsAny const):
     16        (WTF::OptionSet::containsAll const):
     17
     18        Add separate functions for OptionSet argument.
     19
    1202018-08-13  Commit Queue  <commit-queue@webkit.org>
    221
  • trunk/Source/WTF/wtf/OptionSet.h

    r234768 r234811  
    9797    constexpr explicit operator bool() { return !isEmpty(); }
    9898
    99     constexpr bool contains(OptionSet optionSet) const
     99    constexpr bool contains(T option) const
    100100    {
    101         return m_storage & optionSet.m_storage;
     101        return containsAny({ option });
     102    }
     103
     104    constexpr bool containsAny(OptionSet optionSet) const
     105    {
     106        return !!(*this & optionSet);
     107    }
     108
     109    constexpr bool containsAll(OptionSet optionSet) const
     110    {
     111        return (*this & optionSet) == optionSet;
    102112    }
    103113
  • trunk/Source/WebCore/ChangeLog

    r234810 r234811  
     12018-08-13  Antti Koivisto  <antti@apple.com>
     2
     3        Meaning of OptionSet::contains is unclear when used with OptionSet argument
     4        https://bugs.webkit.org/show_bug.cgi?id=188501
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * dom/DocumentMarkerController.cpp:
     9        (WebCore::DocumentMarkerController::possiblyHasMarkers):
     10        * dom/DocumentMarkerController.h:
     11        (WebCore::DocumentMarkerController::hasMarkers const):
     12        * platform/FileSystem.h:
     13        (WebCore::FileSystem::openAndLockFile):
     14        * rendering/RenderElement.cpp:
     15        (WebCore::RenderElement::selectionColor const):
     16        * rendering/RenderLayer.cpp:
     17        (WebCore::RenderLayer::paintForegroundForFragments):
     18
    1192018-08-13  Commit Queue  <commit-queue@webkit.org>
    220
  • trunk/Source/WebCore/dom/DocumentMarkerController.cpp

    r230211 r234811  
    4545inline bool DocumentMarkerController::possiblyHasMarkers(OptionSet<DocumentMarker::MarkerType> types)
    4646{
    47     return m_possiblyExistingMarkerTypes.contains(types);
     47    return m_possiblyExistingMarkerTypes.containsAny(types);
    4848}
    4949
  • trunk/Source/WebCore/dom/DocumentMarkerController.h

    r219597 r234811  
    6464    bool hasMarkers() const
    6565    {
    66         ASSERT(m_markers.isEmpty() == !m_possiblyExistingMarkerTypes.contains(DocumentMarker::allMarkers()));
     66        ASSERT(m_markers.isEmpty() == !m_possiblyExistingMarkerTypes.containsAny(DocumentMarker::allMarkers()));
    6767        return !m_markers.isEmpty();
    6868    }
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r234619 r234811  
    13621362    // don't override the foreground color with the selection foreground color.
    13631363    if (style().userSelect() == UserSelect::None
    1364         || (view().frameView().paintBehavior().contains(OptionSet<PaintBehavior>(PaintBehavior::SelectionOnly) | PaintBehavior::SelectionAndBackgroundsOnly)))
     1364        || (view().frameView().paintBehavior().containsAny({ PaintBehavior::SelectionOnly, PaintBehavior::SelectionAndBackgroundsOnly })))
    13651365        return Color();
    13661366
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r234782 r234811  
    47894789    // We have to loop through every fragment multiple times, since we have to repaint in each specific phase in order for
    47904790    // interleaving of the fragments to work properly.
    4791     bool selectionOnly = localPaintingInfo.paintBehavior.contains(OptionSet<PaintBehavior>(PaintBehavior::SelectionAndBackgroundsOnly) | PaintBehavior::SelectionOnly);
     4791    bool selectionOnly = localPaintingInfo.paintBehavior.containsAny({ PaintBehavior::SelectionAndBackgroundsOnly, PaintBehavior::SelectionOnly });
    47924792    paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhase::Selection : PaintPhase::ChildBlockBackgrounds, layerFragments,
    47934793        context, localPaintingInfo, localPaintBehavior, subtreePaintRootForRenderer);
  • trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp

    r234619 r234811  
    18481848
    18491849    if (FrameView* frameView = frame()->view()) {
    1850         if (frameView->paintBehavior().contains(OptionSet<PaintBehavior>(PaintBehavior::SelectionOnly) | PaintBehavior::SelectionAndBackgroundsOnly | PaintBehavior::ForceBlackText)) {
     1850        if (frameView->paintBehavior().containsAny({ PaintBehavior::SelectionOnly, PaintBehavior::SelectionAndBackgroundsOnly, PaintBehavior::ForceBlackText})) {
    18511851            // This paint behavior is used when drawing the find indicator and there's no need to
    18521852            // snapshot plug-ins, because they can never be painted as part of the find indicator.
  • trunk/Tools/ChangeLog

    r234810 r234811  
     12018-08-13  Antti Koivisto  <antti@apple.com>
     2
     3        Meaning of OptionSet::contains is unclear when used with OptionSet argument
     4        https://bugs.webkit.org/show_bug.cgi?id=188501
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * TestWebKitAPI/Tests/WTF/OptionSet.cpp:
     9        (TestWebKitAPI::TEST):
     10
    1112018-08-13  Commit Queue  <commit-queue@webkit.org>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp

    r231548 r234811  
    380380}
    381381
     382TEST(WTF_OptionSet, ContainsAny)
     383{
     384    OptionSet<ExampleFlags> set { ExampleFlags::A, ExampleFlags::B };
     385
     386    EXPECT_TRUE(set.containsAny({ ExampleFlags::A }));
     387    EXPECT_TRUE(set.containsAny({ ExampleFlags::B }));
     388    EXPECT_FALSE(set.containsAny({ ExampleFlags::C }));
     389    EXPECT_FALSE(set.containsAny({ ExampleFlags::C, ExampleFlags::D }));
     390    EXPECT_TRUE(set.containsAny({ ExampleFlags::A, ExampleFlags::B }));
     391    EXPECT_TRUE(set.containsAny({ ExampleFlags::B, ExampleFlags::C }));
     392    EXPECT_TRUE(set.containsAny({ ExampleFlags::A, ExampleFlags::C }));
     393    EXPECT_TRUE(set.containsAny({ ExampleFlags::A, ExampleFlags::B, ExampleFlags::C }));
     394}
     395
     396TEST(WTF_OptionSet, ContainsAll)
     397{
     398    OptionSet<ExampleFlags> set { ExampleFlags::A, ExampleFlags::B };
     399
     400    EXPECT_TRUE(set.containsAll({ ExampleFlags::A }));
     401    EXPECT_TRUE(set.containsAll({ ExampleFlags::B }));
     402    EXPECT_FALSE(set.containsAll({ ExampleFlags::C }));
     403    EXPECT_FALSE(set.containsAll({ ExampleFlags::C, ExampleFlags::D }));
     404    EXPECT_TRUE(set.containsAll({ ExampleFlags::A, ExampleFlags::B }));
     405    EXPECT_FALSE(set.containsAll({ ExampleFlags::B, ExampleFlags::C }));
     406    EXPECT_FALSE(set.containsAll({ ExampleFlags::A, ExampleFlags::C }));
     407    EXPECT_FALSE(set.containsAll({ ExampleFlags::A, ExampleFlags::B, ExampleFlags::C }));
     408}
     409
    382410} // namespace TestWebKitAPI
Note: See TracChangeset for help on using the changeset viewer.