Diff
Modified: trunk/Source/WebKit2/ChangeLog (179704 => 179705)
--- trunk/Source/WebKit2/ChangeLog 2015-02-05 21:48:16 UTC (rev 179704)
+++ trunk/Source/WebKit2/ChangeLog 2015-02-05 21:52:11 UTC (rev 179705)
@@ -1,3 +1,103 @@
+2015-02-05 Brian J. Burg <[email protected]>
+
+ Clean up WebInspectorProxy and use simpler inspector levels design
+ https://bugs.webkit.org/show_bug.cgi?id=141135
+
+ Reviewed by Timothy Hatcher.
+
+ Inspector levels used to be managed by keeping a set of WebPageGroup
+ instances and doing pointer comparisons to check whether the inspected
+ view is itself a web inspector instance. This is unnecessary, as we
+ can maintain a mapping from WebPageProxy* to its corresponding level.
+
+ When an inspector instance is created, it is inserted into the mapping
+ along with its level. An inspector's level is 1 unless its inspected page
+ is in the mapping, then it is one greater that the inspected page's level.
+
+ The level is provided by inspectorLevel(), rather than a member variable.
+ WebInspectorProxy is created in the constructor of WebPageProxy. Thus, there
+ would be no chance to add the inspector page's level to the mapping before the
+ next level inspector tries to look it up when initializing its members.
+
+ This patch introduces other miscellaneous cleanups, such as naming m_page
+ to m_inspectedPage, using Ref and using an enum class for the attachment side.
+
+ * UIProcess/API/C/WKInspector.cpp:
+ (WKInspectorGetPage):
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (resizeWebKitWebViewBaseFromAllocation):
+ * UIProcess/InspectorServer/efl/WebInspectorServerEfl.cpp:
+ * UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp:
+ * UIProcess/WebInspectorProxy.cpp:
+ (WebKit::pageLevelMap):
+ (WebKit::WebInspectorProxy::WebInspectorProxy):
+ (WebKit::WebInspectorProxy::inspectorLevel):
+ (WebKit::WebInspectorProxy::inspectorPageGroupIdentifier):
+ (WebKit::WebInspectorProxy::inspectorPagePreferences):
+ (WebKit::WebInspectorProxy::invalidate):
+ (WebKit::WebInspectorProxy::isFront):
+ (WebKit::WebInspectorProxy::connect):
+ (WebKit::WebInspectorProxy::show):
+ (WebKit::WebInspectorProxy::hide):
+ (WebKit::WebInspectorProxy::close):
+ (WebKit::WebInspectorProxy::didRelaunchInspectorPageProcess):
+ (WebKit::WebInspectorProxy::showConsole):
+ (WebKit::WebInspectorProxy::showResources):
+ (WebKit::WebInspectorProxy::showMainResourceForFrame):
+ (WebKit::WebInspectorProxy::attachBottom):
+ (WebKit::WebInspectorProxy::attachRight):
+ (WebKit::WebInspectorProxy::attach):
+ (WebKit::WebInspectorProxy::detach):
+ (WebKit::WebInspectorProxy::togglePageProfiling):
+ (WebKit::WebInspectorProxy::isInspectorPage):
+ (WebKit::decidePolicyForNavigationAction):
+ (WebKit::WebInspectorProxy::remoteFrontendConnected):
+ (WebKit::WebInspectorProxy::remoteFrontendDisconnected):
+ (WebKit::WebInspectorProxy::dispatchMessageFromRemoteFrontend):
+ (WebKit::WebInspectorProxy::eagerlyCreateInspectorPage):
+ (WebKit::WebInspectorProxy::createInspectorPage):
+ (WebKit::WebInspectorProxy::didClose):
+ (WebKit::WebInspectorPageGroups::singleton): Deleted.
+ (WebKit::WebInspectorPageGroups::inspectorLevel): Deleted.
+ (WebKit::WebInspectorPageGroups::isInspectorPageGroup): Deleted.
+ (WebKit::WebInspectorPageGroups::inspectorPageGroupLevel): Deleted.
+ (WebKit::WebInspectorPageGroups::inspectorPageGroupForLevel): Deleted.
+ (WebKit::WebInspectorPageGroups::createInspectorPageGroup): Deleted.
+ (WebKit::WebInspectorProxy::~WebInspectorProxy): Deleted.
+ (WebKit::WebInspectorProxy::inspectorPageGroup): Deleted.
+ (WebKit::WebInspectorProxy::setAttachedWindowHeight): Deleted.
+ (WebKit::WebInspectorProxy::enableRemoteInspection): Deleted.
+ (WebKit::WebInspectorProxy::open): Deleted.
+ * UIProcess/WebInspectorProxy.h:
+ (WebKit::WebInspectorProxy::create):
+ (WebKit::WebInspectorProxy::inspectedPage):
+ (WebKit::WebInspectorProxy::page): Deleted.
+ * UIProcess/efl/WebInspectorProxyEfl.cpp:
+ (WebKit::WebInspectorProxy::platformCreateInspectorPage):
+ * UIProcess/gtk/WebInspectorProxyGtk.cpp:
+ (WebKit::WebInspectorProxy::platformCreateInspectorPage):
+ (WebKit::WebInspectorProxy::dockButtonClicked):
+ (WebKit::WebInspectorProxy::createInspectorWindow):
+ (WebKit::WebInspectorProxy::platformInspectedWindowHeight):
+ (WebKit::WebInspectorProxy::platformInspectedWindowWidth):
+ (WebKit::WebInspectorProxy::platformAttach):
+ (WebKit::WebInspectorProxy::platformDetach):
+ (WebKit::WebInspectorProxy::platformSetAttachedWindowHeight):
+ (WebKit::WebInspectorProxy::platformSetAttachedWindowWidth):
+ * UIProcess/mac/WebInspectorProxyMac.mm:
+ (-[WKWebInspectorProxyObjCAdapter attachRight:]):
+ (-[WKWebInspectorProxyObjCAdapter attachBottom:]):
+ (WebKit::WebInspectorProxy::createInspectorWindow):
+ (WebKit::WebInspectorProxy::platformCreateInspectorPage):
+ (WebKit::WebInspectorProxy::platformBringToFront):
+ (WebKit::WebInspectorProxy::windowFrameDidChange):
+ (WebKit::WebInspectorProxy::inspectedViewFrameDidChange):
+ (WebKit::WebInspectorProxy::platformInspectedWindowHeight):
+ (WebKit::WebInspectorProxy::platformInspectedWindowWidth):
+ (WebKit::WebInspectorProxy::platformAttach):
+ (WebKit::WebInspectorProxy::platformDetach):
+ (-[WKWebInspectorProxyObjCAdapter close]): Deleted.
+
2015-02-05 Chris Dumez <[email protected]>
[WK2][Cocoa] Populate m_contentsFilter bloom filter from the main dispatch queue NetworkCacheStorage::initialize()
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKInspector.cpp (179704 => 179705)
--- trunk/Source/WebKit2/UIProcess/API/C/WKInspector.cpp 2015-02-05 21:48:16 UTC (rev 179704)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKInspector.cpp 2015-02-05 21:52:11 UTC (rev 179705)
@@ -41,7 +41,7 @@
WKPageRef WKInspectorGetPage(WKInspectorRef inspectorRef)
{
- return toAPI(toImpl(inspectorRef)->page());
+ return toAPI(toImpl(inspectorRef)->inspectedPage());
}
bool WKInspectorIsConnected(WKInspectorRef inspectorRef)
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (179704 => 179705)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2015-02-05 21:48:16 UTC (rev 179704)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2015-02-05 21:52:11 UTC (rev 179705)
@@ -591,7 +591,7 @@
if (priv->inspectorView) {
GtkAllocation childAllocation = viewRect;
- if (priv->inspectorAttachmentSide == AttachmentSideBottom) {
+ if (priv->inspectorAttachmentSide == AttachmentSide::Bottom) {
int inspectorViewHeight = std::min(static_cast<int>(priv->inspectorViewSize), allocation->height);
childAllocation.x = 0;
childAllocation.y = allocation->height - inspectorViewHeight;
Modified: trunk/Source/WebKit2/UIProcess/InspectorServer/efl/WebInspectorServerEfl.cpp (179704 => 179705)
--- trunk/Source/WebKit2/UIProcess/InspectorServer/efl/WebInspectorServerEfl.cpp 2015-02-05 21:48:16 UTC (rev 179704)
+++ trunk/Source/WebKit2/UIProcess/InspectorServer/efl/WebInspectorServerEfl.cpp 2015-02-05 21:52:11 UTC (rev 179705)
@@ -84,7 +84,7 @@
ClientMap::iterator end = m_clientMap.end();
for (ClientMap::iterator it = m_clientMap.begin(); it != end; ++it) {
- WebPageProxy* webPage = it->value->page();
+ WebPageProxy* webPage = it->value->inspectedPage();
if (it != m_clientMap.begin())
builder.appendLiteral(", ");
builder.appendLiteral("{ \"id\": ");
Modified: trunk/Source/WebKit2/UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp (179704 => 179705)
--- trunk/Source/WebKit2/UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp 2015-02-05 21:48:16 UTC (rev 179704)
+++ trunk/Source/WebKit2/UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp 2015-02-05 21:52:11 UTC (rev 179705)
@@ -94,7 +94,7 @@
builder.appendLiteral("[ ");
ClientMap::iterator end = m_clientMap.end();
for (ClientMap::iterator it = m_clientMap.begin(); it != end; ++it) {
- WebPageProxy* webPage = it->value->page();
+ WebPageProxy* webPage = it->value->inspectedPage();
if (it != m_clientMap.begin())
builder.appendLiteral(", ");
builder.appendLiteral("{ \"id\": ");
Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp (179704 => 179705)
--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp 2015-02-05 21:48:16 UTC (rev 179704)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp 2015-02-05 21:52:11 UTC (rev 179705)
@@ -58,90 +58,45 @@
const unsigned WebInspectorProxy::initialWindowWidth = 1000;
const unsigned WebInspectorProxy::initialWindowHeight = 650;
-class WebInspectorPageGroups {
-public:
- static WebInspectorPageGroups& singleton()
- {
- static NeverDestroyed<WebInspectorPageGroups> instance;
- return instance;
- }
+typedef HashMap<WebPageProxy*, unsigned> PageLevelMap;
- unsigned inspectorLevel(WebPageGroup& inspectedPageGroup)
- {
- return isInspectorPageGroup(inspectedPageGroup) ? inspectorPageGroupLevel(inspectedPageGroup) + 1 : 1;
- }
+static PageLevelMap& pageLevelMap()
+{
+ static NeverDestroyed<PageLevelMap> map;
+ return map;
+}
- bool isInspectorPageGroup(WebPageGroup& group)
- {
- return m_pageGroupLevel.contains(&group);
- }
-
- unsigned inspectorPageGroupLevel(WebPageGroup& group)
- {
- ASSERT(isInspectorPageGroup(group));
- return m_pageGroupLevel.get(&group);
- }
-
- WebPageGroup* inspectorPageGroupForLevel(unsigned level)
- {
- // The level is the key of the HashMap, so it cannot be 0.
- ASSERT(level);
-
- auto iterator = m_pageGroupByLevel.find(level);
- if (iterator != m_pageGroupByLevel.end())
- return iterator->value.get();
-
- RefPtr<WebPageGroup> group = createInspectorPageGroup(level);
- m_pageGroupByLevel.set(level, group.get());
- m_pageGroupLevel.set(group.get(), level);
- return group.get();
- }
-
-private:
- static PassRefPtr<WebPageGroup> createInspectorPageGroup(unsigned level)
- {
- RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(String::format("__WebInspectorPageGroupLevel%u__", level), false, false);
-
-#ifndef NDEBUG
- // Allow developers to inspect the Web Inspector in debug builds without changing settings.
- pageGroup->preferences().setDeveloperExtrasEnabled(true);
- pageGroup->preferences().setLogsPageMessagesToSystemConsoleEnabled(true);
-#endif
-
- pageGroup->preferences().setAllowFileAccessFromFileURLs(true);
-
- return pageGroup.release();
- }
-
- typedef HashMap<unsigned, RefPtr<WebPageGroup> > PageGroupByLevelMap;
- typedef HashMap<WebPageGroup*, unsigned> PageGroupLevelMap;
-
- PageGroupByLevelMap m_pageGroupByLevel;
- PageGroupLevelMap m_pageGroupLevel;
-};
-
-WebInspectorProxy::WebInspectorProxy(WebPageProxy* page)
- : m_page(page)
+WebInspectorProxy::WebInspectorProxy(WebPageProxy* inspectedPage)
+ : m_inspectedPage(inspectedPage)
#if PLATFORM(MAC) && WK_API_ENABLED
, m_closeTimer(RunLoop::main(), this, &WebInspectorProxy::closeTimerFired)
#endif
{
- m_level = WebInspectorPageGroups::singleton().inspectorLevel(m_page->pageGroup());
- m_page->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID(), *this);
+ m_inspectedPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID(), *this);
}
WebInspectorProxy::~WebInspectorProxy()
{
}
-WebPageGroup* WebInspectorProxy::inspectorPageGroup() const
+unsigned WebInspectorProxy::inspectorLevel() const
{
- return WebInspectorPageGroups::singleton().inspectorPageGroupForLevel(m_level);
+ auto findResult = pageLevelMap().find(inspectedPage());
+ if (findResult != pageLevelMap().end())
+ return findResult->value + 1;
+
+ return 1;
}
+String WebInspectorProxy::inspectorPageGroupIdentifier() const
+{
+ return String::format("__WebInspectorPageGroupLevel%u__", inspectorLevel());
+}
+
WebPreferences& WebInspectorProxy::inspectorPagePreferences() const
{
- return inspectorPageGroup()->preferences();
+ ASSERT(m_inspectorPage);
+ return m_inspectorPage->pageGroup().preferences();
}
void WebInspectorProxy::invalidate()
@@ -151,18 +106,19 @@
WebInspectorServer::singleton().unregisterPage(m_remoteInspectionPageId);
#endif
- m_page->process().removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID());
+ m_inspectedPage->process().removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID());
didClose();
platformInvalidate();
- m_page = nullptr;
+ pageLevelMap().remove(m_inspectedPage);
+ m_inspectedPage = nullptr;
}
// Public APIs
bool WebInspectorProxy::isFront()
{
- if (!m_page)
+ if (!m_inspectedPage)
return false;
return platformIsFront();
@@ -170,7 +126,7 @@
void WebInspectorProxy::connect()
{
- if (!m_page)
+ if (!m_inspectedPage)
return;
if (m_showMessageSent)
@@ -181,12 +137,12 @@
eagerlyCreateInspectorPage();
- m_page->process().send(Messages::WebInspector::Show(), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::Show(), m_inspectedPage->pageID());
}
void WebInspectorProxy::show()
{
- if (!m_page)
+ if (!m_inspectedPage)
return;
if (isConnected()) {
@@ -202,7 +158,7 @@
void WebInspectorProxy::hide()
{
- if (!m_page)
+ if (!m_inspectedPage)
return;
m_isVisible = false;
@@ -212,86 +168,86 @@
void WebInspectorProxy::close()
{
- if (!m_page)
+ if (!m_inspectedPage)
return;
- m_page->process().send(Messages::WebInspector::Close(), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::Close(), m_inspectedPage->pageID());
didClose();
}
void WebInspectorProxy::didRelaunchInspectorPageProcess()
{
- m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID(), *this);
+ m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID(), *this);
m_inspectorPage->process().assumeReadAccessToBaseURL(inspectorBaseURL());
// When didRelaunchInspectorPageProcess is called we can assume it is during a load request.
// Any messages we would have sent to a terminated process need to be re-sent.
- m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(m_connectionIdentifier, m_page->pageID(), m_underTest), m_inspectorPage->pageID());
+ m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(m_connectionIdentifier, m_inspectedPage->pageID(), m_underTest), m_inspectorPage->pageID());
}
void WebInspectorProxy::showConsole()
{
- if (!m_page)
+ if (!m_inspectedPage)
return;
eagerlyCreateInspectorPage();
- m_page->process().send(Messages::WebInspector::ShowConsole(), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::ShowConsole(), m_inspectedPage->pageID());
}
void WebInspectorProxy::showResources()
{
- if (!m_page)
+ if (!m_inspectedPage)
return;
eagerlyCreateInspectorPage();
- m_page->process().send(Messages::WebInspector::ShowResources(), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::ShowResources(), m_inspectedPage->pageID());
}
void WebInspectorProxy::showMainResourceForFrame(WebFrameProxy* frame)
{
- if (!m_page)
+ if (!m_inspectedPage)
return;
eagerlyCreateInspectorPage();
- m_page->process().send(Messages::WebInspector::ShowMainResourceForFrame(frame->frameID()), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::ShowMainResourceForFrame(frame->frameID()), m_inspectedPage->pageID());
}
void WebInspectorProxy::attachBottom()
{
- attach(AttachmentSideBottom);
+ attach(AttachmentSide::Bottom);
}
void WebInspectorProxy::attachRight()
{
- attach(AttachmentSideRight);
+ attach(AttachmentSide::Right);
}
void WebInspectorProxy::attach(AttachmentSide side)
{
- if (!m_page || !canAttach())
+ if (!m_inspectedPage || !canAttach())
return;
m_isAttached = true;
m_attachmentSide = side;
- inspectorPagePreferences().setInspectorAttachmentSide(side);
+ inspectorPagePreferences().setInspectorAttachmentSide(static_cast<uint32_t>(side));
if (m_isVisible)
inspectorPagePreferences().setInspectorStartsAttached(true);
- m_page->process().send(Messages::WebInspector::SetAttached(true), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::SetAttached(true), m_inspectedPage->pageID());
switch (m_attachmentSide) {
- case AttachmentSideBottom:
+ case AttachmentSide::Bottom:
m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedBottom(), m_inspectorPage->pageID());
break;
- case AttachmentSideRight:
+ case AttachmentSide::Right:
m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedRight(), m_inspectorPage->pageID());
break;
}
@@ -301,7 +257,7 @@
void WebInspectorProxy::detach()
{
- if (!m_page)
+ if (!m_inspectedPage)
return;
m_isAttached = false;
@@ -309,7 +265,7 @@
if (m_isVisible)
inspectorPagePreferences().setInspectorStartsAttached(false);
- m_page->process().send(Messages::WebInspector::SetAttached(false), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::SetAttached(false), m_inspectedPage->pageID());
m_inspectorPage->process().send(Messages::WebInspectorUI::Detached(), m_inspectorPage->pageID());
platformDetach();
@@ -329,23 +285,18 @@
void WebInspectorProxy::togglePageProfiling()
{
- if (!m_page)
+ if (!m_inspectedPage)
return;
if (m_isProfilingPage)
- m_page->process().send(Messages::WebInspector::StopPageProfiling(), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::StopPageProfiling(), m_inspectedPage->pageID());
else
- m_page->process().send(Messages::WebInspector::StartPageProfiling(), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::StartPageProfiling(), m_inspectedPage->pageID());
// FIXME: have the WebProcess notify us on state changes.
m_isProfilingPage = !m_isProfilingPage;
}
-bool WebInspectorProxy::isInspectorPage(WebPageProxy& page)
-{
- return WebInspectorPageGroups::singleton().isInspectorPageGroup(page.pageGroup());
-}
-
WebProcessPool& WebInspectorProxy::inspectorProcessPool()
{
// Having our own process pool removes us from the main process pool and
@@ -359,6 +310,11 @@
return *processPool;
}
+bool WebInspectorProxy::isInspectorPage(WebPageProxy& webPage)
+{
+ return pageLevelMap().contains(&webPage);
+}
+
static bool isMainOrTestInspectorPage(const WebInspectorProxy* webInspectorProxy, WKURLRequestRef requestRef)
{
URL requestURL(URL(), toImpl(requestRef)->resourceRequest().url());
@@ -409,7 +365,7 @@
toImpl(listenerRef)->ignore();
// And instead load it in the inspected page.
- webInspectorProxy->page()->loadRequest(toImpl(requestRef)->resourceRequest());
+ webInspectorProxy->inspectedPage()->loadRequest(toImpl(requestRef)->resourceRequest());
}
#if ENABLE(INSPECTOR_SERVER)
@@ -421,17 +377,17 @@
void WebInspectorProxy::remoteFrontendConnected()
{
- m_page->process().send(Messages::WebInspector::RemoteFrontendConnected(), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::RemoteFrontendConnected(), m_inspectedPage->pageID());
}
void WebInspectorProxy::remoteFrontendDisconnected()
{
- m_page->process().send(Messages::WebInspector::RemoteFrontendDisconnected(), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::RemoteFrontendDisconnected(), m_inspectedPage->pageID());
}
void WebInspectorProxy::dispatchMessageFromRemoteFrontend(const String& message)
{
- m_page->process().send(Messages::WebInspector::SendMessageToBackend(message), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::SendMessageToBackend(message), m_inspectedPage->pageID());
}
#endif
@@ -445,6 +401,8 @@
if (!m_inspectorPage)
return;
+ pageLevelMap().set(m_inspectorPage, inspectorLevel());
+
WKPagePolicyClientV1 policyClient = {
{ 1, this },
nullptr, // decidePolicyForNavigationAction_deprecatedForUseWithV0
@@ -501,14 +459,14 @@
WKPageSetPagePolicyClient(toAPI(m_inspectorPage), &policyClient.base);
WKPageSetPageLoaderClient(toAPI(m_inspectorPage), &loaderClient.base);
- m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID(), *this);
+ m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID(), *this);
m_inspectorPage->process().assumeReadAccessToBaseURL(inspectorBaseURL());
}
// Called by WebInspectorProxy messages
void WebInspectorProxy::createInspectorPage(IPC::Attachment connectionIdentifier, bool canAttach, bool underTest)
{
- if (!m_page)
+ if (!m_inspectedPage)
return;
eagerlyCreateInspectorPage();
@@ -520,22 +478,22 @@
m_underTest = underTest;
m_connectionIdentifier = connectionIdentifier;
- m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(m_connectionIdentifier, m_page->pageID(), m_underTest), m_inspectorPage->pageID());
+ m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(m_connectionIdentifier, m_inspectedPage->pageID(), m_underTest), m_inspectorPage->pageID());
if (!m_underTest) {
m_canAttach = canAttach;
m_isAttached = shouldOpenAttached();
m_attachmentSide = static_cast<AttachmentSide>(inspectorPagePreferences().inspectorAttachmentSide());
- m_page->process().send(Messages::WebInspector::SetAttached(m_isAttached), m_page->pageID());
+ m_inspectedPage->process().send(Messages::WebInspector::SetAttached(m_isAttached), m_inspectedPage->pageID());
if (m_isAttached) {
switch (m_attachmentSide) {
- case AttachmentSideBottom:
+ case AttachmentSide::Bottom:
m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedBottom(), m_inspectorPage->pageID());
break;
- case AttachmentSideRight:
+ case AttachmentSide::Right:
m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedRight(), m_inspectorPage->pageID());
break;
}
@@ -561,7 +519,7 @@
if (!m_inspectorPage)
return;
- m_inspectorPage->process().removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID());
+ m_inspectorPage->process().removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID());
m_inspectorPage = nullptr;
m_isVisible = false;
Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h (179704 => 179705)
--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h 2015-02-05 21:48:16 UTC (rev 179704)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h 2015-02-05 21:52:11 UTC (rev 179705)
@@ -64,16 +64,16 @@
class WebPreferences;
class WebProcessPool;
-enum AttachmentSide {
- AttachmentSideBottom,
- AttachmentSideRight
+enum class AttachmentSide {
+ Bottom,
+ Right
};
class WebInspectorProxy : public API::ObjectImpl<API::Object::Type::Inspector>, public IPC::MessageReceiver {
public:
- static PassRefPtr<WebInspectorProxy> create(WebPageProxy* page)
+ static Ref<WebInspectorProxy> create(WebPageProxy* inspectedPage)
{
- return adoptRef(new WebInspectorProxy(page));
+ return adoptRef(*new WebInspectorProxy(inspectedPage));
}
~WebInspectorProxy();
@@ -81,7 +81,7 @@
void invalidate();
// Public APIs
- WebPageProxy* page() const { return m_page; }
+ WebPageProxy* inspectedPage() const { return m_inspectedPage; }
bool isConnected() const { return !!m_inspectorPage; }
bool isVisible() const { return m_isVisible; }
@@ -120,7 +120,7 @@
bool isAttached() const { return m_isAttached; }
void attachRight();
void attachBottom();
- void attach(AttachmentSide = AttachmentSideBottom);
+ void attach(AttachmentSide = AttachmentSide::Bottom);
void detach();
void setAttachedWindowHeight(unsigned);
@@ -130,8 +130,8 @@
bool isProfilingPage() const { return m_isProfilingPage; }
void togglePageProfiling();
- static bool isInspectorPage(WebPageProxy&);
static WebProcessPool& inspectorProcessPool();
+ static bool isInspectorPage(WebPageProxy&);
// Provided by platform WebInspectorProxy implementations.
String inspectorPageURL() const;
@@ -192,9 +192,10 @@
void open();
- // FIXME: this should return the page group identifier, not an instance. The Mac port cannot
- // directly provide a page group instance, and instances are not necessary to compute levels.
- WebPageGroup* inspectorPageGroup() const;
+ // The inspector level is used to give different preferences to each inspector
+ // level by setting a per-level page group identifier.
+ unsigned inspectorLevel() const;
+ String inspectorPageGroupIdentifier() const;
WebPreferences& inspectorPagePreferences() const;
#if PLATFORM(GTK) || PLATFORM(EFL)
@@ -212,7 +213,7 @@
static const unsigned initialWindowWidth;
static const unsigned initialWindowHeight;
- WebPageProxy* m_page {nullptr};
+ WebPageProxy* m_inspectedPage {nullptr};
WebPageProxy* m_inspectorPage {nullptr};
bool m_underTest {false};
@@ -223,14 +224,9 @@
bool m_showMessageSent {false};
bool m_ignoreFirstBringToFront {false};
- // The debugger stops all the pages in the same PageGroup. Having
- // all the inspectors in the same group will make it impossible to debug
- // the inspector code, so we use the level to make different page groups.
- unsigned m_level;
-
IPC::Attachment m_connectionIdentifier;
- AttachmentSide m_attachmentSide {AttachmentSideBottom};
+ AttachmentSide m_attachmentSide {AttachmentSide::Bottom};
#if PLATFORM(MAC) && WK_API_ENABLED
RetainPtr<WKWebInspectorWKWebView> m_inspectorView;
Modified: trunk/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp (179704 => 179705)
--- trunk/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp 2015-02-05 21:48:16 UTC (rev 179704)
+++ trunk/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp 2015-02-05 21:52:11 UTC (rev 179705)
@@ -89,7 +89,7 @@
WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
{
- ASSERT(m_page);
+ ASSERT(m_inspectedPage);
#ifdef HAVE_ECORE_X
const char* engine = "opengl_x11";
@@ -103,7 +103,8 @@
return 0;
WKContextRef wkContext = toAPI(&inspectorProcessPool());
- WKPageGroupRef wkPageGroup = toAPI(inspectorPageGroup());
+ WKRetainPtr<WKStringRef> wkGroupIdentifier = adoptWK(WKStringCreateWithUTF8CString(inspectorPageGroupIdentifier().utf8().data()));
+ WKPageGroupRef wkPageGroup = WKPageGroupCreateWithIdentifier(wkGroupIdentifier.get());
m_inspectorView = EWKViewCreate(wkContext, wkPageGroup, ecore_evas_get(m_inspectorWindow), /* smart */ 0);
WKViewRef wkView = EWKViewGetWKView(m_inspectorView);
Modified: trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp (179704 => 179705)
--- trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp 2015-02-05 21:48:16 UTC (rev 179704)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp 2015-02-05 21:52:11 UTC (rev 179705)
@@ -30,6 +30,7 @@
#include "WebInspectorProxy.h"
#include "WebKitWebViewBasePrivate.h"
+#include "WebPageGroup.h"
#include "WebProcessProxy.h"
#include <WebCore/FileSystem.h>
#include <WebCore/GtkUtilities.h>
@@ -58,9 +59,10 @@
WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
{
- ASSERT(m_page);
+ ASSERT(inspectedPage());
ASSERT(!m_inspectorView);
- m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(&inspectorProcessPool(), nullptr, inspectorPageGroup(), nullptr, nullptr));
+ RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(inspectorPageGroupIdentifier(), false, false).leakRef();
+ m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(&inspectorProcessPool(), nullptr, pageGroup.get(), nullptr, nullptr));
g_object_add_weak_pointer(G_OBJECT(m_inspectorView), reinterpret_cast<void**>(&m_inspectorView));
return webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_inspectorView));
}
@@ -68,9 +70,9 @@
void WebInspectorProxy::dockButtonClicked(GtkWidget* button, WebInspectorProxy* inspector)
{
if (button == inspector->m_dockBottomButton)
- inspector->attach(AttachmentSideBottom);
+ inspector->attach(AttachmentSide::Bottom);
else if (button == inspector->m_dockRightButton)
- inspector->attach(AttachmentSideRight);
+ inspector->attach(AttachmentSide::Right);
else
ASSERT_NOT_REACHED();
}
@@ -83,7 +85,7 @@
ASSERT(!m_inspectorWindow);
m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- GtkWidget* inspectedViewParent = gtk_widget_get_toplevel(m_page->viewWidget());
+ GtkWidget* inspectedViewParent = gtk_widget_get_toplevel(inspectedPage()->viewWidget());
if (WebCore::widgetIsOnscreenToplevelWindow(inspectedViewParent))
gtk_window_set_transient_for(GTK_WINDOW(m_inspectorWindow), GTK_WINDOW(inspectedViewParent));
@@ -219,12 +221,12 @@
unsigned WebInspectorProxy::platformInspectedWindowHeight()
{
- return gtk_widget_get_allocated_height(m_page->viewWidget());
+ return gtk_widget_get_allocated_height(inspectedPage()->viewWidget());
}
unsigned WebInspectorProxy::platformInspectedWindowWidth()
{
- return gtk_widget_get_allocated_width(m_page->viewWidget());
+ return gtk_widget_get_allocated_width(inspectedPage()->viewWidget());
}
void WebInspectorProxy::platformAttach()
@@ -241,7 +243,7 @@
static const unsigned minimumAttachedWidth = 750;
static const unsigned minimumAttachedHeight = 250;
- if (m_attachmentSide == AttachmentSideBottom) {
+ if (m_attachmentSide == AttachmentSide::Bottom) {
unsigned maximumAttachedHeight = platformInspectedWindowHeight() * 3 / 4;
platformSetAttachedWindowHeight(std::max(minimumAttachedHeight, std::min(defaultAttachedSize, maximumAttachedHeight)));
} else {
@@ -252,13 +254,13 @@
if (m_client.attach(this))
return;
- webkitWebViewBaseAddWebInspector(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), m_inspectorView, m_attachmentSide);
+ webkitWebViewBaseAddWebInspector(WEBKIT_WEB_VIEW_BASE(inspectedPage()->viewWidget()), m_inspectorView, m_attachmentSide);
gtk_widget_show(m_inspectorView);
}
void WebInspectorProxy::platformDetach()
{
- if (!m_page->isValid())
+ if (!inspectedPage()->isValid())
return;
GRefPtr<GtkWidget> inspectorView = m_inspectorView;
@@ -280,7 +282,7 @@
return;
m_client.didChangeAttachedHeight(this, height);
- webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), height);
+ webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(inspectedPage()->viewWidget()), height);
}
void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned width)
@@ -289,7 +291,7 @@
return;
m_client.didChangeAttachedWidth(this, width);
- webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(m_page->viewWidget()), width);
+ webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(inspectedPage()->viewWidget()), width);
}
void WebInspectorProxy::platformSetToolbarHeight(unsigned)
Modified: trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm (179704 => 179705)
--- trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm 2015-02-05 21:48:16 UTC (rev 179704)
+++ trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm 2015-02-05 21:52:11 UTC (rev 179705)
@@ -114,12 +114,12 @@
- (IBAction)attachRight:(id)sender
{
- static_cast<WebInspectorProxy*>(_inspectorProxy)->attach(AttachmentSideRight);
+ static_cast<WebInspectorProxy*>(_inspectorProxy)->attach(AttachmentSide::Right);
}
- (IBAction)attachBottom:(id)sender
{
- static_cast<WebInspectorProxy*>(_inspectorProxy)->attach(AttachmentSideBottom);
+ static_cast<WebInspectorProxy*>(_inspectorProxy)->attach(AttachmentSide::Bottom);
}
- (void)close
@@ -285,7 +285,7 @@
WKRelease(fileURLs);
} else
WKOpenPanelResultListenerCancel(listener);
-
+
WKRelease(listener);
}];
}
@@ -348,7 +348,7 @@
NSRect windowFrame = NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight);
// Restore the saved window frame, if there was one.
- NSString *savedWindowFrameString = page()->pageGroup().preferences().inspectorWindowFrame();
+ NSString *savedWindowFrameString = inspectedPage()->pageGroup().preferences().inspectorWindowFrame();
NSRect savedWindowFrame = NSRectFromString(savedWindowFrameString);
if (!NSIsEmptyRect(savedWindowFrame))
windowFrame = savedWindowFrame;
@@ -447,7 +447,7 @@
WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
{
- ASSERT(m_page);
+ ASSERT(inspectedPage());
m_closeTimer.stop();
@@ -461,20 +461,20 @@
NSRect initialRect;
if (m_isAttached) {
- NSRect inspectedViewFrame = m_page->wkView().frame;
+ NSRect inspectedViewFrame = inspectedPage()->wkView().frame;
switch (m_attachmentSide) {
- case AttachmentSideBottom:
+ case AttachmentSide::Bottom:
initialRect = NSMakeRect(0, 0, NSWidth(inspectedViewFrame), inspectorPagePreferences().inspectorAttachedHeight());
break;
- case AttachmentSideRight:
+ case AttachmentSide::Right:
initialRect = NSMakeRect(0, 0, inspectorPagePreferences().inspectorAttachedWidth(), NSHeight(inspectedViewFrame));
break;
}
} else {
initialRect = NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight);
- NSString *windowFrameString = page()->pageGroup().preferences().inspectorWindowFrame();
+ NSString *windowFrameString = inspectedPage()->pageGroup().preferences().inspectorWindowFrame();
NSRect windowFrame = NSRectFromString(windowFrameString);
if (!NSIsEmptyRect(windowFrame))
initialRect = [NSWindow contentRectForFrameRect:windowFrame styleMask:windowStyleMask];
@@ -489,7 +489,7 @@
#endif
preferences._allowFileAccessFromFileURLs = YES;
[configuration setProcessPool: ::WebKit::wrapper(inspectorProcessPool())];
- [configuration _setGroupIdentifier:inspectorPageGroup()->identifier()];
+ [configuration _setGroupIdentifier:inspectorPageGroupIdentifier()];
m_inspectorView = adoptNS([[WKWebInspectorWKWebView alloc] initWithFrame:initialRect configuration:configuration.get()]);
ASSERT(m_inspectorView);
@@ -610,7 +610,7 @@
// If the Web Inspector is no longer in the same window as the inspected view,
// then we need to reopen the Inspector to get it attached to the right window.
// This can happen when dragging tabs to another window in Safari.
- if (m_isAttached && m_inspectorView.get().window != m_page->wkView().window) {
+ if (m_isAttached && m_inspectorView.get().window != inspectedPage()->wkView().window) {
platformOpen();
return;
}
@@ -719,7 +719,7 @@
return;
NSString *frameString = NSStringFromRect([m_inspectorWindow frame]);
- page()->pageGroup().preferences().setInspectorWindowFrame(frameString);
+ inspectedPage()->pageGroup().preferences().setInspectorWindowFrame(frameString);
}
void WebInspectorProxy::inspectedViewFrameDidChange(CGFloat currentDimension)
@@ -727,41 +727,41 @@
if (!m_isAttached || !m_isVisible)
return;
- WKView *inspectedView = m_page->wkView();
+ WKView *inspectedView = inspectedPage()->wkView();
NSRect inspectedViewFrame = [inspectedView frame];
NSRect inspectorFrame = NSZeroRect;
NSRect parentBounds = [[inspectedView superview] bounds];
CGFloat inspectedViewTop = NSMaxY(inspectedViewFrame);
switch (m_attachmentSide) {
- case AttachmentSideBottom: {
- if (!currentDimension)
- currentDimension = NSHeight([m_inspectorView frame]);
+ case AttachmentSide::Bottom: {
+ if (!currentDimension)
+ currentDimension = NSHeight([m_inspectorView frame]);
- CGFloat parentHeight = NSHeight(parentBounds);
- CGFloat inspectorHeight = InspectorFrontendClientLocal::constrainedAttachedWindowHeight(currentDimension, parentHeight);
+ CGFloat parentHeight = NSHeight(parentBounds);
+ CGFloat inspectorHeight = InspectorFrontendClientLocal::constrainedAttachedWindowHeight(currentDimension, parentHeight);
- // Preserve the top position of the inspected view so banners in Safari still work.
- inspectedViewFrame = NSMakeRect(0, inspectorHeight, NSWidth(parentBounds), inspectedViewTop - inspectorHeight);
- inspectorFrame = NSMakeRect(0, 0, NSWidth(inspectedViewFrame), inspectorHeight);
- break;
- }
+ // Preserve the top position of the inspected view so banners in Safari still work.
+ inspectedViewFrame = NSMakeRect(0, inspectorHeight, NSWidth(parentBounds), inspectedViewTop - inspectorHeight);
+ inspectorFrame = NSMakeRect(0, 0, NSWidth(inspectedViewFrame), inspectorHeight);
+ break;
+ }
- case AttachmentSideRight: {
- if (!currentDimension)
- currentDimension = NSWidth([m_inspectorView frame]);
+ case AttachmentSide::Right: {
+ if (!currentDimension)
+ currentDimension = NSWidth([m_inspectorView frame]);
- CGFloat parentWidth = NSWidth(parentBounds);
- CGFloat inspectorWidth = InspectorFrontendClientLocal::constrainedAttachedWindowWidth(currentDimension, parentWidth);
+ CGFloat parentWidth = NSWidth(parentBounds);
+ CGFloat inspectorWidth = InspectorFrontendClientLocal::constrainedAttachedWindowWidth(currentDimension, parentWidth);
- // Preserve the top position of the inspected view so banners in Safari still work. But don't use that
- // top position for the inspector view since the banners only stretch as wide as the the inspected view.
- inspectedViewFrame = NSMakeRect(0, 0, parentWidth - inspectorWidth, inspectedViewTop);
- CGFloat insetExcludingBanners = inspectedView._topContentInset - inspectedView._totalHeightOfBanners;
- inspectorFrame = NSMakeRect(parentWidth - inspectorWidth, 0, inspectorWidth, NSHeight(parentBounds) - insetExcludingBanners);
- break;
- }
+ // Preserve the top position of the inspected view so banners in Safari still work. But don't use that
+ // top position for the inspector view since the banners only stretch as wide as the the inspected view.
+ inspectedViewFrame = NSMakeRect(0, 0, parentWidth - inspectorWidth, inspectedViewTop);
+ CGFloat insetExcludingBanners = inspectedView._topContentInset - inspectedView._totalHeightOfBanners;
+ inspectorFrame = NSMakeRect(parentWidth - inspectorWidth, 0, inspectorWidth, NSHeight(parentBounds) - insetExcludingBanners);
+ break;
}
+ }
if (NSEqualRects([m_inspectorView frame], inspectorFrame) && NSEqualRects([inspectedView frame], inspectedViewFrame))
return;
@@ -777,21 +777,21 @@
unsigned WebInspectorProxy::platformInspectedWindowHeight()
{
- WKView *inspectedView = m_page->wkView();
+ WKView *inspectedView = inspectedPage()->wkView();
NSRect inspectedViewRect = [inspectedView frame];
return static_cast<unsigned>(inspectedViewRect.size.height);
}
unsigned WebInspectorProxy::platformInspectedWindowWidth()
{
- WKView *inspectedView = m_page->wkView();
+ WKView *inspectedView = inspectedPage()->wkView();
NSRect inspectedViewRect = [inspectedView frame];
return static_cast<unsigned>(inspectedViewRect.size.width);
}
void WebInspectorProxy::platformAttach()
{
- WKView *inspectedView = m_page->wkView();
+ WKView *inspectedView = inspectedPage()->wkView();
[[NSNotificationCenter defaultCenter] addObserver:m_inspectorProxyObjCAdapter.get() selector:@selector(inspectedViewFrameDidChange:) name:NSViewFrameDidChangeNotification object:inspectedView];
if (m_inspectorWindow) {
@@ -805,11 +805,11 @@
CGFloat currentDimension;
switch (m_attachmentSide) {
- case AttachmentSideBottom:
+ case AttachmentSide::Bottom:
[m_inspectorView setAutoresizingMask:NSViewWidthSizable | NSViewMaxYMargin];
currentDimension = inspectorPagePreferences().inspectorAttachedHeight();
break;
- case AttachmentSideRight:
+ case AttachmentSide::Right:
[m_inspectorView setAutoresizingMask:NSViewHeightSizable | NSViewMinXMargin];
currentDimension = inspectorPagePreferences().inspectorAttachedWidth();
break;
@@ -824,7 +824,7 @@
void WebInspectorProxy::platformDetach()
{
- WKView *inspectedView = m_page->wkView();
+ WKView *inspectedView = inspectedPage()->wkView();
[[NSNotificationCenter defaultCenter] removeObserver:m_inspectorProxyObjCAdapter.get() name:NSViewFrameDidChangeNotification object:inspectedView];
[m_inspectorView removeFromSuperview];