Title: [155164] trunk/Source
Revision
155164
Author
[email protected]
Date
2013-09-05 17:35:00 -0700 (Thu, 05 Sep 2013)

Log Message

ScrollView::children() should return a reference.
<https://webkit.org/b/120795>

Reviewed by Anders Carlsson.

Source/WebCore:

This function was already just returning the address of a member variable.
Modernized some loops that were using it.

* bindings/js/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::setJavaScriptPaused):
* page/FrameView.cpp:
(WebCore::FrameView::hasCustomScrollbars):
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/Page.cpp:
(WebCore::Page::pluginViews):
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::computeNonFastScrollableRegion):
* platform/ScrollView.h:
(WebCore::ScrollView::children):
* plugins/IFrameShimSupport.cpp:
(WebCore::getPluginOcclusions):

Source/WebKit/mac:

* WebView/WebView.mm:
(-[WebView _addScrollerDashboardRegionsForFrameView:dashboardRegions:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (155163 => 155164)


--- trunk/Source/WebCore/ChangeLog	2013-09-06 00:23:22 UTC (rev 155163)
+++ trunk/Source/WebCore/ChangeLog	2013-09-06 00:35:00 UTC (rev 155164)
@@ -1,3 +1,27 @@
+2013-09-05  Andreas Kling  <[email protected]>
+
+        ScrollView::children() should return a reference.
+        <https://webkit.org/b/120795>
+
+        Reviewed by Anders Carlsson.
+
+        This function was already just returning the address of a member variable.
+        Modernized some loops that were using it.
+
+        * bindings/js/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::setJavaScriptPaused):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::hasCustomScrollbars):
+        (WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
+        * page/Page.cpp:
+        (WebCore::Page::pluginViews):
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::computeNonFastScrollableRegion):
+        * platform/ScrollView.h:
+        (WebCore::ScrollView::children):
+        * plugins/IFrameShimSupport.cpp:
+        (WebCore::getPluginOcclusions):
+
 2013-09-05  Beth Dakin  <[email protected]>
 
         Reverting revisions 155139, 155141, 155142, and 155145 since they appear to have 

Modified: trunk/Source/WebCore/bindings/js/PageScriptDebugServer.cpp (155163 => 155164)


--- trunk/Source/WebCore/bindings/js/PageScriptDebugServer.cpp	2013-09-06 00:23:22 UTC (rev 155163)
+++ trunk/Source/WebCore/bindings/js/PageScriptDebugServer.cpp	2013-09-06 00:35:00 UTC (rev 155164)
@@ -219,11 +219,7 @@
     if (!view)
         return;
 
