Title: [154715] trunk/Source

Diff

Modified: trunk/Source/WebCore/ChangeLog (154714 => 154715)


--- trunk/Source/WebCore/ChangeLog	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/ChangeLog	2013-08-28 00:09:16 UTC (rev 154715)
@@ -1,3 +1,18 @@
+2013-08-27  Andreas Kling  <[email protected]>
+
+        Make it less awkward to check if a Frame is the main Frame.
+        <https://webkit.org/b/120382>
+
+        Reviewed by Anders Carlsson.
+
+        Added Page::frameIsMainFrame(const Frame*) so code that wants to find out if a given
+        Frame is a Page's main frame doesn't have to do a manual pointer compare.
+
+        * page/Page.h:
+        (WebCore::Page::frameIsMainFrame):
+
+            Added. Replaces (frame == &page->mainFrame()) idiom.
+
 2013-08-27  Morten Stenshorne  <[email protected]>
 
         Improve multicol intrinsic width calculation

Modified: trunk/Source/WebCore/dom/Document.cpp (154714 => 154715)


--- trunk/Source/WebCore/dom/Document.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/dom/Document.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -1274,7 +1274,7 @@
         updateLayout();
 
     if (Page* page = this->page()) {
-        if (frame() == &page->mainFrame()) {
+        if (page->frameIsMainFrame(frame())) {
             frameView->addPaintPendingMilestones(DidFirstPaintAfterSuppressedIncrementalRendering);
             if (page->requestedLayoutMilestones() & DidFirstLayoutAfterSuppressedIncrementalRendering)
                 frame()->loader().didLayout(DidFirstLayoutAfterSuppressedIncrementalRendering);
@@ -2025,13 +2025,13 @@
     // FIXME: Doing this every time is a waste. If the current document and its
     // subframes' documents have no wheel event handlers, then the count did not change,
     // unless the documents they are replacing had wheel event handlers.
-    if (page() && &page()->mainFrame() == m_frame)
+    if (page() && page()->frameIsMainFrame(m_frame))
         pageWheelEventHandlerCountChanged(*page());
 
 #if ENABLE(TOUCH_EVENTS)
     // FIXME: Doing this only for the main frame is insufficient.
     // A subframe could have touch event handlers.
-    if (hasTouchEventHandlers() && page() && &page()->mainFrame() == m_frame)
+    if (hasTouchEventHandlers() && page() && page()->frameIsMainFrame(m_frame))
         page()->chrome().client().needTouchEvents(true);
 #endif
 
@@ -2955,7 +2955,7 @@
 
 void Document::updateViewportArguments()
 {
-    if (page() && &page()->mainFrame() == frame()) {
+    if (page() && page()->frameIsMainFrame(frame())) {
 #ifndef NDEBUG
         m_didDispatchViewportPropertiesChanged = true;
 #endif
@@ -4009,7 +4009,7 @@
             // function. It would be nice if there was more symmetry here.
             // https://bugs.webkit.org/show_bug.cgi?id=98698
             v->cacheCurrentScrollPosition();
-            if (page && &page->mainFrame() == m_frame) {
+            if (page && page->frameIsMainFrame(m_frame)) {
                 v->resetScrollbarsAndClearContentsSize();
                 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
                     scrollingCoordinator->clearStateTree();

Modified: trunk/Source/WebCore/history/CachedPage.cpp (154714 => 154715)


--- trunk/Source/WebCore/history/CachedPage.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/history/CachedPage.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -77,7 +77,7 @@
 void CachedPage::restore(Page* page)
 {
     ASSERT(m_cachedMainFrame);
-    ASSERT(page && &page->mainFrame() == &m_cachedMainFrame->view()->frame());
+    ASSERT(page && page->frameIsMainFrame(&m_cachedMainFrame->view()->frame()));
     ASSERT(!page->subframeCount());
 
     m_cachedMainFrame->open();

Modified: trunk/Source/WebCore/history/PageCache.cpp (154714 => 154715)


--- trunk/Source/WebCore/history/PageCache.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/history/PageCache.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -399,7 +399,7 @@
 {
     for (HistoryItem* current = m_head; current; current = current->m_next) {
         CachedPage* cachedPage = current->m_cachedPage.get();
-        if (&cachedPage->cachedMainFrame()->view()->frame() == &page->mainFrame())
+        if (page->frameIsMainFrame(&cachedPage->cachedMainFrame()->view()->frame()))
             cachedPage->markForFullStyleRecalc();
     }
 }
@@ -410,7 +410,7 @@
 {
     for (HistoryItem* current = m_head; current; current = current->m_next) {
         CachedPage* cachedPage = current->m_cachedPage.get();
-        if (&cachedPage->cachedMainFrame()->view()->frame() == &page->mainFrame())
+        if (page->frameIsMainFrame(&cachedPage->cachedMainFrame()->view()->frame()))
             cachedPage->markForDeviceScaleChanged();
     }
 }

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (154714 => 154715)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -603,7 +603,7 @@
         return;
     }
 
-    bool inMainFrame = document()->frame() == &document()->page()->mainFrame();
+    bool inMainFrame = document()->page()->frameIsMainFrame(document()->frame());
 
     if (document()->isPluginDocument() && inMainFrame) {
         LOG(Plugins, "%p Plug-in document in main frame", this);

Modified: trunk/Source/WebCore/html/ImageDocument.cpp (154714 => 154715)


--- trunk/Source/WebCore/html/ImageDocument.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/html/ImageDocument.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -373,7 +373,7 @@
 
 bool ImageDocument::shouldShrinkToFit() const
 {
-    return frame()->page()->settings().shrinksStandaloneImagesToFit() && &frame()->page()->mainFrame() == frame();
+    return frame()->settings().shrinksStandaloneImagesToFit() && frame()->page()->frameIsMainFrame(frame());
 }
 
 void ImageEventListener::handleEvent(ScriptExecutionContext*, Event* event)

Modified: trunk/Source/WebCore/inspector/InspectorAgent.cpp (154714 => 154715)


--- trunk/Source/WebCore/inspector/InspectorAgent.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/inspector/InspectorAgent.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -141,7 +141,7 @@
 
 bool InspectorAgent::isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl)
 {
-    return loader->frame() == &m_inspectedPage->mainFrame() && requestUrl == loader->requestURL();
+    return m_inspectedPage->frameIsMainFrame(loader->frame()) && requestUrl == loader->requestURL();
 }
 
 void InspectorAgent::evaluateForTestInFrontend(long callId, const String& script)

Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (154714 => 154715)


--- trunk/Source/WebCore/inspector/InspectorController.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -222,7 +222,7 @@
 
     // If the page is supposed to serve as InspectorFrontend notify inspector frontend
     // client that it's cleared so that the client can expose inspector bindings.
-    if (m_inspectorFrontendClient && frame == &m_page->mainFrame())
+    if (m_inspectorFrontendClient && m_page->frameIsMainFrame(frame))
         m_inspectorFrontendClient->windowObjectCleared();
 }
 

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (154714 => 154715)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -902,7 +902,7 @@
     if (!inspectorAgent || !inspectorAgent->developerExtrasEnabled())
         return;
 
-    if (loader->frame() == &page->mainFrame()) {
+    if (page->frameIsMainFrame(loader->frame())) {
         if (InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent())
             consoleAgent->reset();
 

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (154714 => 154715)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -868,7 +868,7 @@
     if (world != mainThreadNormalWorld())
         return;
 
-    if (frame == &m_page->mainFrame())
+    if (m_page->frameIsMainFrame(frame))
         m_injectedScriptManager->discardInjectedScripts();
 
     if (!m_frontend)
@@ -900,7 +900,7 @@
 
 void InspectorPageAgent::frameNavigated(DocumentLoader* loader)
 {
-    if (loader->frame() == &m_page->mainFrame()) {
+    if (m_page->frameIsMainFrame(loader->frame())) {
         m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce;
         m_scriptPreprocessor = m_pendingScriptPreprocessor;
         m_pendingScriptToEvaluateOnLoadOnce = String();

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (154714 => 154715)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -1959,7 +1959,7 @@
 {
     ASSERT(!m_frame.tree().parent());
     ASSERT(m_frame.page());
-    ASSERT(&m_frame.page()->mainFrame() == &m_frame);
+    ASSERT(m_frame.page()->frameIsMainFrame(&m_frame));
 
     m_frame.navigationScheduler().cancel();
 
@@ -2028,7 +2028,7 @@
 
 bool FrameLoader::isLoadingMainFrame() const
 {
-    return m_frame.page() && &m_frame.page()->mainFrame() == &m_frame;
+    return m_frame.page() && m_frame.page()->frameIsMainFrame(&m_frame);
 }
 
 bool FrameLoader::isReplacing() const
@@ -2178,7 +2178,7 @@
 
             m_progressTracker->progressCompleted();
             if (Page* page = m_frame.page()) {
-                if (&m_frame == &page->mainFrame())
+                if (page->frameIsMainFrame(&m_frame))
                     page->resetRelevantPaintedObjectCounter();
             }
 
@@ -2287,7 +2287,7 @@
 {
 #if !ASSERT_DISABLED
     if (Page* page = m_frame.page())
-        ASSERT(&page->mainFrame() == &m_frame);
+        ASSERT(page->frameIsMainFrame(&m_frame));
 #endif
 
     m_client.dispatchDidLayout(milestones);
@@ -2861,7 +2861,7 @@
 
 #if ENABLE(_javascript__DEBUGGER) && ENABLE(INSPECTOR)
     if (Page* page = m_frame.page()) {
-        if (&page->mainFrame() == &m_frame)
+        if (page->frameIsMainFrame(&m_frame))
             page->inspectorController()->resume();
     }
 #endif
@@ -3328,7 +3328,7 @@
 
     InspectorInstrumentation::didCommitLoad(&m_frame, m_documentLoader.get());
 
-    if (&m_frame.page()->mainFrame() == &m_frame)
+    if (m_frame.page()->frameIsMainFrame(&m_frame))
         m_frame.page()->featureObserver()->didCommitLoad();
 
 }

Modified: trunk/Source/WebCore/loader/HistoryController.cpp (154714 => 154715)


--- trunk/Source/WebCore/loader/HistoryController.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/loader/HistoryController.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -81,7 +81,7 @@
         item->setScrollPoint(m_frame.view()->scrollPosition());
 
     Page* page = m_frame.page();
-    if (page && &page->mainFrame() == &m_frame)
+    if (page && page->frameIsMainFrame(&m_frame))
         item->setPageScaleFactor(page->pageScaleFactor());
 
     // FIXME: It would be great to work out a way to put this code in WebCore instead of calling through to the client.
@@ -134,13 +134,13 @@
     // https://bugs.webkit.org/show_bug.cgi?id=98698
     if (FrameView* view = m_frame.view()) {
         Page* page = m_frame.page();
-        if (page && &page->mainFrame() == &m_frame) {
+        if (page && page->frameIsMainFrame(&m_frame)) {
             if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
                 scrollingCoordinator->frameViewRootLayerDidChange(view);
         }
 
         if (!view->wasScrolledByUser()) {
-            if (page && &page->mainFrame() == &m_frame && m_currentItem->pageScaleFactor())
+            if (page && page->frameIsMainFrame(&m_frame) && m_currentItem->pageScaleFactor())
                 page->setPageScaleFactor(m_currentItem->pageScaleFactor(), m_currentItem->scrollPoint());
             else
                 view->setScrollPosition(m_currentItem->scrollPoint());

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (154714 => 154715)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -231,7 +231,7 @@
     Page* page = frame->page();
     if (!page)
         return false;
-    return frame == &page->mainFrame();
+    return page->frameIsMainFrame(frame);
 }
 
 bool DOMWindow::dispatchAllPendingBeforeUnloadEvents()
@@ -931,7 +931,7 @@
     }
 
     // If we're a top level window, bring the window to the front.
-    if (m_frame == &page->mainFrame() && allowFocus)
+    if (page->frameIsMainFrame(m_frame) && allowFocus)
         page->chrome().focus();
 
     if (!m_frame)

Modified: trunk/Source/WebCore/page/Frame.cpp (154714 => 154715)


--- trunk/Source/WebCore/page/Frame.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/page/Frame.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -706,7 +706,7 @@
     ASSERT(this);
     ASSERT(m_page);
 
-    bool isMainFrame = this == &m_page->mainFrame();
+    bool isMainFrame = m_page->frameIsMainFrame(this);
 
     if (isMainFrame && view())
         view()->setParentVisible(false);
@@ -879,7 +879,7 @@
             view->layout();
     }
 
-    if (&page->mainFrame() == this)
+    if (page->frameIsMainFrame(this))
         pageCache()->markPagesForFullStyleRecalc(page);
 }
 

Modified: trunk/Source/WebCore/page/FrameView.cpp (154714 => 154715)


--- trunk/Source/WebCore/page/FrameView.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/page/FrameView.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -412,7 +412,7 @@
 
 bool FrameView::isMainFrameView() const
 {
-    return frame().page() && &frame().page()->mainFrame() == &frame();
+    return frame().page() && frame().page()->frameIsMainFrame(&frame());
 }
 
 bool FrameView::didFirstLayout() const
@@ -2742,8 +2742,9 @@
         }
     }
 
-    if (milestonesAchieved && page && &page->mainFrame() == &frame())
+    if (milestonesAchieved && page && page->frameIsMainFrame(&frame()))
         frame().loader().didLayout(milestonesAchieved);
+
 #if ENABLE(FONT_LOAD_EVENTS)
     if (RuntimeEnabledFeatures::fontLoadEventsEnabled())
         frame().document()->fontloader()->didLayout();

Modified: trunk/Source/WebCore/page/Page.h (154714 => 154715)


--- trunk/Source/WebCore/page/Page.h	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/page/Page.h	2013-08-28 00:09:16 UTC (rev 154715)
@@ -161,6 +161,7 @@
     PlugInClient* plugInClient() const { return m_plugInClient; }
 
     Frame& mainFrame() const { return *m_mainFrame; }
+    bool frameIsMainFrame(const Frame* frame) { return frame == m_mainFrame.get(); }
 
     bool openedByDOM() const;
     void setOpenedByDOM();

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (154714 => 154715)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -829,7 +829,7 @@
     if (node() != &document())
         return false;
     Page* page = frame().page();
-    return page && &page->mainFrame() == &frame() && view().frameView().isScrollable();
+    return page && page->frameIsMainFrame(&frame()) && view().frameView().isScrollable();
 }
 
 // If specified point is in border belt, returned offset denotes direction of

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (154714 => 154715)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2013-08-28 00:09:16 UTC (rev 154715)
@@ -121,7 +121,7 @@
 {
     if (layer->isRootLayer()) {
         Page* page = renderer().frame().page();
-        if (page && &page->mainFrame() == &renderer().frame()) {
+        if (page && page->frameIsMainFrame(&renderer().frame())) {
             m_isMainFrameRenderViewLayer = true;
 
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (154714 => 154715)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm	2013-08-28 00:09:16 UTC (rev 154715)
@@ -1065,7 +1065,7 @@
 {
     Frame* frame = core(m_webFrame.get());
     Page* page = frame->page();
-    BOOL forMainFrame = page && &page->mainFrame() == frame;
+    BOOL forMainFrame = page && page->frameIsMainFrame(frame);
     return [WebView _canHandleRequest:request.nsURLRequest(UpdateHTTPBody) forMainFrame:forMainFrame];
 }
 
@@ -1265,7 +1265,7 @@
     // If we own the view, delete the old one - otherwise the render m_frame will take care of deleting the view.
     Frame* coreFrame = core(m_webFrame.get());
     Page* page = coreFrame->page();
-    bool isMainFrame = coreFrame == &page->mainFrame();
+    bool isMainFrame = page->frameIsMainFrame(coreFrame);
     if (isMainFrame && coreFrame->view())
         coreFrame->view()->setParentVisible(false);
     coreFrame->setView(0);

Modified: trunk/Source/WebKit/mac/WebView/WebFrameView.mm (154714 => 154715)


--- trunk/Source/WebKit/mac/WebView/WebFrameView.mm	2013-08-27 23:17:15 UTC (rev 154714)
+++ trunk/Source/WebKit/mac/WebView/WebFrameView.mm	2013-08-28 00:09:16 UTC (rev 154715)
@@ -282,7 +282,7 @@
 
     // If this isn't the main frame, it must have an owner element set, or it
     // won't ever get installed in the view hierarchy.
-    ASSERT(frame == &frame->page()->mainFrame() || frame->ownerElement());
+    ASSERT(frame->page()->frameIsMainFrame(frame) || frame->ownerElement());
 
     FrameView* view = frame->view();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to