Diff
Modified: trunk/Source/WTF/ChangeLog (234810 => 234811)
--- trunk/Source/WTF/ChangeLog 2018-08-13 18:42:55 UTC (rev 234810)
+++ trunk/Source/WTF/ChangeLog 2018-08-13 19:16:10 UTC (rev 234811)
@@ -1,3 +1,22 @@
+2018-08-13 Antti Koivisto <[email protected]>
+
+ Meaning of OptionSet::contains is unclear when used with OptionSet argument
+ https://bugs.webkit.org/show_bug.cgi?id=188501
+
+ Reviewed by Anders Carlsson.
+
+ 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.
+
2018-08-13 Commit Queue <[email protected]>
Unreviewed, rolling out r234747.
Modified: trunk/Source/WTF/wtf/OptionSet.h (234810 => 234811)
--- trunk/Source/WTF/wtf/OptionSet.h 2018-08-13 18:42:55 UTC (rev 234810)
+++ trunk/Source/WTF/wtf/OptionSet.h 2018-08-13 19:16:10 UTC (rev 234811)
@@ -96,11 +96,21 @@
constexpr explicit operator bool() { return !isEmpty(); }
- constexpr bool contains(OptionSet optionSet) const
+ constexpr bool contains(T option) const
{
- return m_storage & optionSet.m_storage;
+ return containsAny({ option });
}
+ constexpr bool containsAny(OptionSet optionSet) const
+ {
+ return !!(*this & optionSet);
+ }
+
+ constexpr bool containsAll(OptionSet optionSet) const
+ {
+ return (*this & optionSet) == optionSet;
+ }
+
constexpr friend bool operator==(OptionSet lhs, OptionSet rhs)
{
return lhs.m_storage == rhs.m_storage;
Modified: trunk/Source/WebCore/ChangeLog (234810 => 234811)
--- trunk/Source/WebCore/ChangeLog 2018-08-13 18:42:55 UTC (rev 234810)
+++ trunk/Source/WebCore/ChangeLog 2018-08-13 19:16:10 UTC (rev 234811)
@@ -1,3 +1,21 @@
+2018-08-13 Antti Koivisto <[email protected]>
+
+ Meaning of OptionSet::contains is unclear when used with OptionSet argument
+ https://bugs.webkit.org/show_bug.cgi?id=188501
+
+ Reviewed by Anders Carlsson.
+
+ * 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):
+
2018-08-13 Commit Queue <[email protected]>
Unreviewed, rolling out r234747.
Modified: trunk/Source/WebCore/dom/DocumentMarkerController.cpp (234810 => 234811)
--- trunk/Source/WebCore/dom/DocumentMarkerController.cpp 2018-08-13 18:42:55 UTC (rev 234810)
+++ trunk/Source/WebCore/dom/DocumentMarkerController.cpp 2018-08-13 19:16:10 UTC (rev 234811)
@@ -44,7 +44,7 @@
inline bool DocumentMarkerController::possiblyHasMarkers(OptionSet<DocumentMarker::MarkerType> types)
{
- return m_possiblyExistingMarkerTypes.contains(types);
+ return m_possiblyExistingMarkerTypes.containsAny(types);
}
DocumentMarkerController::DocumentMarkerController(Document& document)
Modified: trunk/Source/WebCore/dom/DocumentMarkerController.h (234810 => 234811)
--- trunk/Source/WebCore/dom/DocumentMarkerController.h 2018-08-13 18:42:55 UTC (rev 234810)
+++ trunk/Source/WebCore/dom/DocumentMarkerController.h 2018-08-13 19:16:10 UTC (rev 234811)
@@ -63,7 +63,7 @@
void copyMarkers(Node* srcNode, unsigned startOffset, int length, Node* dstNode, int delta);
bool hasMarkers() const
{
- ASSERT(m_markers.isEmpty() == !m_possiblyExistingMarkerTypes.contains(DocumentMarker::allMarkers()));
+ ASSERT(m_markers.isEmpty() == !m_possiblyExistingMarkerTypes.containsAny(DocumentMarker::allMarkers()));
return !m_markers.isEmpty();
}
bool hasMarkers(Range&, OptionSet<DocumentMarker::MarkerType> = DocumentMarker::allMarkers());
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (234810 => 234811)
--- trunk/Source/WebCore/rendering/RenderElement.cpp 2018-08-13 18:42:55 UTC (rev 234810)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp 2018-08-13 19:16:10 UTC (rev 234811)
@@ -1361,7 +1361,7 @@
// If the element is unselectable, or we are only painting the selection,
// don't override the foreground color with the selection foreground color.
if (style().userSelect() == UserSelect::None
- || (view().frameView().paintBehavior().contains(OptionSet<PaintBehavior>(PaintBehavior::SelectionOnly) | PaintBehavior::SelectionAndBackgroundsOnly)))
+ || (view().frameView().paintBehavior().containsAny({ PaintBehavior::SelectionOnly, PaintBehavior::SelectionAndBackgroundsOnly })))
return Color();
if (std::unique_ptr<RenderStyle> pseudoStyle = selectionPseudoStyle()) {
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (234810 => 234811)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2018-08-13 18:42:55 UTC (rev 234810)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2018-08-13 19:16:10 UTC (rev 234811)
@@ -4788,7 +4788,7 @@
// We have to loop through every fragment multiple times, since we have to repaint in each specific phase in order for
// interleaving of the fragments to work properly.
- bool selectionOnly = localPaintingInfo.paintBehavior.contains(OptionSet<PaintBehavior>(PaintBehavior::SelectionAndBackgroundsOnly) | PaintBehavior::SelectionOnly);
+ bool selectionOnly = localPaintingInfo.paintBehavior.containsAny({ PaintBehavior::SelectionAndBackgroundsOnly, PaintBehavior::SelectionOnly });
paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhase::Selection : PaintPhase::ChildBlockBackgrounds, layerFragments,
context, localPaintingInfo, localPaintBehavior, subtreePaintRootForRenderer);
Modified: trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp (234810 => 234811)
--- trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp 2018-08-13 18:42:55 UTC (rev 234810)
+++ trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp 2018-08-13 19:16:10 UTC (rev 234811)
@@ -1847,7 +1847,7 @@
return false;
if (FrameView* frameView = frame()->view()) {
- if (frameView->paintBehavior().contains(OptionSet<PaintBehavior>(PaintBehavior::SelectionOnly) | PaintBehavior::SelectionAndBackgroundsOnly | PaintBehavior::ForceBlackText)) {
+ if (frameView->paintBehavior().containsAny({ PaintBehavior::SelectionOnly, PaintBehavior::SelectionAndBackgroundsOnly, PaintBehavior::ForceBlackText})) {
// This paint behavior is used when drawing the find indicator and there's no need to
// snapshot plug-ins, because they can never be painted as part of the find indicator.
return false;
Modified: trunk/Tools/ChangeLog (234810 => 234811)
--- trunk/Tools/ChangeLog 2018-08-13 18:42:55 UTC (rev 234810)
+++ trunk/Tools/ChangeLog 2018-08-13 19:16:10 UTC (rev 234811)
@@ -1,3 +1,13 @@
+2018-08-13 Antti Koivisto <[email protected]>
+
+ Meaning of OptionSet::contains is unclear when used with OptionSet argument
+ https://bugs.webkit.org/show_bug.cgi?id=188501
+
+ Reviewed by Anders Carlsson.
+
+ * TestWebKitAPI/Tests/WTF/OptionSet.cpp:
+ (TestWebKitAPI::TEST):
+
2018-08-13 Commit Queue <[email protected]>
Unreviewed, rolling out r234747.
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp (234810 => 234811)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp 2018-08-13 18:42:55 UTC (rev 234810)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp 2018-08-13 19:16:10 UTC (rev 234811)
@@ -379,4 +379,32 @@
}
}
+TEST(WTF_OptionSet, ContainsAny)
+{
+ OptionSet<ExampleFlags> set { ExampleFlags::A, ExampleFlags::B };
+
+ EXPECT_TRUE(set.containsAny({ ExampleFlags::A }));
+ EXPECT_TRUE(set.containsAny({ ExampleFlags::B }));
+ EXPECT_FALSE(set.containsAny({ ExampleFlags::C }));
+ EXPECT_FALSE(set.containsAny({ ExampleFlags::C, ExampleFlags::D }));
+ EXPECT_TRUE(set.containsAny({ ExampleFlags::A, ExampleFlags::B }));
+ EXPECT_TRUE(set.containsAny({ ExampleFlags::B, ExampleFlags::C }));
+ EXPECT_TRUE(set.containsAny({ ExampleFlags::A, ExampleFlags::C }));
+ EXPECT_TRUE(set.containsAny({ ExampleFlags::A, ExampleFlags::B, ExampleFlags::C }));
+}
+
+TEST(WTF_OptionSet, ContainsAll)
+{
+ OptionSet<ExampleFlags> set { ExampleFlags::A, ExampleFlags::B };
+
+ EXPECT_TRUE(set.containsAll({ ExampleFlags::A }));
+ EXPECT_TRUE(set.containsAll({ ExampleFlags::B }));
+ EXPECT_FALSE(set.containsAll({ ExampleFlags::C }));
+ EXPECT_FALSE(set.containsAll({ ExampleFlags::C, ExampleFlags::D }));
+ EXPECT_TRUE(set.containsAll({ ExampleFlags::A, ExampleFlags::B }));
+ EXPECT_FALSE(set.containsAll({ ExampleFlags::B, ExampleFlags::C }));
+ EXPECT_FALSE(set.containsAll({ ExampleFlags::A, ExampleFlags::C }));
+ EXPECT_FALSE(set.containsAll({ ExampleFlags::A, ExampleFlags::B, ExampleFlags::C }));
+}
+
} // namespace TestWebKitAPI