Title: [156922] trunk/Source/WebCore
Revision
156922
Author
[email protected]
Date
2013-10-04 15:49:40 -0700 (Fri, 04 Oct 2013)

Log Message

CTTE: SubframeLoader backpointer to Frame should be a reference.
<https://webkit.org/b/122350>

Reviewed by Anders Carlsson.

SubframeLoader is tied to the lifetime of FrameLoader, which in turn
is tied to the lifetime of Frame.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (156921 => 156922)


--- trunk/Source/WebCore/ChangeLog	2013-10-04 22:46:15 UTC (rev 156921)
+++ trunk/Source/WebCore/ChangeLog	2013-10-04 22:49:40 UTC (rev 156922)
@@ -1,3 +1,13 @@
+2013-10-04  Andreas Kling  <[email protected]>
+
+        CTTE: SubframeLoader backpointer to Frame should be a reference.
+        <https://webkit.org/b/122350>
+
+        Reviewed by Anders Carlsson.
+
+        SubframeLoader is tied to the lifetime of FrameLoader, which in turn
+        is tied to the lifetime of Frame.
+
 2013-10-04  Anders Carlsson  <[email protected]>
 
         Remove some unneeded code from WidgetMac

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (156921 => 156922)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2013-10-04 22:46:15 UTC (rev 156921)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2013-10-04 22:49:40 UTC (rev 156922)
@@ -217,7 +217,7 @@
     , m_policyChecker(adoptPtr(new PolicyChecker(&frame)))
     , m_history(adoptPtr(new HistoryController(frame)))
     , m_notifer(&frame)
-    , m_subframeLoader(adoptPtr(new SubframeLoader(&frame)))
+    , m_subframeLoader(adoptPtr(new SubframeLoader(frame)))
     , m_icon(adoptPtr(new IconController(&frame)))
     , m_mixedContentChecker(&frame)
     , m_state(FrameStateProvisional)

Modified: trunk/Source/WebCore/loader/SubframeLoader.cpp (156921 => 156922)


--- trunk/Source/WebCore/loader/SubframeLoader.cpp	2013-10-04 22:46:15 UTC (rev 156921)
+++ trunk/Source/WebCore/loader/SubframeLoader.cpp	2013-10-04 22:49:40 UTC (rev 156922)
@@ -64,7 +64,7 @@
     
 using namespace HTMLNames;
 
-SubframeLoader::SubframeLoader(Frame* frame)
+SubframeLoader::SubframeLoader(Frame& frame)
     : m_containsPlugins(false)
     , m_frame(frame)
 {
@@ -109,9 +109,9 @@
 bool SubframeLoader::pluginIsLoadable(HTMLPlugInImageElement* pluginElement, const URL& url, const String& mimeType)
 {
     if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType)) {
-        if (!m_frame->settings().isJavaEnabled())
+        if (!m_frame.settings().isJavaEnabled())
             return false;
-        if (document() && document()->securityOrigin()->isLocal() && !m_frame->settings().isJavaEnabledForLocalFiles())
+        if (document() && document()->securityOrigin()->isLocal() && !m_frame.settings().isJavaEnabledForLocalFiles())
             return false;
     }
 
@@ -120,7 +120,7 @@
             return false;
 
         if (!document()->securityOrigin()->canDisplay(url)) {
-            FrameLoader::reportLocalLoadFailed(m_frame, url.string());
+            FrameLoader::reportLocalLoadFailed(&m_frame, url.string());
             return false;
         }
 
@@ -134,7 +134,7 @@
             return false;
         }
 
-        if (!m_frame->loader().mixedContentChecker().canRunInsecureContent(document()->securityOrigin(), url))
+        if (!m_frame.loader().mixedContentChecker().canRunInsecureContent(document()->securityOrigin(), url))
             return false;
     }
 
@@ -246,12 +246,12 @@
     if (!url.isEmpty())
         completedURL = completeURL(url);
 
