Commit 2a375b4e authored by andersca@apple.com's avatar andersca@apple.com

Test the waters and begin using lambdas

https://bugs.webkit.org/show_bug.cgi?id=121809

Reviewed by Andreas Kling.

Source/WebCore:

Use lambdas instead of static functions and function objects.

* css/MediaQuery.cpp:
(WebCore::MediaQuery::MediaQuery):
* dom/MutationObserver.cpp:
(WebCore::MutationObserver::deliverAllMutations):
* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::sortedTrackListForMenu):

Source/WTF:

* wtf/ListDump.h:
(WTF::sortedListDump):
Use std::less instead of a custom lessThan function.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156963 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b40e6cd4
2013-10-05 Anders Carlsson <andersca@apple.com>
Test the waters and begin using lambdas
https://bugs.webkit.org/show_bug.cgi?id=121809
Reviewed by Andreas Kling.
* wtf/ListDump.h:
(WTF::sortedListDump):
Use std::less instead of a custom lessThan function.
2013-10-04 Darin Adler <darin@apple.com>
text-transform: lowercase is not lang-dependent (Turkish languages : tr,az)
......
......@@ -93,16 +93,10 @@ CString sortedListDump(const T& list, const Comparator& comparator, const char*
return out.toCString();
}
template<typename T>
inline bool lessThan(const T& a, const T& b)
{
return a < b;
}
template<typename T>
CString sortedListDump(const T& list, const char* comma = ", ")
{
return sortedListDump(list, lessThan<typename T::ValueType>, comma);
return sortedListDump(list, std::less<typename T::ValueType>(), comma);
}
template<typename T>
......
2013-10-05 Anders Carlsson <andersca@apple.com>
Test the waters and begin using lambdas
https://bugs.webkit.org/show_bug.cgi?id=121809
Reviewed by Andreas Kling.
Use lambdas instead of static functions and function objects.
* css/MediaQuery.cpp:
(WebCore::MediaQuery::MediaQuery):
* dom/MutationObserver.cpp:
(WebCore::MutationObserver::deliverAllMutations):
* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::sortedTrackListForMenu):
2013-10-05 Gyuyoung Kim <gyuyoung.kim@samsung.com>
Add *CSS* prefix to FontValue to generate toCSSFontValue()
......@@ -72,11 +72,6 @@ String MediaQuery::serialize() const
return result.toString();
}
static bool expressionCompare(const OwnPtr<MediaQueryExp>& a, const OwnPtr<MediaQueryExp>& b)
{
return codePointCompare(a->serialize(), b->serialize()) < 0;
}
MediaQuery::MediaQuery(Restrictor r, const String& mediaType, PassOwnPtr<ExpressionVector> exprs)
: m_restrictor(r)
, m_mediaType(mediaType.lower())
......@@ -88,7 +83,9 @@ MediaQuery::MediaQuery(Restrictor r, const String& mediaType, PassOwnPtr<Express
return;
}
std::sort(m_expressions->begin(), m_expressions->end(), expressionCompare);
std::sort(m_expressions->begin(), m_expressions->end(), [](const OwnPtr<MediaQueryExp>& a, const OwnPtr<MediaQueryExp>& b) {
return codePointCompare(a->serialize(), b->serialize()) < 0;
});
// remove all duplicated expressions
String key;
......
......@@ -48,13 +48,6 @@ namespace WebCore {
static unsigned s_observerPriority = 0;
struct MutationObserver::ObserverLessThan {
bool operator()(const RefPtr<MutationObserver>& lhs, const RefPtr<MutationObserver>& rhs)
{
return lhs->m_priority < rhs->m_priority;
}
};
PassRefPtr<MutationObserver> MutationObserver::create(PassRefPtr<MutationCallback> callback)
{
ASSERT(isMainThread());
......@@ -231,7 +224,10 @@ void MutationObserver::deliverAllMutations()
Vector<RefPtr<MutationObserver> > observers;
copyToVector(activeMutationObservers(), observers);
activeMutationObservers().clear();
std::sort(observers.begin(), observers.end(), ObserverLessThan());
std::sort(observers.begin(), observers.end(), [](const RefPtr<MutationObserver>& lhs, const RefPtr<MutationObserver>& rhs) {
return lhs->m_priority < rhs->m_priority;
});
for (size_t i = 0; i < observers.size(); ++i) {
if (observers[i]->canDeliver())
observers[i]->deliver();
......
......@@ -173,11 +173,6 @@ String CaptionUserPreferences::displayNameForTrack(TextTrack* track) const
return trackDisplayName(track);
}
static bool textTrackCompare(const RefPtr<TextTrack>& a, const RefPtr<TextTrack>& b)
{
return codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get())) < 0;
}
Vector<RefPtr<TextTrack>> CaptionUserPreferences::sortedTrackListForMenu(TextTrackList* trackList)
{
ASSERT(trackList);
......@@ -187,7 +182,9 @@ Vector<RefPtr<TextTrack>> CaptionUserPreferences::sortedTrackListForMenu(TextTra
for (unsigned i = 0, length = trackList->length(); i < length; ++i)
tracksForMenu.append(trackList->item(i));
std::sort(tracksForMenu.begin(), tracksForMenu.end(), textTrackCompare);
std::sort(tracksForMenu.begin(), tracksForMenu.end(), [](const RefPtr<TextTrack>& a, const RefPtr<TextTrack>& b) {
return codePointCompare(trackDisplayName(a.get()), trackDisplayName(b.get())) < 0;
});
tracksForMenu.insert(0, TextTrack::captionMenuOffItem());
tracksForMenu.insert(1, TextTrack::captionMenuAutomaticItem());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment