Changeset 169820 in webkit
- Timestamp:
- Jun 11, 2014 12:59:24 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r169818 r169820 1 2014-06-11 Roger Fong <roger_fong@apple.com> 2 3 Don't snapshot offscreen plugins that would normally be considered primary plugins after they are moved in view. 4 https://bugs.webkit.org/show_bug.cgi?id=133667. 5 <rdar://problem/16743250> 6 7 Reviewed by Tim Horton. 8 9 * WebProcess/Plugins/PluginView.cpp: 10 (WebKit::PluginView::PluginView): 11 (WebKit::PluginView::pluginSnapshotTimerFired): 12 Set the display state to Playing if the following is true: 13 The plugin in question is large enough to be considered the primary snapshot and either: 14 a) The maximum number of snapshot retries has been reached and no good snapshot has been found. 15 b) The plugin is moved to be on-screen while the snapshot attempts are in progress. 16 * WebProcess/Plugins/PluginView.h: 17 * WebProcess/WebPage/WebPage.cpp: 18 (WebKit::WebPage::plugInIntersectsSearchRect): Re-factor out intersection logic. 19 (WebKit::WebPage::plugInIsPrimarySize): Re-factor out primary plugin size logic. 20 (WebKit::WebPage::determinePrimarySnapshottedPlugIn): Use the above two methods here. 21 * WebProcess/WebPage/WebPage.h: 22 1 23 2014-06-11 Anders Carlsson <andersca@apple.com> 2 24 -
trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
r169724 r169820 287 287 , m_isBeingDestroyed(false) 288 288 , m_pluginProcessHasCrashed(false) 289 , m_didPlugInStartOffScreen(false) 289 290 , m_pendingURLRequestsTimer(RunLoop::main(), this, &PluginView::pendingURLRequestsTimerFired) 290 291 #if ENABLE(NETSCAPE_PLUGIN_API) … … 1689 1690 ASSERT(m_plugin); 1690 1691 1692 HTMLPlugInImageElement* plugInImageElement = toHTMLPlugInImageElement(m_pluginElement.get()); 1693 bool isPlugInOnScreen = m_webPage->plugInIntersectsSearchRect(*plugInImageElement); 1694 if (!m_countSnapshotRetries) 1695 m_didPlugInStartOffScreen = !isPlugInOnScreen; 1696 1697 bool plugInCameOnScreen = isPlugInOnScreen && m_didPlugInStartOffScreen; 1698 bool snapshotFound = false; 1699 1691 1700 if (m_plugin->supportsSnapshotting()) { 1692 1701 // Snapshot might be 0 if plugin size is 0x0. … … 1696 1705 snapshotImage = snapshot->createImage(); 1697 1706 m_pluginElement->updateSnapshot(snapshotImage.get()); 1707 bool snapshotIsAlmostSolidColor = isAlmostSolidColor(toBitmapImage(snapshotImage.get())); 1708 snapshotFound = snapshotImage && !snapshotIsAlmostSolidColor; 1698 1709 1699 1710 #if PLATFORM(COCOA) 1700 1711 unsigned maximumSnapshotRetries = frame() ? frame()->settings().maximumPlugInSnapshotAttempts() : 0; 1701 if (snapshotImage && isAlmostSolidColor(toBitmapImage(snapshotImage.get())) && m_countSnapshotRetries < maximumSnapshotRetries) {1712 if (snapshotImage && snapshotIsAlmostSolidColor && m_countSnapshotRetries < maximumSnapshotRetries && !plugInCameOnScreen) { 1702 1713 ++m_countSnapshotRetries; 1703 1714 m_pluginSnapshotTimer.restart(); … … 1706 1717 #endif 1707 1718 } 1708 // Even if there is no snapshot we still set the state to DisplayingSnapshot 1709 // since we just want to display the default empty box. 1710 m_pluginElement->setDisplayState(HTMLPlugInElement::DisplayingSnapshot); 1719 unsigned candidateArea = 0; 1720 bool noSnapshotFoundAfterMaxRetries = m_countSnapshotRetries == frame()->settings().maximumPlugInSnapshotAttempts() && !isPlugInOnScreen && !snapshotFound; 1721 if (m_webPage->plugInIsPrimarySize(*plugInImageElement, candidateArea) 1722 && (noSnapshotFoundAfterMaxRetries || plugInCameOnScreen)) 1723 m_pluginElement->setDisplayState(HTMLPlugInElement::Playing); 1724 else 1725 m_pluginElement->setDisplayState(HTMLPlugInElement::DisplayingSnapshot); 1711 1726 } 1712 1727 -
trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h
r169724 r169820 239 239 bool m_isBeingDestroyed; 240 240 bool m_pluginProcessHasCrashed; 241 bool m_didPlugInStartOffScreen; 241 242 242 243 // Pending URLRequests that the plug-in has made. -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r169799 r169820 4473 4473 continue; 4474 4474 auto& pluginRenderBox = toRenderBox(*pluginRenderer); 4475 if (!plugInIntersectsSearchRect(plugInImageElement)) 4476 continue; 4477 4475 4478 IntRect plugInRectRelativeToView = plugInImageElement.clientRect(); 4476 if (plugInRectRelativeToView.isEmpty())4477 continue;4478 4479 IntSize scrollOffset = mainFrame.view()->documentScrollOffsetRelativeToViewOrigin(); 4479 4480 IntRect plugInRectRelativeToTopDocument(plugInRectRelativeToView.location() + scrollOffset, plugInRectRelativeToView.size()); 4480 if (!plugInRectRelativeToTopDocument.intersects(searchRect))4481 continue;4482 4483 4481 HitTestResult hitTestResult(plugInRectRelativeToTopDocument.center()); 4484 4482 mainRenderView.hitTest(request, hitTestResult); … … 4505 4503 plugInImageElement.restartSnapshottedPlugIn(); 4506 4504 } 4507 if (pluginRenderBox.contentWidth() < primarySnapshottedPlugInMinimumWidth || pluginRenderBox.contentHeight() < primarySnapshottedPlugInMinimumHeight) 4508 continue; 4509 4510 LayoutUnit contentArea = pluginRenderBox.contentWidth() * pluginRenderBox.contentHeight(); 4511 if (contentArea > candidatePlugInArea * primarySnapshottedPlugInSearchBucketSize) { 4505 4506 if (plugInIsPrimarySize(plugInImageElement, candidatePlugInArea)) 4512 4507 candidatePlugIn = &plugInImageElement; 4513 candidatePlugInArea = contentArea;4514 }4515 4508 } 4516 4509 } … … 4547 4540 4548 4541 return (pageOrigin == m_primaryPlugInPageOrigin && pluginOrigin == m_primaryPlugInOrigin && mimeType == m_primaryPlugInMimeType); 4542 } 4543 4544 bool WebPage::plugInIntersectsSearchRect(HTMLPlugInImageElement& plugInImageElement) 4545 { 4546 MainFrame& mainFrame = corePage()->mainFrame(); 4547 if (!mainFrame.view()) 4548 return false; 4549 if (!mainFrame.view()->renderView()) 4550 return false; 4551 4552 IntRect searchRect = IntRect(IntPoint(), corePage()->mainFrame().view()->contentsSize()); 4553 searchRect.intersect(IntRect(IntPoint(), IntSize(primarySnapshottedPlugInSearchLimit, primarySnapshottedPlugInSearchLimit))); 4554 4555 IntRect plugInRectRelativeToView = plugInImageElement.clientRect(); 4556 if (plugInRectRelativeToView.isEmpty()) 4557 return false; 4558 IntSize scrollOffset = mainFrame.view()->documentScrollOffsetRelativeToViewOrigin(); 4559 IntRect plugInRectRelativeToTopDocument(plugInRectRelativeToView.location() + scrollOffset, plugInRectRelativeToView.size()); 4560 4561 return plugInRectRelativeToTopDocument.intersects(searchRect); 4562 } 4563 4564 bool WebPage::plugInIsPrimarySize(WebCore::HTMLPlugInImageElement& plugInImageElement, unsigned& candidatePlugInArea) 4565 { 4566 auto& pluginRenderBox = toRenderBox(*(plugInImageElement.renderer())); 4567 if (pluginRenderBox.contentWidth() < primarySnapshottedPlugInMinimumWidth || pluginRenderBox.contentHeight() < primarySnapshottedPlugInMinimumHeight) 4568 return false; 4569 4570 LayoutUnit contentArea = pluginRenderBox.contentWidth() * pluginRenderBox.contentHeight(); 4571 if (contentArea > candidatePlugInArea * primarySnapshottedPlugInSearchBucketSize) { 4572 candidatePlugInArea = contentArea; 4573 return true; 4574 } 4575 return false; 4549 4576 } 4550 4577 #endif // ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r169799 r169820 119 119 class FrameView; 120 120 class HTMLPlugInElement; 121 class HTMLPlugInImageElement; 121 122 class IntPoint; 122 123 class KeyboardEvent; … … 792 793 void resetPrimarySnapshottedPlugIn(); 793 794 bool matchesPrimaryPlugIn(const String& pageOrigin, const String& pluginOrigin, const String& mimeType) const; 795 bool plugInIntersectsSearchRect(WebCore::HTMLPlugInImageElement& pluginImageElement); 796 bool plugInIsPrimarySize(WebCore::HTMLPlugInImageElement& pluginImageElement, unsigned &pluginArea); 794 797 #endif 795 798
Note: See TracChangeset
for help on using the changeset viewer.