-    if (!m_frame->document()->securityOrigin()->canDisplay(completedURL)) {
+    if (!m_frame.document()->securityOrigin()->canDisplay(completedURL)) {
         FrameLoader::reportLocalLoadFailed(m_frame, completedURL.string());
         return 0;
     }
 
-    if (!m_frame->document()->contentSecurityPolicy()->allowMediaFromSource(completedURL))
+    if (!m_frame.document()->contentSecurityPolicy()->allowMediaFromSource(completedURL))
         return 0;
 
     HTMLMediaElement* mediaElement = toHTMLMediaElement(node);
@@ -263,10 +263,10 @@
     else if (mediaElement->isVideo())
         size = RenderVideo::defaultSize();
 
-    if (!m_frame->loader().mixedContentChecker().canRunInsecureContent(m_frame->document()->securityOrigin(), completedURL))
+    if (!m_frame.loader().mixedContentChecker().canRunInsecureContent(m_frame.document()->securityOrigin(), completedURL))
         return 0;
 
-    RefPtr<Widget> widget = m_frame->loader().client().createMediaPlayerProxyPlugin(size, mediaElement, completedURL,
+    RefPtr<Widget> widget = m_frame.loader().client().createMediaPlayerProxyPlugin(size, mediaElement, completedURL,
                                          paramNames, paramValues, "application/x-media-element-proxy-plugin");
 
     if (widget && renderer) {
@@ -294,7 +294,7 @@
     if (!codeBaseURLString.isEmpty()) {
         URL codeBaseURL = completeURL(codeBaseURLString);
         if (!element->document().securityOrigin()->canDisplay(codeBaseURL)) {
-            FrameLoader::reportLocalLoadFailed(m_frame, codeBaseURL.string());
+            FrameLoader::reportLocalLoadFailed(&m_frame, codeBaseURL.string());
             return 0;
         }
 
@@ -305,12 +305,12 @@
     }
 
     if (baseURLString.isEmpty())
-        baseURLString = m_frame->document()->baseURL().string();
+        baseURLString = m_frame.document()->baseURL().string();
     URL baseURL = completeURL(baseURLString);
 
     RefPtr<Widget> widget;
     if (allowPlugins(AboutToInstantiatePlugin))
-        widget = m_frame->loader().client().createJavaAppletWidget(size, element, baseURL, paramNames, paramValues);
+        widget = m_frame.loader().client().createJavaAppletWidget(size, element, baseURL, paramNames, paramValues);
 
     logPluginRequest(document()->page(), element->serviceType(), String(), widget);
 
@@ -330,9 +330,9 @@
 {
     Frame* frame = ownerElement->contentFrame();
     if (frame)
-        frame->navigationScheduler().scheduleLocationChange(m_frame->document()->securityOrigin(), url.string(), m_frame->loader().outgoingReferrer(), lockHistory, lockBackForwardList);
+        frame->navigationScheduler().scheduleLocationChange(m_frame.document()->securityOrigin(), url.string(), m_frame.loader().outgoingReferrer(), lockHistory, lockBackForwardList);
     else
-        frame = loadSubframe(ownerElement, url, frameName, m_frame->loader().outgoingReferrer());
+        frame = loadSubframe(ownerElement, url, frameName, m_frame.loader().outgoingReferrer());
 
     ASSERT(ownerElement->contentFrame() == frame || !ownerElement->contentFrame());
     return ownerElement->contentFrame();
@@ -340,7 +340,7 @@
 
 Frame* SubframeLoader::loadSubframe(HTMLFrameOwnerElement* ownerElement, const URL& url, const String& name, const String& referrer)
 {
-    RefPtr<Frame> protect(m_frame);
+    Ref<Frame> protect(m_frame);
 
     bool allowsScrolling = true;
     int marginWidth = -1;
@@ -353,15 +353,15 @@
     }
 
     if (!ownerElement->document().securityOrigin()->canDisplay(url)) {
-        FrameLoader::reportLocalLoadFailed(m_frame, url.string());
+        FrameLoader::reportLocalLoadFailed(&m_frame, url.string());
         return 0;
     }
 
     String referrerToUse = SecurityPolicy::generateReferrerHeader(ownerElement->document().referrerPolicy(), url, referrer);
-    RefPtr<Frame> frame = m_frame->loader().client().createFrame(url, name, ownerElement, referrerToUse, allowsScrolling, marginWidth, marginHeight);
+    RefPtr<Frame> frame = m_frame.loader().client().createFrame(url, name, ownerElement, referrerToUse, allowsScrolling, marginWidth, marginHeight);
 
     if (!frame)  {
-        m_frame->loader().checkCallImplicitClose();
+        m_frame.loader().checkCallImplicitClose();
         return 0;
     }
     
@@ -378,7 +378,7 @@
     if (renderer && renderer->isWidget() && view)
         toRenderWidget(renderer)->setWidget(view);
     
-    m_frame->loader().checkCallImplicitClose();
+    m_frame.loader().checkCallImplicitClose();
     
     // Some loads are performed synchronously (e.g., about:blank and loads
     // cancelled by returning a null ResourceRequest from requestFromDelegate).
@@ -397,28 +397,28 @@
 
 bool SubframeLoader::allowPlugins(ReasonForCallingAllowPlugins reason)
 {
-    bool allowed = m_frame->loader().client().allowPlugins(m_frame->settings().arePluginsEnabled());
+    bool allowed = m_frame.loader().client().allowPlugins(m_frame.settings().arePluginsEnabled());
     if (!allowed && reason == AboutToInstantiatePlugin)
-        m_frame->loader().client().didNotAllowPlugins();
+        m_frame.loader().client().didNotAllowPlugins();
     return allowed;
 }
 
 bool SubframeLoader::shouldUsePlugin(const URL& url, const String& mimeType, bool shouldPreferPlugInsForImages, bool hasFallback, bool& useFallback)
 {
-    if (m_frame->loader().client().shouldAlwaysUsePluginDocument(mimeType)) {
+    if (m_frame.loader().client().shouldAlwaysUsePluginDocument(mimeType)) {
         useFallback = false;
         return true;
     }
 
     // Allow other plug-ins to win over QuickTime because if the user has installed a plug-in that
     // can handle TIFF (which QuickTime can also handle) they probably intended to override QT.
-    if (m_frame->page() && (mimeType == "image/tiff" || mimeType == "image/tif" || mimeType == "image/x-tiff")) {
-        String pluginName = m_frame->page()->pluginData().pluginNameForMimeType(mimeType);
+    if (m_frame.page() && (mimeType == "image/tiff" || mimeType == "image/tif" || mimeType == "image/x-tiff")) {
+        String pluginName = m_frame.page()->pluginData().pluginNameForMimeType(mimeType);
         if (!pluginName.isEmpty() && !pluginName.contains("QuickTime", false)) 
             return true;
     }
         
-    ObjectContentType objectType = m_frame->loader().client().objectContentType(url, mimeType, shouldPreferPlugInsForImages);
+    ObjectContentType objectType = m_frame.loader().client().objectContentType(url, mimeType, shouldPreferPlugInsForImages);
     // If an object's content can't be handled and it has no fallback, let
     // it be handled as a plugin to show the broken plugin icon.
     useFallback = objectType == ObjectContentNone && hasFallback;
@@ -427,7 +427,7 @@
 
 Document* SubframeLoader::document() const
 {
-    return m_frame->document();
+    return m_frame.document();
 }
 
 bool SubframeLoader::loadPlugin(HTMLPlugInImageElement* pluginElement, const URL& url, const String& mimeType,
@@ -443,7 +443,7 @@
 
     IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), renderer->contentHeight()));
     bool loadManually = document()->isPluginDocument() && !m_containsPlugins && toPluginDocument(document())->shouldLoadPluginManually();
-    RefPtr<Widget> widget = m_frame->loader().client().createPlugin(contentSize,
+    RefPtr<Widget> widget = m_frame.loader().client().createPlugin(contentSize,
         pluginElement, url, paramNames, paramValues, mimeType, loadManually);
 
     if (!widget) {
@@ -464,8 +464,8 @@
 
 URL SubframeLoader::completeURL(const String& url) const
 {
-    ASSERT(m_frame->document());
-    return m_frame->document()->completeURL(url);
+    ASSERT(m_frame.document());
+    return m_frame.document()->completeURL(url);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/SubframeLoader.h (156921 => 156922)


--- trunk/Source/WebCore/loader/SubframeLoader.h	2013-10-04 22:46:15 UTC (rev 156921)
+++ trunk/Source/WebCore/loader/SubframeLoader.h	2013-10-04 22:49:40 UTC (rev 156922)
@@ -57,7 +57,7 @@
 class SubframeLoader {
     WTF_MAKE_NONCOPYABLE(SubframeLoader);
 public:
-    explicit SubframeLoader(Frame*);
+    explicit SubframeLoader(Frame&);
 
     void clear();
 
@@ -92,7 +92,7 @@
     Document* document() const;
 
     bool m_containsPlugins;
-    Frame* m_frame;
+    Frame& m_frame;
 
     URL completeURL(const String&) const;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to