Commit c151c812 authored by akling@apple.com's avatar akling@apple.com

Use Vector<Ref<T>> in three random WebCore loops.

<https://webkit.org/b/120661>

Reviewed by Darin Adler.

Clean up three little loops to use Refs to avoid null checking known-valid objects.
Also apply auto, reserveInitialCapacity and uncheckedAppend as appropriate.

* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchAllPendingBeforeUnloadEvents):
(WebCore::DOMWindow::dispatchAllPendingUnloadEvents):
* platform/graphics/FontCache.cpp:
(WebCore::FontCache::invalidate):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155040 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e201d111
2013-09-04 Andreas Kling <akling@apple.com>
Use Vector<Ref<T>> in three random WebCore loops.
<https://webkit.org/b/120661>
Reviewed by Darin Adler.
Clean up three little loops to use Refs to avoid null checking known-valid objects.
Also apply auto, reserveInitialCapacity and uncheckedAppend as appropriate.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchAllPendingBeforeUnloadEvents):
(WebCore::DOMWindow::dispatchAllPendingUnloadEvents):
* platform/graphics/FontCache.cpp:
(WebCore::FontCache::invalidate):
2013-09-04 Claudio Saavedra <csaavedra@igalia.com>
[GTK] Color of input button's text broken with recent gnome-themes-standard
......@@ -232,25 +232,24 @@ bool DOMWindow::dispatchAllPendingBeforeUnloadEvents()
if (alreadyDispatched)
return true;
Vector<RefPtr<DOMWindow> > windows;
DOMWindowSet::iterator end = set.end();
for (DOMWindowSet::iterator it = set.begin(); it != end; ++it)
windows.append(it->key);
size_t size = windows.size();
for (size_t i = 0; i < size; ++i) {
DOMWindow* window = windows[i].get();
if (!set.contains(window))
Vector<Ref<DOMWindow>> windows;
windows.reserveInitialCapacity(set.size());
for (auto it = set.begin(), end = set.end(); it != end; ++it)
windows.uncheckedAppend(*it->key);
for (unsigned i = 0; i < windows.size(); ++i) {
DOMWindow& window = windows[i].get();
if (!set.contains(&window))
continue;
Frame* frame = window->frame();
Frame* frame = window.frame();
if (!frame)
continue;
if (!frame->loader().shouldClose())
return false;
window->enableSuddenTermination();
window.enableSuddenTermination();
}
alreadyDispatched = true;
......@@ -273,21 +272,20 @@ void DOMWindow::dispatchAllPendingUnloadEvents()
if (alreadyDispatched)
return;
Vector<RefPtr<DOMWindow> > windows;
DOMWindowSet::iterator end = set.end();
for (DOMWindowSet::iterator it = set.begin(); it != end; ++it)
windows.append(it->key);
Vector<Ref<DOMWindow>> windows;
windows.reserveInitialCapacity(set.size());
for (auto it = set.begin(), end = set.end(); it != end; ++it)
windows.uncheckedAppend(*it->key);
size_t size = windows.size();
for (size_t i = 0; i < size; ++i) {
DOMWindow* window = windows[i].get();
if (!set.contains(window))
for (unsigned i = 0; i < windows.size(); ++i) {
DOMWindow& window = windows[i].get();
if (!set.contains(&window))
continue;
window->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, false), window->document());
window->dispatchEvent(Event::create(eventNames().unloadEvent, false, false), window->document());
window.dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, false), window.document());
window.dispatchEvent(Event::create(eventNames().unloadEvent, false, false), window.document());
window->enableSuddenTermination();
window.enableSuddenTermination();
}
alreadyDispatched = true;
......
......@@ -535,15 +535,12 @@ void FontCache::invalidate()
gGeneration++;
Vector<RefPtr<FontSelector> > clients;
size_t numClients = gClients->size();
clients.reserveInitialCapacity(numClients);
HashSet<FontSelector*>::iterator end = gClients->end();
for (HashSet<FontSelector*>::iterator it = gClients->begin(); it != end; ++it)
clients.append(*it);
ASSERT(numClients == clients.size());
for (size_t i = 0; i < numClients; ++i)
Vector<Ref<FontSelector>> clients;
clients.reserveInitialCapacity(gClients->size());
for (auto it = gClients->begin(), end = gClients->end(); it != end; ++it)
clients.uncheckedAppend(**it);
for (unsigned i = 0; i < clients.size(); ++i)
clients[i]->fontCacheInvalidated();
purgeInactiveFontData();
......
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