1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "web/InspectorRenderingAgent.h"
#include "core/frame/FrameView.h"
#include "core/frame/Settings.h"
#include "core/page/Page.h"
#include "web/InspectorOverlay.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebViewImpl.h"
namespace blink {
namespace RenderingAgentState {
static const char showDebugBorders[] = "showDebugBorders";
static const char showFPSCounter[] = "showFPSCounter";
static const char showPaintRects[] = "showPaintRects";
static const char showScrollBottleneckRects[] = "showScrollBottleneckRects";
static const char showSizeOnResize[] = "showSizeOnResize";
}
PassOwnPtrWillBeRawPtr<InspectorRenderingAgent> InspectorRenderingAgent::create(WebLocalFrameImpl* webLocalFrameImpl, InspectorOverlay* overlay)
{
return adoptPtrWillBeNoop(new InspectorRenderingAgent(webLocalFrameImpl, overlay));
}
InspectorRenderingAgent::InspectorRenderingAgent(WebLocalFrameImpl* webLocalFrameImpl, InspectorOverlay* overlay)
: InspectorBaseAgent<InspectorRenderingAgent, protocol::Frontend::Rendering>("Rendering")
, m_webLocalFrameImpl(webLocalFrameImpl)
, m_overlay(overlay)
{
}
WebViewImpl* InspectorRenderingAgent::webViewImpl()
{
return m_webLocalFrameImpl->viewImpl();
}
void InspectorRenderingAgent::restore()
{
ErrorString error;
setShowDebugBorders(&error, m_state->booleanProperty(RenderingAgentState::showDebugBorders, false));
setShowFPSCounter(&error, m_state->booleanProperty(RenderingAgentState::showFPSCounter, false));
setShowPaintRects(&error, m_state->booleanProperty(RenderingAgentState::showPaintRects, false));
setShowScrollBottleneckRects(&error, m_state->booleanProperty(RenderingAgentState::showScrollBottleneckRects, false));
setShowViewportSizeOnResize(&error, m_state->booleanProperty(RenderingAgentState::showSizeOnResize, false));
}
void InspectorRenderingAgent::disable(ErrorString*)
{
ErrorString error;
setShowDebugBorders(&error, false);
setShowFPSCounter(&error, false);
setShowPaintRects(&error, false);
setShowScrollBottleneckRects(&error, false);
setShowViewportSizeOnResize(&error, false);
}
void InspectorRenderingAgent::setShowDebugBorders(ErrorString* errorString, bool show)
{
m_state->setBoolean(RenderingAgentState::showDebugBorders, show);
if (show && !compositingEnabled(errorString))
return;
webViewImpl()->setShowDebugBorders(show);
}
void InspectorRenderingAgent::setShowFPSCounter(ErrorString* errorString, bool show)
{
m_state->setBoolean(RenderingAgentState::showFPSCounter, show);
if (show && !compositingEnabled(errorString))
return;
webViewImpl()->setShowFPSCounter(show);
}
void InspectorRenderingAgent::setShowPaintRects(ErrorString*, bool show)
{
m_state->setBoolean(RenderingAgentState::showPaintRects, show);
webViewImpl()->setShowPaintRects(show);
if (!show && m_webLocalFrameImpl->frameView())
m_webLocalFrameImpl->frameView()->invalidate();
}
void InspectorRenderingAgent::setShowScrollBottleneckRects(ErrorString* errorString, bool show)
{
m_state->setBoolean(RenderingAgentState::showScrollBottleneckRects, show);
if (show && !compositingEnabled(errorString))
return;
webViewImpl()->setShowScrollBottleneckRects(show);
}
void InspectorRenderingAgent::setShowViewportSizeOnResize(ErrorString* errorString, bool show)
{
m_state->setBoolean(RenderingAgentState::showSizeOnResize, show);
if (m_overlay)
m_overlay->setShowViewportSizeOnResize(show);
}
bool InspectorRenderingAgent::compositingEnabled(ErrorString* errorString)
{
if (!webViewImpl()->page()->settings().acceleratedCompositingEnabled()) {
if (errorString)
*errorString = "Compositing mode is not supported";
return false;
}
return true;
}
DEFINE_TRACE(InspectorRenderingAgent)
{
visitor->trace(m_webLocalFrameImpl);
visitor->trace(m_overlay);
InspectorBaseAgent::trace(visitor);
}
} // namespace blink
|