Changeset 158962 in webkit
- Timestamp:
- Nov 8, 2013 3:23:16 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r158961 r158962 1 2013-11-08 Sam Weinig <sam@webkit.org> 2 3 Teach SubframeLoader a bit about references 4 https://bugs.webkit.org/show_bug.cgi?id=124076 5 6 Reviewed by Anders Carlsson. 7 8 * html/HTMLAppletElement.cpp: 9 * html/HTMLFrameElementBase.cpp: 10 * html/HTMLMediaElement.cpp: 11 * loader/SubframeLoader.cpp: 12 * loader/SubframeLoader.h: 13 1 14 2013-11-08 Brady Eidson <beidson@apple.com> 2 15 -
trunk/Source/WebCore/html/HTMLAppletElement.cpp
r158163 r158962 161 161 ASSERT(frame); 162 162 163 renderer->setWidget(frame->loader().subframeLoader().createJavaAppletWidget(roundedIntSize(LayoutSize(contentWidth, contentHeight)), this, paramNames, paramValues));163 renderer->setWidget(frame->loader().subframeLoader().createJavaAppletWidget(roundedIntSize(LayoutSize(contentWidth, contentHeight)), *this, paramNames, paramValues)); 164 164 } 165 165 -
trunk/Source/WebCore/html/HTMLFrameElementBase.cpp
r156903 r158962 87 87 return; 88 88 89 parentFrame->loader().subframeLoader().requestFrame( this, m_URL, m_frameName, lockHistory, lockBackForwardList);89 parentFrame->loader().subframeLoader().requestFrame(*this, m_URL, m_frameName, lockHistory, lockBackForwardList); 90 90 if (contentFrame()) 91 91 contentFrame()->setInViewSourceMode(viewSourceMode()); -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r158874 r158962 4382 4382 // Hang onto the proxy widget so it won't be destroyed if the plug-in is set to 4383 4383 // display:none 4384 m_proxyWidget = frame->loader().subframeLoader().loadMediaPlayerProxyPlugin( this, url, paramNames, paramValues);4384 m_proxyWidget = frame->loader().subframeLoader().loadMediaPlayerProxyPlugin(*this, url, paramNames, paramValues); 4385 4385 if (m_proxyWidget) 4386 4386 m_needWidgetUpdate = false; … … 4399 4399 // FIXME: What if document().frame() is 0? 4400 4400 SubframeLoader& loader = document().frame()->loader().subframeLoader(); 4401 loader.loadMediaPlayerProxyPlugin( mediaElement, kurl, paramNames, paramValues);4401 loader.loadMediaPlayerProxyPlugin(*mediaElement, kurl, paramNames, paramValues); 4402 4402 } 4403 4403 -
trunk/Source/WebCore/loader/SubframeLoader.cpp
r158657 r158962 76 76 } 77 77 78 bool SubframeLoader::requestFrame(HTMLFrameOwnerElement *ownerElement, const String& urlString, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList)78 bool SubframeLoader::requestFrame(HTMLFrameOwnerElement& ownerElement, const String& urlString, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList) 79 79 { 80 80 // Support for <frame src="javascript:string"> … … 107 107 } 108 108 109 bool SubframeLoader::pluginIsLoadable(HTMLPlugInImageElement *pluginElement, const URL& url, const String& mimeType)109 bool SubframeLoader::pluginIsLoadable(HTMLPlugInImageElement& pluginElement, const URL& url, const String& mimeType) 110 110 { 111 111 if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType)) { … … 127 127 String declaredMimeType = document()->isPluginDocument() && document()->ownerElement() ? 128 128 document()->ownerElement()->fastGetAttribute(HTMLNames::typeAttr) : 129 pluginElement ->fastGetAttribute(HTMLNames::typeAttr);129 pluginElement.fastGetAttribute(HTMLNames::typeAttr); 130 130 if (!document()->contentSecurityPolicy()->allowObjectFromSource(url) 131 131 || !document()->contentSecurityPolicy()->allowPluginType(mimeType, declaredMimeType, url)) { 132 RenderEmbeddedObject* renderer = pluginElement ->renderEmbeddedObject();132 RenderEmbeddedObject* renderer = pluginElement.renderEmbeddedObject(); 133 133 renderer->setPluginUnavailabilityReason(RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy); 134 134 return false; … … 142 142 } 143 143 144 bool SubframeLoader::requestPlugin(HTMLPlugInImageElement *ownerElement, const URL& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback)144 bool SubframeLoader::requestPlugin(HTMLPlugInImageElement& ownerElement, const URL& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback) 145 145 { 146 146 // Application plug-ins are plug-ins implemented by the user agent, for example Qt plug-ins, … … 153 153 return false; 154 154 155 ASSERT(ownerElement ->hasTagName(objectTag) || ownerElement->hasTagName(embedTag));155 ASSERT(ownerElement.hasTagName(objectTag) || ownerElement.hasTagName(embedTag)); 156 156 return loadPlugin(ownerElement, url, mimeType, paramNames, paramValues, useFallback); 157 157 } … … 222 222 bool useFallback; 223 223 if (shouldUsePlugin(completedURL, mimeType, ownerElement.shouldPreferPlugInsForImages(), hasFallbackContent, useFallback)) { 224 bool success = requestPlugin( &ownerElement, completedURL, mimeType, paramNames, paramValues, useFallback);224 bool success = requestPlugin(ownerElement, completedURL, mimeType, paramNames, paramValues, useFallback); 225 225 logPluginRequest(document()->page(), mimeType, completedURL, success); 226 226 return success; … … 230 230 // it will create a new frame and set it as the RenderWidget's Widget, causing what was previously 231 231 // in the widget to be torn down. 232 return loadOrRedirectSubframe( &ownerElement, completedURL, frameName, true, true);232 return loadOrRedirectSubframe(ownerElement, completedURL, frameName, true, true); 233 233 } 234 234 235 235 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) 236 PassRefPtr<Widget> SubframeLoader::loadMediaPlayerProxyPlugin(Node* node, const URL& url, 237 const Vector<String>& paramNames, const Vector<String>& paramValues) 238 { 239 ASSERT(node->hasTagName(videoTag) || isHTMLAudioElement(node)); 236 PassRefPtr<Widget> SubframeLoader::loadMediaPlayerProxyPlugin(HTMLMediaElement& mediaElement, const URL& url, const Vector<String>& paramNames, const Vector<String>& paramValues) 237 { 238 ASSERT(mediaElement.hasTagName(videoTag) || isHTMLAudioElement(mediaElement)); 240 239 241 240 URL completedURL; … … 245 244 if (!m_frame.document()->securityOrigin()->canDisplay(completedURL)) { 246 245 FrameLoader::reportLocalLoadFailed(m_frame, completedURL.string()); 247 return 0;246 return nullptr; 248 247 } 249 248 250 249 if (!m_frame.document()->contentSecurityPolicy()->allowMediaFromSource(completedURL)) 251 return 0; 252 253 HTMLMediaElement* mediaElement = toHTMLMediaElement(node); 254 RenderWidget* renderer = toRenderWidget(node->renderer()); 250 return nullptr; 251 252 RenderWidget* renderer = toRenderWidget(mediaElement.renderer()); 255 253 IntSize size; 256 254 257 255 if (renderer) 258 256 size = roundedIntSize(LayoutSize(renderer->contentWidth(), renderer->contentHeight())); 259 else if (mediaElement ->isVideo())257 else if (mediaElement.isVideo()) 260 258 size = RenderVideo::defaultSize(); 261 259 262 260 if (!m_frame.loader().mixedContentChecker().canRunInsecureContent(m_frame.document()->securityOrigin(), completedURL)) 263 return 0; 264 265 RefPtr<Widget> widget = m_frame.loader().client().createMediaPlayerProxyPlugin(size, mediaElement, completedURL, 266 paramNames, paramValues, "application/x-media-element-proxy-plugin"); 261 return nullptr; 262 263 RefPtr<Widget> widget = m_frame.loader().client().createMediaPlayerProxyPlugin(size, &mediaElement, completedURL, paramNames, paramValues, "application/x-media-element-proxy-plugin"); 267 264 268 265 if (widget && renderer) { … … 272 269 m_containsPlugins = true; 273 270 274 return widget ? widget.release() : 0;271 return widget ? widget.release() : nullptr; 275 272 } 276 273 #endif // ENABLE(PLUGIN_PROXY_FOR_VIDEO) 277 274 278 PassRefPtr<Widget> SubframeLoader::createJavaAppletWidget(const IntSize& size, HTMLAppletElement *element, const Vector<String>& paramNames, const Vector<String>& paramValues)275 PassRefPtr<Widget> SubframeLoader::createJavaAppletWidget(const IntSize& size, HTMLAppletElement& element, const Vector<String>& paramNames, const Vector<String>& paramValues) 279 276 { 280 277 String baseURLString; … … 290 287 if (!codeBaseURLString.isEmpty()) { 291 288 URL codeBaseURL = completeURL(codeBaseURLString); 292 if (!element ->document().securityOrigin()->canDisplay(codeBaseURL)) {289 if (!element.document().securityOrigin()->canDisplay(codeBaseURL)) { 293 290 FrameLoader::reportLocalLoadFailed(&m_frame, codeBaseURL.string()); 294 return 0;291 return nullptr; 295 292 } 296 293 297 294 const char javaAppletMimeType[] = "application/x-java-applet"; 298 if (!element ->document().contentSecurityPolicy()->allowObjectFromSource(codeBaseURL)299 || !element ->document().contentSecurityPolicy()->allowPluginType(javaAppletMimeType, javaAppletMimeType, codeBaseURL))300 return 0;295 if (!element.document().contentSecurityPolicy()->allowObjectFromSource(codeBaseURL) 296 || !element.document().contentSecurityPolicy()->allowPluginType(javaAppletMimeType, javaAppletMimeType, codeBaseURL)) 297 return nullptr; 301 298 } 302 299 … … 307 304 RefPtr<Widget> widget; 308 305 if (allowPlugins(AboutToInstantiatePlugin)) 309 widget = m_frame.loader().client().createJavaAppletWidget(size, element, baseURL, paramNames, paramValues);310 311 logPluginRequest(document()->page(), element ->serviceType(), String(), widget);306 widget = m_frame.loader().client().createJavaAppletWidget(size, &element, baseURL, paramNames, paramValues); 307 308 logPluginRequest(document()->page(), element.serviceType(), String(), widget); 312 309 313 310 if (!widget) { 314 RenderEmbeddedObject* renderer = element ->renderEmbeddedObject();311 RenderEmbeddedObject* renderer = element.renderEmbeddedObject(); 315 312 316 313 if (!renderer->isPluginUnavailable()) 317 314 renderer->setPluginUnavailabilityReason(RenderEmbeddedObject::PluginMissing); 318 return 0;315 return nullptr; 319 316 } 320 317 … … 323 320 } 324 321 325 Frame* SubframeLoader::loadOrRedirectSubframe(HTMLFrameOwnerElement *ownerElement, const URL& url, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList)326 { 327 Frame* frame = ownerElement ->contentFrame();322 Frame* SubframeLoader::loadOrRedirectSubframe(HTMLFrameOwnerElement& ownerElement, const URL& url, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList) 323 { 324 Frame* frame = ownerElement.contentFrame(); 328 325 if (frame) 329 326 frame->navigationScheduler().scheduleLocationChange(m_frame.document()->securityOrigin(), url.string(), m_frame.loader().outgoingReferrer(), lockHistory, lockBackForwardList); … … 331 328 frame = loadSubframe(ownerElement, url, frameName, m_frame.loader().outgoingReferrer()); 332 329 333 ASSERT(ownerElement ->contentFrame() == frame || !ownerElement->contentFrame());334 return ownerElement ->contentFrame();335 } 336 337 Frame* SubframeLoader::loadSubframe(HTMLFrameOwnerElement *ownerElement, const URL& url, const String& name, const String& referrer)330 ASSERT(ownerElement.contentFrame() == frame || !ownerElement.contentFrame()); 331 return ownerElement.contentFrame(); 332 } 333 334 Frame* SubframeLoader::loadSubframe(HTMLFrameOwnerElement& ownerElement, const URL& url, const String& name, const String& referrer) 338 335 { 339 336 Ref<Frame> protect(m_frame); … … 342 339 int marginWidth = -1; 343 340 int marginHeight = -1; 344 if (ownerElement ->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag)) {345 HTMLFrameElementBase *frameElementBase = toHTMLFrameElementBase(ownerElement);346 allowsScrolling = frameElementBase ->scrollingMode() != ScrollbarAlwaysOff;347 marginWidth = frameElementBase ->marginWidth();348 marginHeight = frameElementBase ->marginHeight();349 } 350 351 if (!ownerElement ->document().securityOrigin()->canDisplay(url)) {341 if (ownerElement.hasTagName(frameTag) || ownerElement.hasTagName(iframeTag)) { 342 HTMLFrameElementBase& frameElementBase = toHTMLFrameElementBase(ownerElement); 343 allowsScrolling = frameElementBase.scrollingMode() != ScrollbarAlwaysOff; 344 marginWidth = frameElementBase.marginWidth(); 345 marginHeight = frameElementBase.marginHeight(); 346 } 347 348 if (!ownerElement.document().securityOrigin()->canDisplay(url)) { 352 349 FrameLoader::reportLocalLoadFailed(&m_frame, url.string()); 353 return 0;354 } 355 356 String referrerToUse = SecurityPolicy::generateReferrerHeader(ownerElement ->document().referrerPolicy(), url, referrer);357 RefPtr<Frame> frame = m_frame.loader().client().createFrame(url, name, ownerElement, referrerToUse, allowsScrolling, marginWidth, marginHeight);350 return nullptr; 351 } 352 353 String referrerToUse = SecurityPolicy::generateReferrerHeader(ownerElement.document().referrerPolicy(), url, referrer); 354 RefPtr<Frame> frame = m_frame.loader().client().createFrame(url, name, &ownerElement, referrerToUse, allowsScrolling, marginWidth, marginHeight); 358 355 359 356 if (!frame) { 360 357 m_frame.loader().checkCallImplicitClose(); 361 return 0;358 return nullptr; 362 359 } 363 360 … … 370 367 frame->loader().started(); 371 368 372 RenderObject* renderer = ownerElement ->renderer();369 RenderObject* renderer = ownerElement.renderer(); 373 370 FrameView* view = frame->view(); 374 371 if (renderer && renderer->isWidget() && view) … … 424 421 } 425 422 426 bool SubframeLoader::loadPlugin(HTMLPlugInImageElement* pluginElement, const URL& url, const String& mimeType, 427 const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback) 428 { 429 RenderEmbeddedObject* renderer = pluginElement->renderEmbeddedObject(); 423 bool SubframeLoader::loadPlugin(HTMLPlugInImageElement& pluginElement, const URL& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback) 424 { 425 RenderEmbeddedObject* renderer = pluginElement.renderEmbeddedObject(); 430 426 431 427 // FIXME: This code should not depend on renderer! … … 433 429 return false; 434 430 435 pluginElement ->subframeLoaderWillCreatePlugIn(url);431 pluginElement.subframeLoaderWillCreatePlugIn(url); 436 432 437 433 IntSize contentSize = roundedIntSize(LayoutSize(renderer->contentWidth(), renderer->contentHeight())); 438 434 bool loadManually = document()->isPluginDocument() && !m_containsPlugins && toPluginDocument(document())->shouldLoadPluginManually(); 439 RefPtr<Widget> widget = m_frame.loader().client().createPlugin(contentSize, 440 pluginElement, url, paramNames, paramValues, mimeType, loadManually); 435 RefPtr<Widget> widget = m_frame.loader().client().createPlugin(contentSize, &pluginElement, url, paramNames, paramValues, mimeType, loadManually); 441 436 442 437 if (!widget) { … … 446 441 } 447 442 448 pluginElement ->subframeLoaderDidCreatePlugIn(widget.get());443 pluginElement.subframeLoaderDidCreatePlugIn(widget.get()); 449 444 renderer->setWidget(widget); 450 445 m_containsPlugins = true; -
trunk/Source/WebCore/loader/SubframeLoader.h
r158657 r158962 46 46 class HTMLAppletElement; 47 47 class HTMLFrameOwnerElement; 48 class HTMLMediaElement; 48 49 class HTMLPlugInImageElement; 49 50 class IntSize; 50 51 class URL; 51 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)52 class Node;53 #endif54 52 class Widget; 55 53 … … 62 60 void clear(); 63 61 64 bool requestFrame(HTMLFrameOwnerElement *, const String& url, const AtomicString& frameName, bool lockHistory = true, bool lockBackForwardList = true);62 bool requestFrame(HTMLFrameOwnerElement&, const String& url, const AtomicString& frameName, bool lockHistory = true, bool lockBackForwardList = true); 65 63 bool requestObject(HTMLPlugInImageElement&, const String& url, const AtomicString& frameName, 66 64 const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues); 67 65 68 66 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) 69 // FIXME: This should take Element* instead of Node*, or better yet the 70 // specific type of Element which this code depends on. 71 PassRefPtr<Widget> loadMediaPlayerProxyPlugin(Node*, const URL&, const Vector<String>& paramNames, const Vector<String>& paramValues); 67 PassRefPtr<Widget> loadMediaPlayerProxyPlugin(HTMLMediaElement&, const URL&, const Vector<String>& paramNames, const Vector<String>& paramValues); 72 68 #endif 73 69 74 PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement *, const Vector<String>& paramNames, const Vector<String>& paramValues);70 PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement&, const Vector<String>& paramNames, const Vector<String>& paramValues); 75 71 76 72 bool allowPlugins(ReasonForCallingAllowPlugins); … … 81 77 82 78 private: 83 bool requestPlugin(HTMLPlugInImageElement*, const URL&, const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback); 84 Frame* loadOrRedirectSubframe(HTMLFrameOwnerElement*, const URL&, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList); 85 Frame* loadSubframe(HTMLFrameOwnerElement*, const URL&, const String& name, const String& referrer); 86 bool loadPlugin(HTMLPlugInImageElement*, const URL&, const String& mimeType, 87 const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback); 79 bool requestPlugin(HTMLPlugInImageElement&, const URL&, const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback); 80 Frame* loadOrRedirectSubframe(HTMLFrameOwnerElement&, const URL&, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList); 81 Frame* loadSubframe(HTMLFrameOwnerElement&, const URL&, const String& name, const String& referrer); 82 bool loadPlugin(HTMLPlugInImageElement&, const URL&, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback); 88 83 89 84 bool shouldUsePlugin(const URL&, const String& mimeType, bool shouldPreferPlugInsForImages, bool hasFallback, bool& useFallback); 90 bool pluginIsLoadable(HTMLPlugInImageElement *, const URL&, const String& mimeType);85 bool pluginIsLoadable(HTMLPlugInImageElement&, const URL&, const String& mimeType); 91 86 92 87 Document* document() const;
Note: See TracChangeset
for help on using the changeset viewer.