-    const HashSet<RefPtr<Widget> >* children = view->children();
-    ASSERT(children);
-
-    HashSet<RefPtr<Widget> >::const_iterator end = children->end();
-    for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != end; ++it) {
+    for (auto it = view->children().begin(), end = view->children().end(); it != end; ++it) {
         Widget* widget = (*it).get();
         if (!widget->isPluginView())
             continue;

Modified: trunk/Source/WebCore/page/FrameView.cpp (155163 => 155164)


--- trunk/Source/WebCore/page/FrameView.cpp	2013-09-06 00:23:22 UTC (rev 155163)
+++ trunk/Source/WebCore/page/FrameView.cpp	2013-09-06 00:35:00 UTC (rev 155164)
@@ -1065,19 +1065,6 @@
     return onlyDuringLayout && layoutPending() ? 0 : m_layoutRoot;
 }
 
-static inline void collectFrameViewChildren(FrameView* frameView, Vector<RefPtr<FrameView> >& frameViews)
-{
-    const HashSet<RefPtr<Widget> >* viewChildren = frameView->children();
-    ASSERT(viewChildren);
-
-    const HashSet<RefPtr<Widget> >::iterator end = viewChildren->end();
-    for (HashSet<RefPtr<Widget> >::iterator current = viewChildren->begin(); current != end; ++current) {
-        Widget* widget = (*current).get();
-        if (widget->isFrameView())
-            frameViews.append(toFrameView(widget));
-    }
-}
-
 inline void FrameView::forceLayoutParentViewIfNeeded()
 {
 #if ENABLE(SVG)
@@ -3378,10 +3365,8 @@
 
 bool FrameView::hasCustomScrollbars() const
 {
-    const HashSet<RefPtr<Widget> >* viewChildren = children();
-    HashSet<RefPtr<Widget> >::const_iterator end = viewChildren->end();
-    for (HashSet<RefPtr<Widget> >::const_iterator current = viewChildren->begin(); current != end; ++current) {
-        Widget* widget = current->get();
+    for (auto it = children().begin(), end = children().end(); it != end; ++it) {
+        Widget* widget = it->get();
         if (widget->isFrameView()) {
             if (toFrameView(widget)->hasCustomScrollbars())
                 return true;
@@ -3695,12 +3680,15 @@
     // Grab a copy of the children() set, as it may be mutated by the following updateLayoutAndStyleIfNeededRecursive
     // calls, as they can potentially re-enter a layout of the parent frame view, which may add/remove scrollbars
     // and thus mutates the children() set.
-    Vector<RefPtr<FrameView> > frameViews;
-    collectFrameViewChildren(this, frameViews);
+    Vector<Ref<FrameView>, 16> childViews;
+    childViews.reserveInitialCapacity(children().size());
+    for (auto it = children().begin(), end = children().end(); it != end; ++it) {
+        if (it->get()->isFrameView())
+            childViews.uncheckedAppend(*toFrameView(it->get()));
+    }
 
-    const Vector<RefPtr<FrameView> >::iterator end = frameViews.end();
-    for (Vector<RefPtr<FrameView> >::iterator it = frameViews.begin(); it != end; ++it)
-        (*it)->updateLayoutAndStyleIfNeededRecursive();
+    for (unsigned i = 0; i < childViews.size(); ++i)
+        childViews[i]->updateLayoutAndStyleIfNeededRecursive();
 
     // updateLayoutAndStyleIfNeededRecursive is called when we need to make sure style and layout are up-to-date before
     // painting, so we need to flush out any deferred repaints too.

Modified: trunk/Source/WebCore/page/Page.cpp (155163 => 155164)


--- trunk/Source/WebCore/page/Page.cpp	2013-09-06 00:23:22 UTC (rev 155163)
+++ trunk/Source/WebCore/page/Page.cpp	2013-09-06 00:35:00 UTC (rev 155164)
@@ -1187,10 +1187,7 @@
         if (!view)
             break;
 
-        auto children = view->children();
-        ASSERT(children);
-
-        for (auto it = children->begin(), end = children->end(); it != end; ++it) {
+        for (auto it = view->children().begin(), end = view->children().end(); it != end; ++it) {
             Widget* widget = (*it).get();
             if (widget->isPluginViewBase())
                 views.append(*toPluginViewBase(widget));

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (155163 => 155164)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp	2013-09-06 00:23:22 UTC (rev 155163)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp	2013-09-06 00:35:00 UTC (rev 155164)
@@ -140,15 +140,12 @@
         }
     }
 
-    if (const HashSet<RefPtr<Widget> >* children = frameView->children()) {
-        for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(), end = children->end(); it != end; ++it) {
-            if (!(*it)->isPluginViewBase())
-                continue;
-
-            PluginViewBase* pluginViewBase = toPluginViewBase((*it).get());
-            if (pluginViewBase->wantsWheelEvents())
-                nonFastScrollableRegion.unite(pluginViewBase->frameRect());
-        }
+    for (auto it = frameView->children().begin(), end = frameView->children().end(); it != end; ++it) {
+        if (!(*it)->isPluginViewBase())
+            continue;
+        PluginViewBase* pluginViewBase = toPluginViewBase((*it).get());
+        if (pluginViewBase->wantsWheelEvents())
+            nonFastScrollableRegion.unite(pluginViewBase->frameRect());
     }
 
     for (Frame* subframe = frame->tree().firstChild(); subframe; subframe = subframe->tree().nextSibling())

Modified: trunk/Source/WebCore/platform/ScrollView.h (155163 => 155164)


--- trunk/Source/WebCore/platform/ScrollView.h	2013-09-06 00:23:22 UTC (rev 155163)
+++ trunk/Source/WebCore/platform/ScrollView.h	2013-09-06 00:35:00 UTC (rev 155164)
@@ -68,7 +68,7 @@
     virtual IntRect windowClipRect(bool clipToContents = true) const = 0;
 
     // Functions for child manipulation and inspection.
-    const HashSet<RefPtr<Widget> >* children() const { return &m_children; }
+    const HashSet<RefPtr<Widget>>& children() const { return m_children; }
     virtual void addChild(PassRefPtr<Widget>);
     virtual void removeChild(Widget*);
 

Modified: trunk/Source/WebCore/plugins/IFrameShimSupport.cpp (155163 => 155164)


--- trunk/Source/WebCore/plugins/IFrameShimSupport.cpp	2013-09-06 00:23:22 UTC (rev 155163)
+++ trunk/Source/WebCore/plugins/IFrameShimSupport.cpp	2013-09-06 00:35:00 UTC (rev 155164)
@@ -135,8 +135,8 @@
 
     FrameView* parentFrameView = toFrameView(parentWidget);
 
-    const HashSet<RefPtr<Widget> >* children = parentFrameView->children();
-    for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != children->end(); ++it) {
+    const auto& children = parentFrameView->children();
+    for (auto it = children.begin(); it != children.end(); ++it) {
         // We only care about FrameView's because iframes show up as FrameViews.
         if (!(*it)->isFrameView())
             continue;

Modified: trunk/Source/WebKit/mac/ChangeLog (155163 => 155164)


--- trunk/Source/WebKit/mac/ChangeLog	2013-09-06 00:23:22 UTC (rev 155163)
+++ trunk/Source/WebKit/mac/ChangeLog	2013-09-06 00:35:00 UTC (rev 155164)
@@ -1,3 +1,13 @@
+2013-09-05  Andreas Kling  <[email protected]>
+
+        ScrollView::children() should return a reference.
+        <https://webkit.org/b/120795>
+
+        Reviewed by Anders Carlsson.
+
+        * WebView/WebView.mm:
+        (-[WebView _addScrollerDashboardRegionsForFrameView:dashboardRegions:]):
+
 2013-09-04  Mark Rowe  <[email protected]>
 
         <https://webkit.org/b/120707> Make WebKit's localizable strings mechanism usable under ARC

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (155163 => 155164)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2013-09-06 00:23:22 UTC (rev 155163)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2013-09-06 00:35:00 UTC (rev 155164)
@@ -2074,12 +2074,9 @@
 {    
     NSView *documentView = [[kit(&frameView->frame()) frameView] documentView];
 
-    const HashSet<RefPtr<Widget> >* children = frameView->children();
-    HashSet<RefPtr<Widget> >::const_iterator end = children->end();
-    for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != end; ++it) {
-        Widget* widget = (*it).get();
+    for (const auto& widget: frameView->children()) {
         if (widget->isFrameView()) {
-            [self _addScrollerDashboardRegionsForFrameView:toFrameView(widget) dashboardRegions:regions];
+            [self _addScrollerDashboardRegionsForFrameView:toFrameView(widget.get()) dashboardRegions:regions];
             continue;
         }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to