Changeset 145332 in webkit
- Timestamp:
- Mar 10, 2013 1:40:47 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r145331 r145332 1 2013-03-10 Tim Horton <timothy_horton@apple.com> 2 3 Add a heuristic to determine the “primary” snapshotted plugin 4 https://bugs.webkit.org/show_bug.cgi?id=111932 5 <rdar://problem/13270208> 6 7 Reviewed by Dean Jackson. 8 9 * WebCore.exp.in: Export a few things. 10 * html/HTMLPlugInImageElement.cpp: 11 (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): 12 (WebCore::classNameForShadowRoot): If we've been informed that we are the primary snapshotted plugin, add the 'primary' class. 13 (WebCore::HTMLPlugInImageElement::setIsPrimarySnapshottedPlugIn): Added 14 (WebCore::HTMLPlugInImageElement::updateSnapshotInfo): Hand classNameForShadowRoot our primary-ness. 15 * html/HTMLPlugInImageElement.h: 16 (HTMLPlugInImageElement): Add storage for m_isPrimarySnapshottedPlugIn. 17 1 18 2013-03-10 Mike West <mkwst@chromium.org> 2 19 -
trunk/Source/WebCore/WebCore.exp.in
r145303 r145332 77 77 __ZN7WebCore10MouseEventC1ERKN3WTF12AtomicStringEbbNS1_10PassRefPtrINS_9DOMWindowEEEiiiiibbbbtNS5_INS_11EventTargetEEENS5_INS_9ClipboardEEEb 78 78 __ZN7WebCore10RenderView10compositorEv 79 __ZN7WebCore10RenderView7hitTestERKNS_14HitTestRequestERNS_13HitTestResultE 79 80 __ZN7WebCore10ScrollView17setUseFixedLayoutEb 80 81 __ZN7WebCore10ScrollView18setFixedLayoutSizeERKNS_7IntSizeE … … 249 250 __ZN7WebCore13HTTPHeaderMapD1Ev 250 251 __ZN7WebCore13HitTestResultC1ERKS0_ 252 __ZN7WebCore13HitTestResultC1ERKNS_11LayoutPointE 251 253 __ZN7WebCore13HitTestResultD1Ev 252 254 __ZN7WebCore13IdentifierRep3getEPKc … … 674 676 __ZN7WebCore22systemMarketingVersionEv 675 677 __ZN7WebCore22userPreferredLanguagesEv 678 __ZN7WebCore22HTMLPlugInImageElement29setIsPrimarySnapshottedPlugInEb 676 679 __ZN7WebCore23ApplicationCacheStorage14setMaximumSizeEx 677 680 __ZN7WebCore23ApplicationCacheStorage16deleteAllEntriesEv … … 1255 1258 __ZNK7WebCore13HitTestResult11targetFrameEv 1256 1259 __ZNK7WebCore13HitTestResult11textContentEv 1260 __ZNK7WebCore13HitTestResult12innerElementEv 1257 1261 __ZNK7WebCore13HitTestResult14absolutePDFURLEv 1258 1262 __ZNK7WebCore13HitTestResult14innerNodeFrameEv … … 1432 1436 __ZNK7WebCore4Page10pluginDataEv 1433 1437 __ZNK7WebCore4Page14renderTreeSizeEv 1438 __ZNK7WebCore4Page16hasSeenAnyPluginEv 1434 1439 __ZNK7WebCore4Page15backForwardListEv 1435 1440 __ZNK7WebCore4Page17viewportArgumentsEv … … 1548 1553 #endif 1549 1554 __ZNK7WebCore9PageCache10frameCountEv 1555 __ZNK7WebCore9RenderBox12clientHeightEv 1556 __ZNK7WebCore9RenderBox11clientWidthEv 1550 1557 __ZTVN7WebCore12ChromeClientE 1551 1558 __ZTVN7WebCore14LoaderStrategyE -
trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp
r144690 r145332 72 72 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPreferPlugInsForImages) 73 73 , m_needsDocumentActivationCallbacks(false) 74 , m_isPrimarySnapshottedPlugIn(false) 74 75 , m_simulatedMouseClickTimer(this, &HTMLPlugInImageElement::simulatedMouseClickTimerFired, simulatedMouseClickTimerDelay) 75 76 , m_swapRendererTimer(this, &HTMLPlugInImageElement::swapRendererTimerFired) … … 296 297 } 297 298 298 static AtomicString classNameForShadowRoot(const Node* node )299 static AtomicString classNameForShadowRoot(const Node* node, bool isPrimary) 299 300 { 300 301 DEFINE_STATIC_LOCAL(const AtomicString, plugInTinySizeClassName, ("tiny", AtomicString::ConstructFromLiteral)); … … 302 303 DEFINE_STATIC_LOCAL(const AtomicString, plugInMediumSizeClassName, ("medium", AtomicString::ConstructFromLiteral)); 303 304 DEFINE_STATIC_LOCAL(const AtomicString, plugInLargeSizeClassName, ("large", AtomicString::ConstructFromLiteral)); 305 DEFINE_STATIC_LOCAL(const AtomicString, plugInLargeSizePrimaryClassName, ("large primary", AtomicString::ConstructFromLiteral)); 304 306 305 307 RenderBox* renderBox = static_cast<RenderBox*>(node->renderer()); … … 316 318 return plugInMediumSizeClassName; 317 319 318 return plugInLargeSizeClassName; 320 return isPrimary ? plugInLargeSizePrimaryClassName : plugInLargeSizeClassName; 321 } 322 323 void HTMLPlugInImageElement::setIsPrimarySnapshottedPlugIn(bool isPrimarySnapshottedPlugIn) 324 { 325 m_isPrimarySnapshottedPlugIn = isPrimarySnapshottedPlugIn; 326 327 updateSnapshotInfo(); 319 328 } 320 329 … … 326 335 327 336 Element* shadowContainer = static_cast<Element*>(root->firstChild()); 328 shadowContainer->setAttribute(classAttr, classNameForShadowRoot(this ));337 shadowContainer->setAttribute(classAttr, classNameForShadowRoot(this, m_isPrimarySnapshottedPlugIn)); 329 338 } 330 339 -
trunk/Source/WebCore/html/HTMLPlugInImageElement.h
r145196 r145332 72 72 void subframeLoaderWillCreatePlugIn(const KURL& plugInURL); 73 73 void subframeLoaderDidCreatePlugIn(const Widget*); 74 75 void setIsPrimarySnapshottedPlugIn(bool); 74 76 75 77 protected: … … 118 120 bool m_shouldPreferPlugInsForImages; 119 121 bool m_needsDocumentActivationCallbacks; 122 bool m_isPrimarySnapshottedPlugIn; 120 123 RefPtr<RenderStyle> m_customStyleForPageCache; 121 124 RefPtr<MouseEvent> m_pendingClickEventFromSnapshot; -
trunk/Source/WebKit2/ChangeLog
r145330 r145332 1 2013-03-10 Tim Horton <timothy_horton@apple.com> 2 3 Add a heuristic to determine the “primary” snapshotted plugin 4 https://bugs.webkit.org/show_bug.cgi?id=111932 5 <rdar://problem/13270208> 6 7 Reviewed by Dean Jackson. 8 9 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: 10 (WebKit::WebFrameLoaderClient::dispatchDidCommitLoad): 11 Forward didCommitLoad to WebPage. Move existing code that manipulated WebPage 12 itself during didCommitLoad into WebPage, where it belongs. 13 (WebKit::WebFrameLoaderClient::dispatchDidFinishLoad): Forward didFinishLoad to WebPage. 14 * WebProcess/WebPage/WebPage.cpp: 15 (WebKit::WebPage::WebPage): Initialize m_didFindPrimarySnapshottedPlugin to false. 16 (WebKit::WebPage::didCommitLoad): Move code from WebPageFrameLoaderClient. 17 Reset the flag that says we've already found a snapshotted plugin. 18 (WebKit::WebPage::didFinishLoad): 19 Call determinePrimarySnapshottedPlugIn when any frame finishes loading. We call this for subframes, 20 not just the main frame, in case the main frame loads with no "primary" plugins, but a subframe later loads with one. 21 (WebKit::WebPage::determinePrimarySnapshottedPlugIn): 22 Attempt to find the primary snapshotted plugin on the page, by hit-testing a grid of points spaced 200px apart. 23 A plugin is considered if it is snapshotted and > 450x300. We scan vertically and left-to-right, only discarding 24 a previous candidate if another candidate is at least 110% the size of the previous candidate. 25 This tends to select plugins near the top left of the page, unless there is a significantly larger plugin elsewhere. 26 (WebKit::WebPage::resetPrimarySnapshottedPlugIn): 27 * WebProcess/WebPage/WebPage.h: 28 (WebPage): 29 1 30 2013-03-10 Sheriff Bot <webkit.review.bot@gmail.com> 2 31 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r144568 r145332 445 445 webPage->send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame->frameID(), response.mimeType(), m_frameHasCustomRepresentation, m_frame->coreFrame()->loader()->loadType(), PlatformCertificateInfo(response), InjectedBundleUserMessageEncoder(userData.get()))); 446 446 447 // Only restore the scale factor for standard frame loads (of the main frame). 448 if (m_frame->isMainFrame() && m_frame->coreFrame()->loader()->loadType() == FrameLoadTypeStandard) { 449 Page* page = m_frame->coreFrame()->page(); 450 if (page && page->pageScaleFactor() != 1) 451 webPage->scalePage(1, IntPoint()); 452 } 447 webPage->didCommitLoad(m_frame); 453 448 } 454 449 … … 525 520 if (WebFrame::LoadListener* loadListener = m_frame->loadListener()) 526 521 loadListener->didFinishLoad(m_frame); 522 523 webPage->didFinishLoad(m_frame); 527 524 } 528 525 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r145300 r145332 102 102 #include <WebCore/HTMLInputElement.h> 103 103 #include <WebCore/HTMLPlugInElement.h> 104 #include <WebCore/HTMLPlugInImageElement.h> 104 105 #include <WebCore/HistoryItem.h> 105 106 #include <WebCore/KeyboardEvent.h> … … 236 237 , m_scrollingPerformanceLoggingEnabled(false) 237 238 , m_mainFrameIsScrollable(true) 239 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) 240 , m_didFindPrimarySnapshottedPlugin(false) 241 #endif 238 242 #if PLATFORM(MAC) 239 243 , m_pdfPluginEnabled(false) … … 3865 3869 } 3866 3870 3871 void WebPage::didCommitLoad(WebFrame* frame) 3872 { 3873 // Only restore the scale factor for standard frame loads (of the main frame). 3874 if (frame->isMainFrame() && frame->coreFrame()->loader()->loadType() == FrameLoadTypeStandard) { 3875 Page* page = frame->coreFrame()->page(); 3876 if (page && page->pageScaleFactor() != 1) 3877 scalePage(1, IntPoint()); 3878 } 3879 3880 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) 3881 if (frame->isMainFrame()) 3882 resetPrimarySnapshottedPlugIn(); 3883 #endif 3884 } 3885 3886 void WebPage::didFinishLoad(WebFrame* frame) 3887 { 3888 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) 3889 determinePrimarySnapshottedPlugIn(); 3890 #endif 3891 } 3892 3893 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) 3894 static int primarySnapshottedPlugInSearchLimit = 3000; 3895 static int primarySnapshottedPlugInSearchGap = 200; 3896 static float primarySnapshottedPlugInSearchBucketSize = 1.1; 3897 static int primarySnapshottedPlugInMinimumWidth = 450; 3898 static int primarySnapshottedPlugInMinimumHeight = 300; 3899 3900 void WebPage::determinePrimarySnapshottedPlugIn() 3901 { 3902 if (!corePage()->hasSeenAnyPlugin()) 3903 return; 3904 3905 if (m_didFindPrimarySnapshottedPlugin) 3906 return; 3907 3908 RenderView* renderView = corePage()->mainFrame()->view()->renderView(); 3909 3910 IntRect searchRect = IntRect(IntPoint(), corePage()->mainFrame()->view()->contentsSize()); 3911 searchRect.intersect(IntRect(IntPoint(), IntSize(primarySnapshottedPlugInSearchLimit, primarySnapshottedPlugInSearchLimit))); 3912 3913 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowChildFrameContent | HitTestRequest::IgnoreClipping); 3914 3915 HashSet<RenderObject*> seenRenderers; 3916 HTMLPlugInImageElement* candidatePlugIn = 0; 3917 unsigned candidatePlugInArea = 0; 3918 3919 for (int x = searchRect.x(); x <= searchRect.width(); x += primarySnapshottedPlugInSearchGap) { 3920 for (int y = searchRect.y(); y <= searchRect.height(); y += primarySnapshottedPlugInSearchGap) { 3921 HitTestResult hitTestResult = HitTestResult(LayoutPoint(x, y)); 3922 renderView->hitTest(request, hitTestResult); 3923 3924 Element* element = hitTestResult.innerElement(); 3925 if (!element) 3926 continue; 3927 3928 RenderObject* renderer = element->renderer(); 3929 if (!renderer || !renderer->isBox()) 3930 continue; 3931 3932 RenderBox* renderBox = toRenderBox(renderer); 3933 3934 if (seenRenderers.contains(renderer)) 3935 continue; 3936 seenRenderers.add(renderer); 3937 3938 if (!element->isPluginElement()) 3939 continue; 3940 3941 HTMLPlugInElement* plugInElement = toHTMLPlugInElement(element); 3942 if (!plugInElement->isPlugInImageElement()) 3943 continue; 3944 3945 HTMLPlugInImageElement* plugInImageElement = toHTMLPlugInImageElement(plugInElement); 3946 3947 if (plugInElement->displayState() == HTMLPlugInElement::Playing) 3948 continue; 3949 3950 if (renderBox->contentWidth() < primarySnapshottedPlugInMinimumWidth || renderBox->contentHeight() < primarySnapshottedPlugInMinimumHeight) 3951 continue; 3952 3953 LayoutUnit contentArea = renderBox->contentWidth() * renderBox->contentHeight(); 3954 3955 if (contentArea > candidatePlugInArea * primarySnapshottedPlugInSearchBucketSize) { 3956 candidatePlugIn = plugInImageElement; 3957 candidatePlugInArea = contentArea; 3958 } 3959 } 3960 } 3961 3962 if (!candidatePlugIn) 3963 return; 3964 3965 m_didFindPrimarySnapshottedPlugin = true; 3966 3967 candidatePlugIn->setIsPrimarySnapshottedPlugIn(true); 3968 } 3969 3970 void WebPage::resetPrimarySnapshottedPlugIn() 3971 { 3972 m_didFindPrimarySnapshottedPlugin = false; 3973 } 3974 #endif // ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) 3975 3867 3976 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r145255 r145332 99 99 OBJC_CLASS NSObject; 100 100 OBJC_CLASS WKAccessibilityWebPageObject; 101 102 #define WTF_ENABLE_PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC 1 101 103 #endif 102 104 … … 218 220 void didStartPageTransition(); 219 221 void didCompletePageTransition(); 222 void didCommitLoad(WebFrame*); 223 void didFinishLoad(WebFrame*); 220 224 void show(); 221 225 String userAgent() const { return m_userAgent; } … … 631 635 void didCancelCheckingText(uint64_t requestID); 632 636 637 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) 638 void determinePrimarySnapshottedPlugIn(); 639 void resetPrimarySnapshottedPlugIn(); 640 #endif 641 633 642 private: 634 643 WebPage(uint64_t pageID, const WebPageCreationParameters&); … … 845 854 bool m_mainFrameIsScrollable; 846 855 856 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) 857 bool m_didFindPrimarySnapshottedPlugin; 858 #endif 859 847 860 #if PLATFORM(MAC) 848 861 bool m_pdfPluginEnabled;
Note: See TracChangeset
for help on using the changeset viewer.