WebKit Bugzilla
Attachment 339565 Details for
Bug 185306
: Add OptionSet::operator& and operator bool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
optionset-and.patch (text/plain), 12.15 KB, created by
Antti Koivisto
on 2018-05-04 10:58:48 PDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Antti Koivisto
Created:
2018-05-04 10:58:48 PDT
Size:
12.15 KB
patch
obsolete
>Index: Source/WTF/ChangeLog >=================================================================== >--- Source/WTF/ChangeLog (revision 231353) >+++ Source/WTF/ChangeLog (working copy) >@@ -1,3 +1,27 @@ >+2018-05-04 Antti Koivisto <antti@apple.com> >+ >+ Add OptionSet::operator& and operator bool >+ https://bugs.webkit.org/show_bug.cgi?id=185306 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This is primarily to allow writing >+ >+ if (options & Option:A) >+ >+ instead of >+ >+ if (options.contains(Option:A)) >+ >+ This is consistent with other OptionSet operators. >+ >+ * wtf/OptionSet.h: >+ (WTF::OptionSet::operator bool): >+ (WTF::OptionSet::operator&): >+ >+ Also remove T versions of operator| and operator-, they are not needed due to >+ implicit conversion from T to OptionSet<T>. >+ > 2018-05-04 Antti Koivisto <antti@apple.com> > > OptionsSet initializer list constructor should be constexpr >Index: Source/WTF/wtf/OptionSet.h >=================================================================== >--- Source/WTF/wtf/OptionSet.h (revision 231353) >+++ Source/WTF/wtf/OptionSet.h (working copy) >@@ -107,6 +107,8 @@ public: > constexpr iterator begin() const { return m_storage; } > constexpr iterator end() const { return 0; } > >+ constexpr explicit operator bool() { return !isEmpty(); } >+ > constexpr bool contains(OptionSet optionSet) const > { > return m_storage & optionSet.m_storage; >@@ -139,9 +141,9 @@ public: > return fromRaw(lhs.m_storage | rhs.m_storage); > } > >- constexpr friend OptionSet operator|(OptionSet lhs, T rhs) >+ constexpr friend OptionSet operator&(OptionSet lhs, OptionSet rhs) > { >- return lhs | OptionSet { rhs }; >+ return fromRaw(lhs.m_storage & rhs.m_storage); > } > > constexpr friend OptionSet operator-(OptionSet lhs, OptionSet rhs) >@@ -149,11 +151,6 @@ public: > return fromRaw(lhs.m_storage & ~rhs.m_storage); > } > >- constexpr friend OptionSet operator-(OptionSet lhs, T rhs) >- { >- return lhs - OptionSet { rhs }; >- } >- > private: > enum InitializationTag { FromRawValue }; > constexpr OptionSet(T t, InitializationTag) >Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 231351) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,18 @@ >+2018-05-04 Antti Koivisto <antti@apple.com> >+ >+ Add OptionSet::operator& and operator bool >+ https://bugs.webkit.org/show_bug.cgi?id=185306 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Use it in a few places. >+ >+ * loader/FrameLoader.cpp: >+ (WebCore::FrameLoader::reload): >+ * rendering/RenderLayerCompositor.cpp: >+ (WebCore::RenderLayerCompositor::logReasonsForCompositing): >+ (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): >+ > 2018-05-04 Yacine Bandou <yacine.bandou_ext@softathome.com> > > [MSE][GStreamer] Delete properly the stream from the WebKitMediaSource >Index: Source/WebCore/loader/FrameLoader.cpp >=================================================================== >--- Source/WebCore/loader/FrameLoader.cpp (revision 231351) >+++ Source/WebCore/loader/FrameLoader.cpp (working copy) >@@ -1693,9 +1693,9 @@ void FrameLoader::reload(OptionSet<Reloa > loader->setOverrideEncoding(m_documentLoader->overrideEncoding()); > > auto frameLoadTypeForReloadOptions = [] (auto options) { >- if (options.contains(ReloadOption::FromOrigin)) >+ if (options & ReloadOption::FromOrigin) > return FrameLoadType::ReloadFromOrigin; >- if (options.contains(ReloadOption::ExpiredOnly)) >+ if (options & ReloadOption::ExpiredOnly) > return FrameLoadType::ReloadExpiredOnly; > return FrameLoadType::Reload; > }; >Index: Source/WebCore/rendering/RenderLayerCompositor.cpp >=================================================================== >--- Source/WebCore/rendering/RenderLayerCompositor.cpp (revision 231351) >+++ Source/WebCore/rendering/RenderLayerCompositor.cpp (working copy) >@@ -2210,81 +2210,81 @@ const char* RenderLayerCompositor::logRe > { > OptionSet<CompositingReason> reasons = reasonsForCompositing(layer); > >- if (reasons.contains(CompositingReason::Transform3D)) >+ if (reasons & CompositingReason::Transform3D) > return "3D transform"; > >- if (reasons.contains(CompositingReason::Video)) >+ if (reasons & CompositingReason::Video) > return "video"; > >- if (reasons.contains(CompositingReason::Canvas)) >+ if (reasons & CompositingReason::Canvas) > return "canvas"; > >- if (reasons.contains(CompositingReason::Plugin)) >+ if (reasons & CompositingReason::Plugin) > return "plugin"; > >- if (reasons.contains(CompositingReason::IFrame)) >+ if (reasons & CompositingReason::IFrame) > return "iframe"; > >- if (reasons.contains(CompositingReason::BackfaceVisibilityHidden)) >+ if (reasons & CompositingReason::BackfaceVisibilityHidden) > return "backface-visibility: hidden"; > >- if (reasons.contains(CompositingReason::ClipsCompositingDescendants)) >+ if (reasons & CompositingReason::ClipsCompositingDescendants) > return "clips compositing descendants"; > >- if (reasons.contains(CompositingReason::Animation)) >+ if (reasons & CompositingReason::Animation) > return "animation"; > >- if (reasons.contains(CompositingReason::Filters)) >+ if (reasons & CompositingReason::Filters) > return "filters"; > >- if (reasons.contains(CompositingReason::PositionFixed)) >+ if (reasons & CompositingReason::PositionFixed) > return "position: fixed"; > >- if (reasons.contains(CompositingReason::PositionSticky)) >+ if (reasons & CompositingReason::PositionSticky) > return "position: sticky"; > >- if (reasons.contains(CompositingReason::OverflowScrollingTouch)) >+ if (reasons & CompositingReason::OverflowScrollingTouch) > return "-webkit-overflow-scrolling: touch"; > >- if (reasons.contains(CompositingReason::Stacking)) >+ if (reasons & CompositingReason::Stacking) > return "stacking"; > >- if (reasons.contains(CompositingReason::Overlap)) >+ if (reasons & CompositingReason::Overlap) > return "overlap"; > >- if (reasons.contains(CompositingReason::NegativeZIndexChildren)) >+ if (reasons & CompositingReason::NegativeZIndexChildren) > return "negative z-index children"; > >- if (reasons.contains(CompositingReason::TransformWithCompositedDescendants)) >+ if (reasons & CompositingReason::TransformWithCompositedDescendants) > return "transform with composited descendants"; > >- if (reasons.contains(CompositingReason::OpacityWithCompositedDescendants)) >+ if (reasons & CompositingReason::OpacityWithCompositedDescendants) > return "opacity with composited descendants"; > >- if (reasons.contains(CompositingReason::MaskWithCompositedDescendants)) >+ if (reasons & CompositingReason::MaskWithCompositedDescendants) > return "mask with composited descendants"; > >- if (reasons.contains(CompositingReason::ReflectionWithCompositedDescendants)) >+ if (reasons & CompositingReason::ReflectionWithCompositedDescendants) > return "reflection with composited descendants"; > >- if (reasons.contains(CompositingReason::FilterWithCompositedDescendants)) >+ if (reasons & CompositingReason::FilterWithCompositedDescendants) > return "filter with composited descendants"; > > #if ENABLE(CSS_COMPOSITING) >- if (reasons.contains(CompositingReason::BlendingWithCompositedDescendants)) >+ if (reasons & CompositingReason::BlendingWithCompositedDescendants) > return "blending with composited descendants"; > >- if (reasons.contains(CompositingReason::IsolatesCompositedBlendingDescendants)) >+ if (reasons & CompositingReason::IsolatesCompositedBlendingDescendants) > return "isolates composited blending descendants"; > #endif > >- if (reasons.contains(CompositingReason::Perspective)) >+ if (reasons & CompositingReason::Perspective) > return "perspective"; > >- if (reasons.contains(CompositingReason::Preserve3D)) >+ if (reasons & CompositingReason::Preserve3D) > return "preserve-3d"; > >- if (reasons.contains(CompositingReason::Root)) >+ if (reasons & CompositingReason::Root) > return "root"; > > return ""; >@@ -3798,10 +3798,10 @@ void RenderLayerCompositor::updateScroll > > LOG_WITH_STREAM(Compositing, stream << "Registering ViewportConstrained " << nodeType << " node " << nodeID << " (layer " << backing->graphicsLayer()->primaryLayerID() << ") as child of " << parentNodeID); > >- if (changes.contains(ScrollingNodeChangeFlags::Layer)) >+ if (changes & ScrollingNodeChangeFlags::Layer) > scrollingCoordinator->updateNodeLayer(nodeID, backing->graphicsLayer()); > >- if (changes.contains(ScrollingNodeChangeFlags::LayerGeometry)) { >+ if (changes & ScrollingNodeChangeFlags::LayerGeometry) { > switch (nodeType) { > case FixedNode: > scrollingCoordinator->updateNodeViewportConstraints(nodeID, computeFixedViewportConstraints(layer)); >Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 231362) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,13 @@ >+2018-05-04 Antti Koivisto <antti@apple.com> >+ >+ Add OptionSet::operator& and operator bool >+ https://bugs.webkit.org/show_bug.cgi?id=185306 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WTF/OptionSet.cpp: >+ (TestWebKitAPI::TEST): >+ > 2018-05-04 Myles C. Maxfield <mmaxfield@apple.com> > > Text shaping in the simple path is flipped in the y direction >Index: Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp >=================================================================== >--- Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp (revision 231351) >+++ Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp (working copy) >@@ -316,4 +316,67 @@ TEST(WTF_OptionSet, IterationOrderTheSam > EXPECT_TRUE(*it1 == *it2); > } > >+TEST(WTF_OptionSet, OperatorAnd) >+{ >+ OptionSet<ExampleFlags> a { ExampleFlags::A }; >+ OptionSet<ExampleFlags> ac { ExampleFlags::A, ExampleFlags::C }; >+ OptionSet<ExampleFlags> bc { ExampleFlags::B, ExampleFlags::C }; >+ { >+ auto set = a & ac; >+ EXPECT_TRUE(!!set); >+ EXPECT_FALSE(set.isEmpty()); >+ EXPECT_TRUE(set.contains(ExampleFlags::A)); >+ EXPECT_FALSE(set.contains(ExampleFlags::B)); >+ EXPECT_FALSE(set.contains(ExampleFlags::C)); >+ } >+ { >+ auto set = a & bc; >+ EXPECT_FALSE(!!set); >+ EXPECT_TRUE(set.isEmpty()); >+ EXPECT_FALSE(set.contains(ExampleFlags::A)); >+ EXPECT_FALSE(set.contains(ExampleFlags::B)); >+ EXPECT_FALSE(set.contains(ExampleFlags::C)); >+ } >+ { >+ auto set = ac & bc; >+ EXPECT_TRUE(!!set); >+ EXPECT_FALSE(set.isEmpty()); >+ EXPECT_FALSE(set.contains(ExampleFlags::A)); >+ EXPECT_FALSE(set.contains(ExampleFlags::B)); >+ EXPECT_TRUE(set.contains(ExampleFlags::C)); >+ } >+ { >+ auto set = ExampleFlags::A & bc; >+ EXPECT_FALSE(!!set); >+ EXPECT_TRUE(set.isEmpty()); >+ EXPECT_FALSE(set.contains(ExampleFlags::A)); >+ EXPECT_FALSE(set.contains(ExampleFlags::B)); >+ EXPECT_FALSE(set.contains(ExampleFlags::C)); >+ } >+ { >+ auto set = ExampleFlags::A & ac; >+ EXPECT_TRUE(!!set); >+ EXPECT_FALSE(set.isEmpty()); >+ EXPECT_TRUE(set.contains(ExampleFlags::A)); >+ EXPECT_FALSE(set.contains(ExampleFlags::B)); >+ EXPECT_FALSE(set.contains(ExampleFlags::C)); >+ } >+ { >+ auto set = bc & ExampleFlags::A; >+ EXPECT_FALSE(!!set); >+ EXPECT_TRUE(set.isEmpty()); >+ EXPECT_FALSE(set.contains(ExampleFlags::A)); >+ EXPECT_FALSE(set.contains(ExampleFlags::B)); >+ EXPECT_FALSE(set.contains(ExampleFlags::C)); >+ } >+ { >+ auto set = ac & ExampleFlags::A; >+ EXPECT_TRUE(!!set); >+ EXPECT_FALSE(set.isEmpty()); >+ EXPECT_TRUE(set.contains(ExampleFlags::A)); >+ EXPECT_FALSE(set.contains(ExampleFlags::B)); >+ EXPECT_FALSE(set.contains(ExampleFlags::C)); >+ } >+} >+ > } // namespace TestWebKitAPI
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185306
: 339565