Index: Source/web/WebViewImpl.cpp |
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp |
index af1c4935a3096dbaff310ee40179bc6fd063ae4a..77df18cae198f97425a3ea51ef8695311271129b 100644 |
--- a/Source/web/WebViewImpl.cpp |
+++ b/Source/web/WebViewImpl.cpp |
@@ -87,6 +87,8 @@ |
#include "core/page/PointerLockController.h" |
#include "core/page/ScopedPageLoadDeferrer.h" |
#include "core/page/TouchDisambiguation.h" |
+#include "core/timing/DOMWindowPerformance.h" |
+#include "core/timing/Performance.h" |
#include "modules/accessibility/AXObject.h" |
#include "modules/accessibility/AXObjectCacheImpl.h" |
#include "modules/credentialmanager/CredentialManagerClient.h" |
@@ -126,6 +128,7 @@ |
#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" |
@@ -1936,6 +1939,68 @@ void WebViewImpl::beginFrame(const WebBeginFrameArgs& frameTime) |
} |
} |
+static void pushFrameTimingRequestRectsToGraphicsLayer(Page* page) |
+{ |
+ typedef WTF::HashMap<const GraphicsLayer*, |
+ std::vector<std::pair<int64_t, WebRect>>> |
+ GraphicsLayerFrameTimingRequests; |
+ |
+ GraphicsLayerFrameTimingRequests glRequests; |
+ |
+ for (Frame* frame = page ? page->mainFrame() : 0; frame; |
+ frame = frame->tree().traverseNext()) { |
+ |
+ // Need a LocalFrame to get the GraphicsLayer to use. |
+ if (!frame->isLocalFrame()) |
+ 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()->viewRect(); |
+ Layer::mapRectToPaintInvalidationBacking(localframe->contentRenderer(), |
+ localframe->contentRenderer()->containerForPaintInvalidation(), |
+ rect); |
+ |
+ if (document->layoutView()->enclosingLayer()->compositingState() |
chrishtr
2015/03/27 01:13:02
Why do you need this complicated conditional inste
MikeB
2015/04/14 18:05:46
I can't find us actually going back and forth last
|
+ == PaintsIntoOwnBacking || !ownerElement) { |
+ graphicsLayer = document->layoutView()->enclosingLayer() |
+ ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
+ ->graphicsLayerBacking(); |
+ } else { |
+ if (!ownerElement->layoutObject()) |
+ continue; |
+ graphicsLayer = ownerElement->layoutObject()->enclosingLayer() |
+ ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
+ ->graphicsLayerBacking(); |
+ |
+ Layer::mapRectToPaintInvalidationBacking( |
+ ownerElement->layoutObject(), |
+ ownerElement->layoutObject()->containerForPaintInvalidation(), |
+ rect); |
+ } |
+ |
+ GraphicsLayerFrameTimingRequests::iterator glIter = glRequests.find(graphicsLayer); |
chrishtr
2015/03/27 01:13:02
s/glIter/requestIterator/
MikeB
2015/04/14 18:05:46
Done.
|
+ std::vector<std::pair<int64_t, WebRect>> *glVector; |
chrishtr
2015/03/27 01:13:03
s/glVector/graphicsLayerTimingRect/
MikeB
2015/04/14 18:05:46
Done.
|
+ if (glIter == glRequests.end()) { |
+ glVector = &glRequests.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 (GraphicsLayerFrameTimingRequests::const_iterator iter = glRequests.begin(); iter != glRequests.end(); ++iter) { |
+ const GraphicsLayer* graphicsLayer = iter->key; |
+ graphicsLayer->platformLayer()->setFrameTimingRequests(iter->value); |
+ } |
+} |
+ |
void WebViewImpl::layout() |
{ |
TRACE_EVENT0("blink", "WebViewImpl::layout"); |
@@ -1947,6 +2012,8 @@ void WebViewImpl::layout() |
for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
m_linkHighlights[i]->updateGeometry(); |
+ |
+ pushFrameTimingRequestRectsToGraphicsLayer(m_page.get()); |
} |
void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) |
@@ -4506,6 +4573,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()) |
chrishtr
2015/03/27 01:13:03
In what situation do you need this conditional?
MikeB
2015/04/14 18:05:45
Most of the routines in this file (at least, the o
|
+ return; |
+ |
+ Frame* frame = m_page ? m_page->mainFrame() : 0; |
chrishtr
2015/03/27 01:13:03
Ditto.
MikeB
2015/04/14 18:05:46
For this one, I don't feel comfortable dereferenci
|
+ |
+ while (frame && frame->frameID() != FrameId) { |
+ frame = frame->tree().traverseNext(); |
+ } |
+ |
+ if (!frame || !frame->domWindow() || !frame->domWindow()->document()) |
+ return; // ASSERT? Other way to report error? |
chrishtr
2015/03/27 01:13:03
Is the frameID supposed to be guaranteed to exist?
MikeB
2015/04/14 18:05:46
No, there is a possibility that the frame has sinc
|
+ |
+ ASSERT(frame->isLocalFrame()); |
chrishtr
2015/03/27 01:13:03
Why is this guaranteed?
MikeB
2015/04/14 18:05:46
No longer required. I was using localframe-only AP
|
+ |
+ blink::DOMWindow* domWindow = frame->domWindow(); |
+ blink::Performance* performance = DOMWindowPerformance::performance(*domWindow); |
+ for (size_t i = 0; i < events.size(); ++i) { |
+ if (eventType == CompositeEvent) |
+ performance->addCompositeTiming(domWindow->document(), events[i].first, events[i].second); |
+ else if (eventType == RenderEvent) |
+ performance->addRenderTiming(domWindow->document(), events[i].first, events[i].second); |
+ } |
+} |
+ |
void WebViewImpl::updateLayerTreeViewport() |
{ |
if (!page() || !m_layerTreeView) |