Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1635)

Unified Diff: Source/web/WebViewImpl.cpp

Issue 908453003: Blink changes to record interest rects for http://w3c.github.io/frame-timing/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add Experimental Blink Feature flag for this change Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index a026fe12d901b713238940b116dec3d146e18902..f825f39cebb6745c8080bb5b8c8b7e9ce1b57ada 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -86,6 +86,9 @@
#include "core/page/PointerLockController.h"
#include "core/page/ScopedPageLoadDeferrer.h"
#include "core/page/TouchDisambiguation.h"
+#include "core/paint/DeprecatedPaintLayer.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"
@@ -125,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"
@@ -1913,12 +1917,75 @@ void WebViewImpl::setNeedsLayoutAndFullPaintInvalidation()
{
if (!mainFrameImpl() || !mainFrameImpl()->frame() || !mainFrameImpl()->frame()->view())
return;
-
FrameView* view = mainFrameImpl()->frame()->view();
view->setNeedsLayout();
view->setNeedsFullPaintInvalidation();
}
+static void pushFrameTimingRequestRectsToGraphicsLayer(Page* page)
chrishtr 2015/04/17 23:59:57 Are you intending to collect here the sizes of all
+{
+ typedef WTF::HashMap<const GraphicsLayer*,
chrishtr 2015/04/30 01:07:33 Move this function to FrameView, which will avoid
MikeB 2015/05/07 23:09:48 Done.
+ std::vector<std::pair<int64_t, WebRect>>>
+ GraphicsLayerFrameTimingRequests;
+
+ GraphicsLayerFrameTimingRequests glRequests;
chrishtr 2015/04/30 01:07:33 s/glRequests/graphicsLayerTimingRequests/
MikeB 2015/05/07 23:09:47 Done.
+
+ 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);
chrishtr 2015/04/30 01:07:33 s/localframe/localFrame/
MikeB 2015/05/07 23:09:47 Done.
+ Document* document = localframe->document();
+ HTMLFrameOwnerElement* ownerElement = document->ownerElement();
+
+ const GraphicsLayer* graphicsLayer = nullptr;
+
+ // Find frame's rect in graphics layer space
+ LayoutRect rect = localframe->contentRenderer()->viewRect();
+ DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(
chrishtr 2015/04/30 01:07:33 I think you should be able to simply write: Depre
MikeB 2015/05/07 23:09:47 enclosingLayerForPaintInvalidationCrossingFrameBou
+ localframe->contentRenderer(),
+ localframe->contentRenderer()->containerForPaintInvalidation(),
+ rect);
+
+ if (document->layoutView()->enclosingLayer()->compositingState()
+ == PaintsIntoOwnBacking || !ownerElement) {
+ DeprecatedPaintLayer* layer = document->layoutView()
+ ->enclosingLayer()
+ ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries();
+ graphicsLayer = layer ? layer->graphicsLayerBacking() : nullptr;
+ } else if (ownerElement->layoutObject()) {
+ DeprecatedPaintLayer* layer = ownerElement->layoutObject()
+ ->enclosingLayer()
+ ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries();
+ graphicsLayer = layer ? layer->graphicsLayerBacking() : nullptr;
+ DeprecatedPaintLayer::mapRectToPaintInvalidationBacking(
+ ownerElement->layoutObject(),
+ ownerElement->layoutObject()->containerForPaintInvalidation(),
+ rect);
+ }
+ if (!graphicsLayer)
+ continue;
+
+ GraphicsLayerFrameTimingRequests::iterator requestIterator = glRequests.find(graphicsLayer);
+ std::vector<std::pair<int64_t, WebRect>> *graphicsLayerTimingRects;
+ if (requestIterator == glRequests.end()) {
+ graphicsLayerTimingRects = &glRequests.add(graphicsLayer,
+ std::vector<std::pair<int64_t, WebRect>>()).storedValue->value;
+ } else {
+ graphicsLayerTimingRects = &requestIterator->value;
+ }
+ graphicsLayerTimingRects->push_back(std::make_pair(frame->frameID(), enclosingIntRect(rect)));
+ }
+
+ for (GraphicsLayerFrameTimingRequests::const_iterator iter = glRequests.begin(); iter != glRequests.end(); ++iter) {
chrishtr 2015/04/30 01:07:33 Change WebLayer to have a method addFrameTimingReq
MikeB 2015/05/07 23:09:48 Not yet done. Will see about making this change on
+ const GraphicsLayer* graphicsLayer = iter->key;
+ graphicsLayer->platformLayer()->setFrameTimingRequests(iter->value);
+ }
+}
+
void WebViewImpl::layout()
{
TRACE_EVENT0("blink", "WebViewImpl::layout");
@@ -1930,6 +1997,9 @@ void WebViewImpl::layout()
for (size_t i = 0; i < m_linkHighlights.size(); ++i)
m_linkHighlights[i]->updateGeometry();
+
+ if (RuntimeEnabledFeatures::frameTimingSupportEnabled())
+ pushFrameTimingRequestRectsToGraphicsLayer(m_page.get());
chrishtr 2015/04/30 01:07:33 I think this should go in FrameView::updateLayoutA
MikeB 2015/05/07 23:09:48 Done, except for the dirty bit.
}
void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect)
@@ -4310,6 +4380,27 @@ void WebViewImpl::applyViewportDeltas(
DoubleSize(outerViewportDelta.width, outerViewportDelta.height), /* programmaticScroll */ false);
}
+void WebViewImpl::recordFrameTimingEvent(FrameTimingEventType eventType, int64_t FrameId, const WebVector<std::pair<int, double>>& events)
+{
+ Frame* frame = m_page ? m_page->mainFrame() : 0;
+
+ while (frame && frame->frameID() != FrameId) {
+ frame = frame->tree().traverseNext();
+ }
+
+ if (!frame || !frame->domWindow() || !frame->domWindow()->document())
+ return; // Can't find frame, it may have been cleaned up from the DOM.
+
+ 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)

Powered by Google App Engine
This is Rietveld 408576698