Diff
Modified: trunk/Source/WebCore/ChangeLog (108329 => 108330)
--- trunk/Source/WebCore/ChangeLog 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/ChangeLog 2012-02-21 11:28:47 UTC (rev 108330)
@@ -1,3 +1,50 @@
+2012-02-21 Pavel Feldman <[email protected]>
+
+ Web Inspector: add "show paint rectangles" setting.
+ https://bugs.webkit.org/show_bug.cgi?id=79030
+
+ Reviewed by Yury Semikhatsky.
+
+ * English.lproj/localizedStrings.js:
+ * inspector/DOMNodeHighlighter.cpp:
+ (WebCore::DOMNodeHighlighter::drawOutline):
+ (DOMNodeHighlighter):
+ * inspector/DOMNodeHighlighter.h:
+ (WebCore):
+ (DOMNodeHighlighter):
+ * inspector/Inspector.json:
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::willPaintImpl):
+ (WebCore::InspectorInstrumentation::didPaintImpl):
+ * inspector/InspectorInstrumentation.h:
+ (WebCore):
+ (InspectorInstrumentation):
+ (WebCore::InspectorInstrumentation::willPaint):
+ * inspector/InspectorPageAgent.cpp:
+ (PageAgentState):
+ (WebCore::InspectorPageAgent::create):
+ (WebCore::InspectorPageAgent::InspectorPageAgent):
+ (WebCore::InspectorPageAgent::setShowPaintRects):
+ (WebCore):
+ (WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
+ (WebCore::InspectorPageAgent::willPaint):
+ (WebCore::InspectorPageAgent::didPaint):
+ (WebCore::InspectorPageAgent::buildObjectForFrame):
+ * inspector/InspectorPageAgent.h:
+ (WebCore):
+ * inspector/front-end/Settings.js:
+ (WebInspector.Settings):
+ * inspector/front-end/SettingsScreen.js:
+ (WebInspector.SettingsScreen):
+ (WebInspector.SettingsScreen.prototype._showPaintRectsChanged):
+ * inspector/front-end/inspector.js:
+ * page/FrameView.cpp:
+ (WebCore::FrameView::paintContents):
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::paintContents):
+
2012-02-21 Andras Becsi <[email protected]>
[Qt] Clean-up project file after r108310
Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js
(Binary files differ)
Modified: trunk/Source/WebCore/inspector/DOMNodeHighlighter.cpp (108329 => 108330)
--- trunk/Source/WebCore/inspector/DOMNodeHighlighter.cpp 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/inspector/DOMNodeHighlighter.cpp 2012-02-21 11:28:47 UTC (rev 108330)
@@ -514,6 +514,12 @@
getOrDrawRectHighlight(0, document, highlightData, highlight);
}
+void drawOutline(GraphicsContext& context, FrameView* view, const LayoutRect& rect, const Color& color)
+{
+ FloatRect outlineRect = rect;
+ drawOutlinedQuad(context, outlineRect, Color(), color);
+}
+
} // namespace DOMNodeHighlighter
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/DOMNodeHighlighter.h (108329 => 108330)
--- trunk/Source/WebCore/inspector/DOMNodeHighlighter.h 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/inspector/DOMNodeHighlighter.h 2012-02-21 11:28:47 UTC (rev 108330)
@@ -31,6 +31,7 @@
#include "Color.h"
#include "FloatQuad.h"
+#include "LayoutTypes.h"
#include <wtf/OwnPtr.h>
#include <wtf/RefPtr.h>
@@ -40,8 +41,8 @@
class Color;
class Document;
+class FrameView;
class GraphicsContext;
-class IntRect;
class Node;
struct HighlightData {
@@ -78,6 +79,7 @@
void drawHighlight(GraphicsContext&, Document*, HighlightData*);
void getHighlight(Document*, HighlightData*, Highlight*);
+void drawOutline(GraphicsContext&, FrameView*, const LayoutRect&, const Color&);
} // namespace DOMNodeHighlighter
Modified: trunk/Source/WebCore/inspector/Inspector.json (108329 => 108330)
--- trunk/Source/WebCore/inspector/Inspector.json 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/inspector/Inspector.json 2012-02-21 11:28:47 UTC (rev 108330)
@@ -317,6 +317,14 @@
{ "name": "height", "type": "integer", "description": "Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override." }
],
"hidden": true
+ },
+ {
+ "name": "setShowPaintRects",
+ "description": "Requests that backend shows paint rectangles",
+ "parameters": [
+ { "name": "result", "type": "boolean", "description": "True for showing paint rectangles" }
+ ],
+ "hidden": true
}
],
"events": [
Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (108329 => 108330)
--- trunk/Source/WebCore/inspector/InspectorController.cpp 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp 2012-02-21 11:28:47 UTC (rev 108330)
@@ -83,7 +83,7 @@
m_inspectorAgent = inspectorAgentPtr.get();
m_agents.append(inspectorAgentPtr.release());
- OwnPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::create(m_instrumentingAgents.get(), page, m_state.get(), m_injectedScriptManager.get()));
+ OwnPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::create(m_instrumentingAgents.get(), page, m_state.get(), m_injectedScriptManager.get(), inspectorClient));
InspectorPageAgent* pageAgent = pageAgentPtr.get();
m_pageAgent = pageAgentPtr.get();
m_agents.append(pageAgentPtr.release());
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (108329 => 108330)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2012-02-21 11:28:47 UTC (rev 108330)
@@ -399,8 +399,11 @@
timelineAgent->didLoadXHR();
}
-InspectorInstrumentationCookie InspectorInstrumentation::willPaintImpl(InstrumentingAgents* instrumentingAgents, const LayoutRect& rect)
+InspectorInstrumentationCookie InspectorInstrumentation::willPaintImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, GraphicsContext* context, const LayoutRect& rect)
{
+ if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
+ pageAgent->willPaint(frame, context, rect);
+
int timelineAgentId = 0;
if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent()) {
timelineAgent->willPaint(rect);
@@ -413,6 +416,8 @@
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
timelineAgent->didPaint();
+ if (InspectorPageAgent* pageAgent = cookie.first ? cookie.first->inspectorPageAgent() : 0)
+ pageAgent->didPaint();
}
InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyleImpl(InstrumentingAgents* instrumentingAgents)
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (108329 => 108330)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2012-02-21 11:28:47 UTC (rev 108330)
@@ -51,6 +51,7 @@
class Element;
class EventContext;
class DocumentLoader;
+class GraphicsContext;
class HitTestResult;
class InspectorCSSAgent;
class InspectorTimelineAgent;
@@ -120,7 +121,7 @@
static void didLayout(const InspectorInstrumentationCookie&);
static InspectorInstrumentationCookie willLoadXHR(ScriptExecutionContext*, XMLHttpRequest*);
static void didLoadXHR(const InspectorInstrumentationCookie&);
- static InspectorInstrumentationCookie willPaint(Frame*, const LayoutRect&);
+ static InspectorInstrumentationCookie willPaint(Frame*, GraphicsContext*, const LayoutRect&);
static void didPaint(const InspectorInstrumentationCookie&);
static InspectorInstrumentationCookie willRecalculateStyle(Document*);
static void didRecalculateStyle(const InspectorInstrumentationCookie&);
@@ -270,7 +271,7 @@
static void didLayoutImpl(const InspectorInstrumentationCookie&);
static InspectorInstrumentationCookie willLoadXHRImpl(InstrumentingAgents*, XMLHttpRequest*);
static void didLoadXHRImpl(const InspectorInstrumentationCookie&);
- static InspectorInstrumentationCookie willPaintImpl(InstrumentingAgents*, const LayoutRect&);
+ static InspectorInstrumentationCookie willPaintImpl(InstrumentingAgents*, Frame*, GraphicsContext*, const LayoutRect&);
static void didPaintImpl(const InspectorInstrumentationCookie&);
static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents*);
static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
@@ -722,12 +723,12 @@
#endif
}
-inline InspectorInstrumentationCookie InspectorInstrumentation::willPaint(Frame* frame, const LayoutRect& rect)
+inline InspectorInstrumentationCookie InspectorInstrumentation::willPaint(Frame* frame, GraphicsContext* context, const LayoutRect& rect)
{
#if ENABLE(INSPECTOR)
FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
- return willPaintImpl(instrumentingAgents, rect);
+ return willPaintImpl(instrumentingAgents, frame, context, rect);
#endif
return InspectorInstrumentationCookie();
}
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (108329 => 108330)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2012-02-21 11:28:47 UTC (rev 108330)
@@ -44,6 +44,7 @@
#include "ContentSearchUtils.h"
#include "Cookie.h"
#include "CookieJar.h"
+#include "DOMNodeHighlighter.h"
#include "DOMPatchSupport.h"
#include "Document.h"
#include "DocumentLoader.h"
@@ -53,6 +54,7 @@
#include "HTMLNames.h"
#include "IdentifiersFactory.h"
#include "InjectedScriptManager.h"
+#include "InspectorClient.h"
#include "InspectorFrontend.h"
#include "InspectorInstrumentation.h"
#include "InspectorState.h"
@@ -80,6 +82,7 @@
static const char pageAgentScriptsToEvaluateOnLoad[] = "pageAgentScriptsToEvaluateOnLoad";
static const char pageAgentScreenWidthOverride[] = "pageAgentScreenWidthOverride";
static const char pageAgentScreenHeightOverride[] = "pageAgentScreenHeightOverride";
+static const char showPaintRects[] = "showPaintRects";
}
static bool decodeSharedBuffer(PassRefPtr<SharedBuffer> buffer, const String& textEncodingName, String* result)
@@ -188,9 +191,9 @@
return decodeSharedBuffer(buffer, textEncodingName, result);
}
-PassOwnPtr<InspectorPageAgent> InspectorPageAgent::create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorState* state, InjectedScriptManager* injectedScriptManager)
+PassOwnPtr<InspectorPageAgent> InspectorPageAgent::create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorState* state, InjectedScriptManager* injectedScriptManager, InspectorClient* client)
{
- return adoptPtr(new InspectorPageAgent(instrumentingAgents, page, state, injectedScriptManager));
+ return adoptPtr(new InspectorPageAgent(instrumentingAgents, page, state, injectedScriptManager, client));
}
// static
@@ -273,13 +276,16 @@
return resourceTypeString(cachedResourceType(cachedResource));
}
-InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents, Page* page, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
+InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents, Page* page, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorClient* client)
: InspectorBaseAgent<InspectorPageAgent>("Page", instrumentingAgents, inspectorState)
, m_page(page)
, m_injectedScriptManager(injectedScriptManager)
+ , m_client(client)
, m_frontend(0)
, m_lastScriptIdentifier(0)
, m_originalUseFixedLayout(false)
+ , m_lastPaintFrame(0)
+ , m_lastPaintContext(0)
{
}
@@ -623,6 +629,13 @@
updateFrameViewFixedLayout(width, height);
}
+void InspectorPageAgent::setShowPaintRects(ErrorString* errorString, bool show)
+{
+ m_state->setBoolean(PageAgentState::showPaintRects, show);
+ if (!show)
+ m_page->mainFrame()->view()->invalidate();
+}
+
void InspectorPageAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld* world)
{
if (world != mainThreadNormalWorld())
@@ -752,6 +765,34 @@
*height = heightOverride;
}
+void InspectorPageAgent::willPaint(Frame* frame, GraphicsContext* context, const LayoutRect& rect)
+{
+ if (m_state->getBoolean(PageAgentState::showPaintRects)) {
+ m_lastPaintFrame = frame;
+ m_lastPaintContext = context;
+ m_lastPaintRect = rect;
+ m_lastPaintRect.inflate(-1);
+ }
+}
+
+void InspectorPageAgent::didPaint()
+{
+ if (!m_lastPaintFrame || !m_state->getBoolean(PageAgentState::showPaintRects))
+ return;
+
+ static int colorSelector = 0;
+ const Color colors[] = {
+ Color(0xFF, 0, 0, 0x3F),
+ Color(0xFF, 0, 0xFF, 0x3F),
+ Color(0, 0, 0xFF, 0x3F),
+ };
+
+ DOMNodeHighlighter::drawOutline(*m_lastPaintContext, m_lastPaintFrame->view(), m_lastPaintRect, colors[colorSelector++ % WTF_ARRAY_LENGTH(colors)]);
+
+ m_lastPaintFrame = 0;
+ m_lastPaintContext = 0;
+}
+
PassRefPtr<InspectorObject> InspectorPageAgent::buildObjectForFrame(Frame* frame)
{
RefPtr<InspectorObject> frameObject = InspectorObject::create();
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.h (108329 => 108330)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.h 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.h 2012-02-21 11:28:47 UTC (rev 108330)
@@ -50,6 +50,7 @@
class Frontend;
class InjectedScriptManager;
class InspectorArray;
+class InspectorClient;
class InspectorObject;
class InspectorState;
class InstrumentingAgents;
@@ -74,7 +75,7 @@
OtherResource
};
- static PassOwnPtr<InspectorPageAgent> create(InstrumentingAgents*, Page*, InspectorState*, InjectedScriptManager*);
+ static PassOwnPtr<InspectorPageAgent> create(InstrumentingAgents*, Page*, InspectorState*, InjectedScriptManager*, InspectorClient*);
static bool cachedResourceContent(CachedResource*, String* result, bool* base64Encoded);
static bool sharedBufferContent(PassRefPtr<SharedBuffer>, const String& textEncodingName, bool withBase64Encode, String* result);
@@ -101,6 +102,7 @@
virtual void searchInResources(ErrorString*, const String&, const bool* caseSensitive, const bool* isRegex, RefPtr<InspectorArray>&);
virtual void setDocumentContent(ErrorString*, const String& frameId, const String& html);
virtual void setScreenSizeOverride(ErrorString*, int width, int height);
+ virtual void setShowPaintRects(ErrorString*, bool show);
// InspectorInstrumentation API
void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*);
@@ -111,6 +113,8 @@
void loaderDetachedFromFrame(DocumentLoader*);
void applyScreenWidthOverride(long*);
void applyScreenHeightOverride(long*);
+ void willPaint(Frame*, GraphicsContext*, const LayoutRect&);
+ void didPaint();
// Inspector Controller API
virtual void setFrontend(InspectorFrontend*);
@@ -127,7 +131,7 @@
static DocumentLoader* assertDocumentLoader(ErrorString*, Frame*);
private:
- InspectorPageAgent(InstrumentingAgents*, Page*, InspectorState*, InjectedScriptManager*);
+ InspectorPageAgent(InstrumentingAgents*, Page*, InspectorState*, InjectedScriptManager*, InspectorClient*);
void updateFrameViewFixedLayout(int, int);
void setFrameViewFixedLayout(int, int);
void clearFrameViewFixedLayout();
@@ -136,6 +140,7 @@
PassRefPtr<InspectorObject> buildObjectForFrameTree(Frame*);
Page* m_page;
InjectedScriptManager* m_injectedScriptManager;
+ InspectorClient* m_client;
InspectorFrontend::Page* m_frontend;
long m_lastScriptIdentifier;
String m_pendingScriptToEvaluateOnLoadOnce;
@@ -145,6 +150,9 @@
HashMap<DocumentLoader*, String> m_loaderToIdentifier;
OwnPtr<IntSize> m_originalFixedLayoutSize;
bool m_originalUseFixedLayout;
+ Frame* m_lastPaintFrame;
+ GraphicsContext* m_lastPaintContext;
+ LayoutRect m_lastPaintRect;
};
Modified: trunk/Source/WebCore/inspector/front-end/Settings.js (108329 => 108330)
--- trunk/Source/WebCore/inspector/front-end/Settings.js 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/inspector/front-end/Settings.js 2012-02-21 11:28:47 UTC (rev 108330)
@@ -89,6 +89,7 @@
this.showScriptFolders = this.createSetting("showScriptFolders", true);
this.dockToRight = this.createSetting("dockToRight", false);
this.emulateTouchEvents = this.createSetting("emulateTouchEvents", false);
+ this.showPaintRects = this.createSetting("showPaintRects", false);
// If there are too many breakpoints in a storage, it is likely due to a recent bug that caused
// periodical breakpoints duplication leading to inspector slowness.
Modified: trunk/Source/WebCore/inspector/front-end/SettingsScreen.js (108329 => 108330)
--- trunk/Source/WebCore/inspector/front-end/SettingsScreen.js 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/inspector/front-end/SettingsScreen.js 2012-02-21 11:28:47 UTC (rev 108330)
@@ -47,6 +47,10 @@
if (Preferences.exposeDisableCache)
p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Disable cache"), WebInspector.settings.cacheDisabled));
}
+
+ p = this._appendSection(WebInspector.UIString("Rendering"));
+ p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show paint rectangles"), WebInspector.settings.showPaintRects));
+ WebInspector.settings.showPaintRects.addChangeListener(this._showPaintRectsChanged, this);
p = this._appendSection(WebInspector.UIString("Elements"));
p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Word wrap"), WebInspector.settings.domWordWrap));
@@ -373,6 +377,11 @@
selectionChanged.call(this);
return fieldsetElement;
+ },
+
+ _showPaintRectsChanged: function()
+ {
+ PageAgent.setShowPaintRects(WebInspector.settings.showPaintRects.get());
}
}
Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (108329 => 108330)
--- trunk/Source/WebCore/inspector/front-end/inspector.js 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js 2012-02-21 11:28:47 UTC (rev 108330)
@@ -406,7 +406,6 @@
this._createPanels();
this._createGlobalStatusBarItems();
-
this.toolbar = new WebInspector.Toolbar();
WebInspector._installDockToRight();
@@ -440,6 +439,9 @@
DatabaseAgent.enable();
DOMStorageAgent.enable();
+ if (WebInspector.settings.showPaintRects.get())
+ PageAgent.setShowPaintRects(true);
+
WebInspector.CSSCompletions.requestCSSNameCompletions();
WebInspector.WorkerManager.loadCompleted();
InspectorFrontendAPI.loadCompleted();
Modified: trunk/Source/WebCore/page/FrameView.cpp (108329 => 108330)
--- trunk/Source/WebCore/page/FrameView.cpp 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/page/FrameView.cpp 2012-02-21 11:28:47 UTC (rev 108330)
@@ -2847,7 +2847,7 @@
if (!frame())
return;
- InspectorInstrumentationCookie cookie = InspectorInstrumentation::willPaint(m_frame.get(), rect);
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willPaint(m_frame.get(), p, rect);
Document* document = m_frame->document();
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (108329 => 108330)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2012-02-21 11:26:27 UTC (rev 108329)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2012-02-21 11:28:47 UTC (rev 108330)
@@ -1140,7 +1140,7 @@
void RenderLayerBacking::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase paintingPhase, const IntRect& clip)
{
if (graphicsLayer == m_graphicsLayer.get() || graphicsLayer == m_foregroundLayer.get() || graphicsLayer == m_maskLayer.get()) {
- InspectorInstrumentationCookie cookie = InspectorInstrumentation::willPaint(m_owningLayer->renderer()->frame(), clip);
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willPaint(m_owningLayer->renderer()->frame(), &context, clip);
// The dirtyRect is in the coords of the painting root.
IntRect dirtyRect = compositedBounds();