Changeset 163082 in webkit


Ignore:
Timestamp:
Jan 30, 2014 7:49:54 AM (10 years ago)
Author:
Antti Koivisto
Message:

WebPage::determinePrimarySnapshottedPlugIn is slow
https://bugs.webkit.org/show_bug.cgi?id=127905

Source/WebCore:

Reviewed by Anders Carlsson.

  • WebCore.exp.in: New exports
  • WebCore.xcodeproj/project.pbxproj:
  • html/HTMLPlugInImageElement.h:

(WebCore::HTMLPlugInImageElement>): Add isElementOfType<>

Source/WebKit2:

Reviewed by Anders Carlsson.

PLT before:
132.0ms 0.8% 0,0 WebKit::WebPage::determinePrimarySnapshottedPlugIn()
130.0ms 0.8% 0,0 WebCore::RenderView::hitTest(WebCore::HitTestRequest const&, WebCore::HitTestResult&)

After:
7.0ms 0.0% 0,0 WebKit::WebPage::determinePrimarySnapshottedPlugIn()
3.0ms 0.0% 0,0 WebCore::RenderView::hitTest(WebCore::HitTestRequest const&, WebCore::HitTestResult&)

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::determinePrimarySnapshottedPlugIn):

Instead of shotgunning the page with hit tests, do a DOM crawl for plugins
and hit test the centers.

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r163081 r163082  
     12014-01-30  Antti Koivisto  <antti@apple.com>
     2
     3        WebPage::determinePrimarySnapshottedPlugIn is slow
     4        https://bugs.webkit.org/show_bug.cgi?id=127905
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebCore.exp.in: New exports
     9        * WebCore.xcodeproj/project.pbxproj:
     10        * html/HTMLPlugInImageElement.h:
     11        (WebCore::HTMLPlugInImageElement>): Add isElementOfType<>
     12
    1132014-01-30  Csaba Osztrogonác  <ossy@webkit.org>
    214
  • trunk/Source/WebCore/WebCore.exp.in

    r163073 r163082  
    292292__ZN7WebCore13NodeTraversal13deepLastChildEPNS_4NodeE
    293293__ZN7WebCore13NodeTraversal19nextAncestorSiblingEPKNS_4NodeE
     294__ZN7WebCore13NodeTraversal19nextAncestorSiblingEPKNS_4NodeES3_
    294295__ZN7WebCore13PageThrottler22reportInterestingEventEv
    295296__ZN7WebCore13PageThrottlerD1Ev
     
    17631764__ZNK7WebCore6Widget25convertToContainingWindowERKNS_8IntPointE
    17641765__ZNK7WebCore6Widget9frameRectEv
     1766__ZNK7WebCore7Element10clientRectEv
    17651767__ZNK7WebCore7Element10screenRectEv
    17661768__ZNK7WebCore7Element10shadowRootEv
     
    25442546#if !defined(NDEBUG)
    25452547__ZN7WebCore14SQLiteDatabase22disableThreadingChecksEv
     2548__ZN7WebCore24NoEventDispatchAssertion7s_countE
    25462549__ZNK7WebCore7Element26fastAttributeLookupAllowedERKNS_13QualifiedNameE
    25472550#endif
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r163073 r163082  
    58875887                E1FF8F6C180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F6A180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp */; };
    58885888                E1FF8F6D180DB5BE00132674 /* CryptoAlgorithmRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */; };
    5889                 E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; };
     5889                E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
    58905890                E424A39E1330DF0100CF6DC9 /* TileGridTile.h in Headers */ = {isa = PBXBuildFile; fileRef = E424A39D1330DF0100CF6DC9 /* TileGridTile.h */; };
    58915891                E424A3A01330DF1E00CF6DC9 /* TileGridTile.mm in Sources */ = {isa = PBXBuildFile; fileRef = E424A39F1330DF1E00CF6DC9 /* TileGridTile.mm */; };
     
    59455945                E45390AE0EAFF4B5003695C8 /* SystemMemoryIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E45390AD0EAFF4B5003695C8 /* SystemMemoryIOS.cpp */; };
    59465946                E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E462A4A0113E71BE004A4220 /* IntPointHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
    5947                 E46A2B1C17CA65B9000DBCD8 /* ElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* ElementDescendantIterator.h */; };
    5948                 E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */; };
     5947                E46A2B1C17CA65B9000DBCD8 /* ElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* ElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
     5948                E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    59495949                E47127CA163438A100ED6F5A /* StyleInvalidationAnalysis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47A97CE163059FC005DCD99 /* StyleInvalidationAnalysis.cpp */; };
    59505950                E47127CB163438AE00ED6F5A /* StyleInvalidationAnalysis.h in Headers */ = {isa = PBXBuildFile; fileRef = E47A97CF163059FC005DCD99 /* StyleInvalidationAnalysis.h */; };
     
    59615961                E49BD9FA131FD2ED003C56F0 /* CSSValuePool.h in Headers */ = {isa = PBXBuildFile; fileRef = E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */; settings = {ATTRIBUTES = (Private, ); }; };
    59625962                E49BDA0B131FD3E5003C56F0 /* CSSValuePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49BDA0A131FD3E5003C56F0 /* CSSValuePool.cpp */; };
    5963                 E4AE7C1617D1BB950009FB31 /* ElementIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AE7C1517D1BB950009FB31 /* ElementIterator.h */; };
    5964                 E4AE7C1A17D232350009FB31 /* ElementAncestorIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AE7C1917D232350009FB31 /* ElementAncestorIterator.h */; };
     5963                E4AE7C1617D1BB950009FB31 /* ElementIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AE7C1517D1BB950009FB31 /* ElementIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
     5964                E4AE7C1A17D232350009FB31 /* ElementAncestorIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AE7C1917D232350009FB31 /* ElementAncestorIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    59655965                E4AFCFA50DAF29A300F5F55C /* UnitBezier.h in Headers */ = {isa = PBXBuildFile; fileRef = E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */; };
    59665966                E4AFD00B0DAF335400F5F55C /* SMILTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4AFD0050DAF335400F5F55C /* SMILTime.cpp */; };
     
    59925992                E4D58EB817B4ED8900CBDCA8 /* StyleFontSizeFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4D58EB617B4ED8900CBDCA8 /* StyleFontSizeFunctions.cpp */; };
    59935993                E4D58EB917B4ED8900CBDCA8 /* StyleFontSizeFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D58EB717B4ED8900CBDCA8 /* StyleFontSizeFunctions.h */; };
    5994                 E4D58EBB17B8F12800CBDCA8 /* ElementTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D58EBA17B8F12800CBDCA8 /* ElementTraversal.h */; };
     5994                E4D58EBB17B8F12800CBDCA8 /* ElementTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D58EBA17B8F12800CBDCA8 /* ElementTraversal.h */; settings = {ATTRIBUTES = (Private, ); }; };
    59955995                E4D687770ED7AE3D006EA978 /* PurgeableBufferMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4D687760ED7AE3D006EA978 /* PurgeableBufferMac.cpp */; };
    59965996                E4D687790ED7AE4F006EA978 /* PurgeableBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D687780ED7AE4F006EA978 /* PurgeableBuffer.h */; };
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.h

    r162139 r163082  
    173173inline bool isHTMLPlugInImageElement(const HTMLPlugInElement& element) { return element.isPlugInImageElement(); }
    174174inline bool isHTMLPlugInImageElement(const Node& node) { return node.isPluginElement() && toHTMLPlugInElement(node).isPlugInImageElement(); }
     175template <> inline bool isElementOfType<const HTMLPlugInImageElement>(const Element& element) { return isHTMLPlugInImageElement(element); }
    175176NODE_TYPE_CASTS(HTMLPlugInImageElement)
    176177
  • trunk/Source/WebKit2/ChangeLog

    r163079 r163082  
     12014-01-30  Antti Koivisto  <antti@apple.com>
     2
     3        WebPage::determinePrimarySnapshottedPlugIn is slow
     4        https://bugs.webkit.org/show_bug.cgi?id=127905
     5
     6        Reviewed by Anders Carlsson.
     7       
     8        PLT before:
     9        132.0ms  0.8% 0,0   WebKit::WebPage::determinePrimarySnapshottedPlugIn()
     10        130.0ms  0.8% 0,0    WebCore::RenderView::hitTest(WebCore::HitTestRequest const&, WebCore::HitTestResult&)
     11       
     12        After:
     13        7.0ms    0.0% 0,0   WebKit::WebPage::determinePrimarySnapshottedPlugIn()
     14        3.0ms    0.0% 0,0    WebCore::RenderView::hitTest(WebCore::HitTestRequest const&, WebCore::HitTestResult&)
     15
     16        * WebProcess/WebPage/WebPage.cpp:
     17        (WebKit::WebPage::determinePrimarySnapshottedPlugIn):
     18       
     19            Instead of shotgunning the page with hit tests, do a DOM crawl for plugins
     20            and hit test the centers.
     21
    1222014-01-30  Andrei Bucur  <abucur@adobe.com>
    223
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r163079 r163082  
    9999#include <WebCore/DragData.h>
    100100#include <WebCore/DragSession.h>
     101#include <WebCore/ElementIterator.h>
    101102#include <WebCore/EventHandler.h>
    102103#include <WebCore/FocusController.h>
     
    39933994#if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
    39943995static int primarySnapshottedPlugInSearchLimit = 3000;
    3995 static int primarySnapshottedPlugInSearchGap = 200;
    39963996static float primarySnapshottedPlugInSearchBucketSize = 1.1;
    39973997static int primarySnapshottedPlugInMinimumWidth = 400;
     
    40364036    ++m_numberOfPrimarySnapshotDetectionAttempts;
    40374037
    4038     RenderView* renderView = corePage()->mainFrame().view()->renderView();
     4038    MainFrame& mainFrame = corePage()->mainFrame();
     4039    if (!mainFrame.view())
     4040        return;
     4041    if (!mainFrame.view()->renderView())
     4042        return;
     4043    RenderView& mainRenderView = *mainFrame.view()->renderView();
    40394044
    40404045    IntRect searchRect = IntRect(IntPoint(), corePage()->mainFrame().view()->contentsSize());
     
    40434048    HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowChildFrameContent | HitTestRequest::IgnoreClipping | HitTestRequest::DisallowShadowContent);
    40444049
    4045     HashSet<RenderObject*> seenRenderers;
    4046     HTMLPlugInImageElement* candidatePlugIn = 0;
     4050    HTMLPlugInImageElement* candidatePlugIn = nullptr;
    40474051    unsigned candidatePlugInArea = 0;
    40484052
    4049     for (int x = searchRect.x(); x <= searchRect.width(); x += primarySnapshottedPlugInSearchGap) {
    4050         for (int y = searchRect.y(); y <= searchRect.height(); y += primarySnapshottedPlugInSearchGap) {
    4051             HitTestResult hitTestResult = HitTestResult(LayoutPoint(x, y));
    4052             renderView->hitTest(request, hitTestResult);
     4053    for (Frame* frame = &mainFrame; frame; frame = frame->tree().traverseNext()) {
     4054        if (!frame->loader().subframeLoader().containsPlugins())
     4055            continue;
     4056        if (!frame->document() || !frame->view())
     4057            continue;
     4058        for (auto& plugInImageElement : descendantsOfType<HTMLPlugInImageElement>(*frame->document())) {
     4059            if (plugInImageElement.displayState() == HTMLPlugInElement::Playing)
     4060                continue;
     4061
     4062            IntRect plugInRectRelativeToView = plugInImageElement.clientRect();
     4063            if (plugInRectRelativeToView.isEmpty())
     4064                continue;
     4065            IntSize scrollOffset = mainFrame.view()->scrollOffsetRelativeToDocument();
     4066            IntRect plugInRectRelativeToTopDocument(plugInRectRelativeToView.location() + scrollOffset, plugInRectRelativeToView.size());
     4067            if (!plugInRectRelativeToTopDocument.intersects(searchRect))
     4068                continue;
     4069
     4070            HitTestResult hitTestResult(plugInRectRelativeToTopDocument.center());
     4071            mainRenderView.hitTest(request, hitTestResult);
    40534072
    40544073            Element* element = hitTestResult.innerElement();
    4055             if (!element)
     4074            if (element != &plugInImageElement)
    40564075                continue;
    40574076
    4058             RenderObject* renderer = element->renderer();
     4077            auto renderer = plugInImageElement.renderer();
    40594078            if (!renderer || !renderer->isBox())
    40604079                continue;
    4061 
    4062             RenderBox* renderBox = toRenderBox(renderer);
    4063 
    4064             if (!seenRenderers.add(renderer).isNewEntry)
     4080            auto& renderBox = toRenderBox(*renderer);
     4081            if (renderBox.contentWidth() < primarySnapshottedPlugInMinimumWidth || renderBox.contentHeight() < primarySnapshottedPlugInMinimumHeight)
    40654082                continue;
    40664083
    4067             if (!element->isPluginElement())
    4068                 continue;
    4069 
    4070             HTMLPlugInElement* plugInElement = toHTMLPlugInElement(element);
    4071             if (!plugInElement->isPlugInImageElement())
    4072                 continue;
    4073 
    4074             HTMLPlugInImageElement* plugInImageElement = toHTMLPlugInImageElement(plugInElement);
    4075 
    4076             if (plugInElement->displayState() == HTMLPlugInElement::Playing)
    4077                 continue;
    4078 
    4079             if (renderBox->contentWidth() < primarySnapshottedPlugInMinimumWidth || renderBox->contentHeight() < primarySnapshottedPlugInMinimumHeight)
    4080                 continue;
    4081 
    4082             LayoutUnit contentArea = renderBox->contentWidth() * renderBox->contentHeight();
    4083 
     4084            LayoutUnit contentArea = renderBox.contentWidth() * renderBox.contentHeight();
    40844085            if (contentArea > candidatePlugInArea * primarySnapshottedPlugInSearchBucketSize) {
    4085                 candidatePlugIn = plugInImageElement;
     4086                candidatePlugIn = &plugInImageElement;
    40864087                candidatePlugInArea = contentArea;
    40874088            }
    40884089        }
    40894090    }
    4090 
    40914091    if (!candidatePlugIn) {
    40924092        LOG(Plugins, "Primary Plug-In Detection: fail - did not find a candidate plug-in.");
Note: See TracChangeset for help on using the changeset viewer.