Chromium Code Reviews| Index: Source/web/WebViewImpl.cpp |
| diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp |
| index 1d5941b0e0c9984bbae48249ad60ae24972e5243..270cdfed0419dd34090125d2db05813e2072b764 100644 |
| --- a/Source/web/WebViewImpl.cpp |
| +++ b/Source/web/WebViewImpl.cpp |
| @@ -64,6 +64,7 @@ |
| #include "core/html/forms/PopupMenuClient.h" |
| #include "core/html/ime/InputMethodContext.h" |
| #include "core/inspector/InspectorController.h" |
| +#include "core/layout/Layer.h" |
| #include "core/layout/compositing/LayerCompositor.h" |
| #include "core/loader/DocumentLoader.h" |
| #include "core/loader/FrameLoader.h" |
| @@ -83,10 +84,12 @@ |
| #include "core/page/PointerLockController.h" |
| #include "core/page/ScopedPageLoadDeferrer.h" |
| #include "core/page/TouchDisambiguation.h" |
| +#include "core/rendering/RenderGeometryMap.h" |
| #include "core/rendering/RenderPart.h" |
| #include "core/rendering/RenderView.h" |
| #include "core/rendering/TextAutosizer.h" |
| #include "core/storage/StorageNamespaceController.h" |
| +#include "core/timing/Performance.h" |
| #include "modules/accessibility/AXObject.h" |
| #include "modules/accessibility/AXObjectCacheImpl.h" |
| #include "modules/credentialmanager/CredentialManagerClient.h" |
| @@ -129,11 +132,13 @@ |
| #include "public/web/WebActiveWheelFlingParameters.h" |
| #include "public/web/WebAutofillClient.h" |
| #include "public/web/WebBeginFrameArgs.h" |
| +#include "public/web/WebFrame.h" |
| #include "public/web/WebFrameClient.h" |
| #include "public/web/WebHitTestResult.h" |
| #include "public/web/WebInputElement.h" |
| #include "public/web/WebMediaPlayerAction.h" |
| #include "public/web/WebNode.h" |
| +#include "public/web/WebPerformance.h" |
| #include "public/web/WebPlugin.h" |
| #include "public/web/WebPluginAction.h" |
| #include "public/web/WebRange.h" |
| @@ -1906,6 +1911,65 @@ void WebViewImpl::beginFrame(const WebBeginFrameArgs& frameTime) |
| } |
| } |
| +static void findFrameTimingRequestRects(Page* page) |
|
enne (OOO)
2015/02/10 00:17:49
Sorry for always bikeshedding, but find in a funct
MikeB
2015/03/18 21:18:34
Done.
|
| +{ |
| + typedef WTF::HashMap<const GraphicsLayer*, |
|
enne (OOO)
2015/02/10 00:17:49
It's really too bad that Blink hasn't moved into t
MikeB
2015/03/18 21:18:34
I'm happy to take a stab at it, but not 100% clear
|
| + std::vector<std::pair<int64_t, WebRect>>> |
| + GraphicsLayerFrameTimingRects; |
|
enne (OOO)
2015/02/10 00:17:49
Rects => Requests?
MikeB
2015/03/18 21:18:34
Done.
|
| + |
| + GraphicsLayerFrameTimingRects glRects; |
| + |
| + for (Frame* frame = page ? page->mainFrame() : 0; frame; |
| + frame = frame->tree().traverseNext()) { |
| + |
| + if (!frame->isLocalFrame()) |
|
enne (OOO)
2015/02/10 00:17:49
Can you leave a comment why this is? How do reques
MikeB
2015/03/18 21:18:34
If I don't have a local frame, then I don't have a
|
| + continue; |
| + |
| + LocalFrame* localframe = toLocalFrame(frame); |
| + Document* document = localframe->document(); |
| + HTMLFrameOwnerElement* ownerElement = document->ownerElement(); |
| + |
| + const GraphicsLayer* graphicsLayer; |
| + |
| + // Find frame's rect in graphics layer space |
| + LayoutRect rect = |
| + localframe->contentRenderer()->rectForPaintInvalidation(); |
| + |
| + if (document->renderView()->enclosingLayer()->compositingState() |
| + == PaintsIntoOwnBacking || !ownerElement) { |
| + graphicsLayer = document->renderView()->enclosingLayer() |
| + ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
| + ->graphicsLayerBacking(); |
| + } else { |
| + if (!ownerElement->renderer()) |
| + continue; |
| + graphicsLayer = ownerElement->renderer()->enclosingLayer() |
| + ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
| + ->graphicsLayerBacking(); |
| + |
| + Layer::mapRectToPaintInvalidationBacking( |
| + ownerElement->renderer(), |
| + ownerElement->renderer()->containerForPaintInvalidation(), |
| + rect); |
| + } |
| + |
| + GraphicsLayerFrameTimingRects::iterator glIter = glRects.find(graphicsLayer); |
| + std::vector<std::pair<int64_t, WebRect>> *glVector; |
| + if (glIter == glRects.end()) { |
| + glVector = &glRects.add(graphicsLayer, |
| + std::vector<std::pair<int64_t, WebRect>>()).storedValue->value; |
| + } else { |
| + glVector = &glIter->value; |
| + } |
| + glVector->push_back(std::make_pair(frame->frameID(), enclosingIntRect(rect))); |
| + } |
| + |
| + for (GraphicsLayerFrameTimingRects::const_iterator iter = glRects.begin(); iter != glRects.end(); ++iter) { |
| + const GraphicsLayer* graphicsLayer = iter->key; |
| + graphicsLayer->platformLayer()->setFrameTimingRequests(iter->value); |
| + } |
| +} |
| + |
| void WebViewImpl::layout() |
| { |
| TRACE_EVENT0("blink", "WebViewImpl::layout"); |
| @@ -1917,6 +1981,8 @@ void WebViewImpl::layout() |
| for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| m_linkHighlights[i]->updateGeometry(); |
| + |
| + findFrameTimingRequestRects(m_page.get()); |
| } |
| void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) |
| @@ -4462,6 +4528,32 @@ void WebViewImpl::applyViewportDeltas(const WebSize& scrollDelta, float pageScal |
| } |
| } |
| +void WebViewImpl::recordFrameTimingEvent(frameTimingEventType eventType, int64_t FrameId, const WebVector<std::pair<int, double>>& events) |
| +{ |
| + if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| + return; |
| + |
| + Frame* frame = m_page ? m_page->mainFrame() : 0; |
| + |
| + while (frame && frame->frameID() != FrameId) { |
| + frame = frame->tree().traverseNext(); |
| + } |
| + |
| + if (!frame || !frame->domWindow() || !frame->domWindow()->performance() |
| + || !frame->domWindow()->document()) |
| + return; // ASSERT? Other way to report error? |
| + |
| + ASSERT(frame->isLocalFrame()); |
| + |
| + Performance* performance = frame->domWindow()->performance(); |
| + for (size_t i = 0; i < events.size(); ++i) { |
| + if (eventType == CompositeEvent) |
| + performance->addCompositeTiming(frame->domWindow()->document(), events[i].first, events[i].second); |
| + else if (eventType == RenderEvent) |
| + performance->addRenderTiming(frame->domWindow()->document(), events[i].first, events[i].second); |
| + } |
| +} |
| + |
| void WebViewImpl::updateLayerTreeViewport() |
| { |
| if (!page() || !m_layerTreeView) |