Changeset 179705 in webkit
- Timestamp:
- Feb 5, 2015 1:52:11 PM (9 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r179704 r179705 1 2015-02-05 Brian J. Burg <burg@cs.washington.edu> 2 3 Clean up WebInspectorProxy and use simpler inspector levels design 4 https://bugs.webkit.org/show_bug.cgi?id=141135 5 6 Reviewed by Timothy Hatcher. 7 8 Inspector levels used to be managed by keeping a set of WebPageGroup 9 instances and doing pointer comparisons to check whether the inspected 10 view is itself a web inspector instance. This is unnecessary, as we 11 can maintain a mapping from WebPageProxy* to its corresponding level. 12 13 When an inspector instance is created, it is inserted into the mapping 14 along with its level. An inspector's level is 1 unless its inspected page 15 is in the mapping, then it is one greater that the inspected page's level. 16 17 The level is provided by inspectorLevel(), rather than a member variable. 18 WebInspectorProxy is created in the constructor of WebPageProxy. Thus, there 19 would be no chance to add the inspector page's level to the mapping before the 20 next level inspector tries to look it up when initializing its members. 21 22 This patch introduces other miscellaneous cleanups, such as naming m_page 23 to m_inspectedPage, using Ref and using an enum class for the attachment side. 24 25 * UIProcess/API/C/WKInspector.cpp: 26 (WKInspectorGetPage): 27 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 28 (resizeWebKitWebViewBaseFromAllocation): 29 * UIProcess/InspectorServer/efl/WebInspectorServerEfl.cpp: 30 * UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp: 31 * UIProcess/WebInspectorProxy.cpp: 32 (WebKit::pageLevelMap): 33 (WebKit::WebInspectorProxy::WebInspectorProxy): 34 (WebKit::WebInspectorProxy::inspectorLevel): 35 (WebKit::WebInspectorProxy::inspectorPageGroupIdentifier): 36 (WebKit::WebInspectorProxy::inspectorPagePreferences): 37 (WebKit::WebInspectorProxy::invalidate): 38 (WebKit::WebInspectorProxy::isFront): 39 (WebKit::WebInspectorProxy::connect): 40 (WebKit::WebInspectorProxy::show): 41 (WebKit::WebInspectorProxy::hide): 42 (WebKit::WebInspectorProxy::close): 43 (WebKit::WebInspectorProxy::didRelaunchInspectorPageProcess): 44 (WebKit::WebInspectorProxy::showConsole): 45 (WebKit::WebInspectorProxy::showResources): 46 (WebKit::WebInspectorProxy::showMainResourceForFrame): 47 (WebKit::WebInspectorProxy::attachBottom): 48 (WebKit::WebInspectorProxy::attachRight): 49 (WebKit::WebInspectorProxy::attach): 50 (WebKit::WebInspectorProxy::detach): 51 (WebKit::WebInspectorProxy::togglePageProfiling): 52 (WebKit::WebInspectorProxy::isInspectorPage): 53 (WebKit::decidePolicyForNavigationAction): 54 (WebKit::WebInspectorProxy::remoteFrontendConnected): 55 (WebKit::WebInspectorProxy::remoteFrontendDisconnected): 56 (WebKit::WebInspectorProxy::dispatchMessageFromRemoteFrontend): 57 (WebKit::WebInspectorProxy::eagerlyCreateInspectorPage): 58 (WebKit::WebInspectorProxy::createInspectorPage): 59 (WebKit::WebInspectorProxy::didClose): 60 (WebKit::WebInspectorPageGroups::singleton): Deleted. 61 (WebKit::WebInspectorPageGroups::inspectorLevel): Deleted. 62 (WebKit::WebInspectorPageGroups::isInspectorPageGroup): Deleted. 63 (WebKit::WebInspectorPageGroups::inspectorPageGroupLevel): Deleted. 64 (WebKit::WebInspectorPageGroups::inspectorPageGroupForLevel): Deleted. 65 (WebKit::WebInspectorPageGroups::createInspectorPageGroup): Deleted. 66 (WebKit::WebInspectorProxy::~WebInspectorProxy): Deleted. 67 (WebKit::WebInspectorProxy::inspectorPageGroup): Deleted. 68 (WebKit::WebInspectorProxy::setAttachedWindowHeight): Deleted. 69 (WebKit::WebInspectorProxy::enableRemoteInspection): Deleted. 70 (WebKit::WebInspectorProxy::open): Deleted. 71 * UIProcess/WebInspectorProxy.h: 72 (WebKit::WebInspectorProxy::create): 73 (WebKit::WebInspectorProxy::inspectedPage): 74 (WebKit::WebInspectorProxy::page): Deleted. 75 * UIProcess/efl/WebInspectorProxyEfl.cpp: 76 (WebKit::WebInspectorProxy::platformCreateInspectorPage): 77 * UIProcess/gtk/WebInspectorProxyGtk.cpp: 78 (WebKit::WebInspectorProxy::platformCreateInspectorPage): 79 (WebKit::WebInspectorProxy::dockButtonClicked): 80 (WebKit::WebInspectorProxy::createInspectorWindow): 81 (WebKit::WebInspectorProxy::platformInspectedWindowHeight): 82 (WebKit::WebInspectorProxy::platformInspectedWindowWidth): 83 (WebKit::WebInspectorProxy::platformAttach): 84 (WebKit::WebInspectorProxy::platformDetach): 85 (WebKit::WebInspectorProxy::platformSetAttachedWindowHeight): 86 (WebKit::WebInspectorProxy::platformSetAttachedWindowWidth): 87 * UIProcess/mac/WebInspectorProxyMac.mm: 88 (-[WKWebInspectorProxyObjCAdapter attachRight:]): 89 (-[WKWebInspectorProxyObjCAdapter attachBottom:]): 90 (WebKit::WebInspectorProxy::createInspectorWindow): 91 (WebKit::WebInspectorProxy::platformCreateInspectorPage): 92 (WebKit::WebInspectorProxy::platformBringToFront): 93 (WebKit::WebInspectorProxy::windowFrameDidChange): 94 (WebKit::WebInspectorProxy::inspectedViewFrameDidChange): 95 (WebKit::WebInspectorProxy::platformInspectedWindowHeight): 96 (WebKit::WebInspectorProxy::platformInspectedWindowWidth): 97 (WebKit::WebInspectorProxy::platformAttach): 98 (WebKit::WebInspectorProxy::platformDetach): 99 (-[WKWebInspectorProxyObjCAdapter close]): Deleted. 100 1 101 2015-02-05 Chris Dumez <cdumez@apple.com> 2 102 -
trunk/Source/WebKit2/UIProcess/API/C/WKInspector.cpp
r178820 r179705 42 42 WKPageRef WKInspectorGetPage(WKInspectorRef inspectorRef) 43 43 { 44 return toAPI(toImpl(inspectorRef)-> page());44 return toAPI(toImpl(inspectorRef)->inspectedPage()); 45 45 } 46 46 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
r179397 r179705 592 592 GtkAllocation childAllocation = viewRect; 593 593 594 if (priv->inspectorAttachmentSide == AttachmentSide Bottom) {594 if (priv->inspectorAttachmentSide == AttachmentSide::Bottom) { 595 595 int inspectorViewHeight = std::min(static_cast<int>(priv->inspectorViewSize), allocation->height); 596 596 childAllocation.x = 0; -
trunk/Source/WebKit2/UIProcess/InspectorServer/efl/WebInspectorServerEfl.cpp
r159674 r179705 85 85 ClientMap::iterator end = m_clientMap.end(); 86 86 for (ClientMap::iterator it = m_clientMap.begin(); it != end; ++it) { 87 WebPageProxy* webPage = it->value-> page();87 WebPageProxy* webPage = it->value->inspectedPage(); 88 88 if (it != m_clientMap.begin()) 89 89 builder.appendLiteral(", "); -
trunk/Source/WebKit2/UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp
r174104 r179705 95 95 ClientMap::iterator end = m_clientMap.end(); 96 96 for (ClientMap::iterator it = m_clientMap.begin(); it != end; ++it) { 97 WebPageProxy* webPage = it->value-> page();97 WebPageProxy* webPage = it->value->inspectedPage(); 98 98 if (it != m_clientMap.begin()) 99 99 builder.appendLiteral(", "); -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp
r179573 r179705 59 59 const unsigned WebInspectorProxy::initialWindowHeight = 650; 60 60 61 class WebInspectorPageGroups { 62 public: 63 static WebInspectorPageGroups& singleton() 64 { 65 static NeverDestroyed<WebInspectorPageGroups> instance; 66 return instance; 67 } 68 69 unsigned inspectorLevel(WebPageGroup& inspectedPageGroup) 70 { 71 return isInspectorPageGroup(inspectedPageGroup) ? inspectorPageGroupLevel(inspectedPageGroup) + 1 : 1; 72 } 73 74 bool isInspectorPageGroup(WebPageGroup& group) 75 { 76 return m_pageGroupLevel.contains(&group); 77 } 78 79 unsigned inspectorPageGroupLevel(WebPageGroup& group) 80 { 81 ASSERT(isInspectorPageGroup(group)); 82 return m_pageGroupLevel.get(&group); 83 } 84 85 WebPageGroup* inspectorPageGroupForLevel(unsigned level) 86 { 87 // The level is the key of the HashMap, so it cannot be 0. 88 ASSERT(level); 89 90 auto iterator = m_pageGroupByLevel.find(level); 91 if (iterator != m_pageGroupByLevel.end()) 92 return iterator->value.get(); 93 94 RefPtr<WebPageGroup> group = createInspectorPageGroup(level); 95 m_pageGroupByLevel.set(level, group.get()); 96 m_pageGroupLevel.set(group.get(), level); 97 return group.get(); 98 } 99 100 private: 101 static PassRefPtr<WebPageGroup> createInspectorPageGroup(unsigned level) 102 { 103 RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(String::format("__WebInspectorPageGroupLevel%u__", level), false, false); 104 105 #ifndef NDEBUG 106 // Allow developers to inspect the Web Inspector in debug builds without changing settings. 107 pageGroup->preferences().setDeveloperExtrasEnabled(true); 108 pageGroup->preferences().setLogsPageMessagesToSystemConsoleEnabled(true); 109 #endif 110 111 pageGroup->preferences().setAllowFileAccessFromFileURLs(true); 112 113 return pageGroup.release(); 114 } 115 116 typedef HashMap<unsigned, RefPtr<WebPageGroup> > PageGroupByLevelMap; 117 typedef HashMap<WebPageGroup*, unsigned> PageGroupLevelMap; 118 119 PageGroupByLevelMap m_pageGroupByLevel; 120 PageGroupLevelMap m_pageGroupLevel; 121 }; 122 123 WebInspectorProxy::WebInspectorProxy(WebPageProxy* page) 124 : m_page(page) 61 typedef HashMap<WebPageProxy*, unsigned> PageLevelMap; 62 63 static PageLevelMap& pageLevelMap() 64 { 65 static NeverDestroyed<PageLevelMap> map; 66 return map; 67 } 68 69 WebInspectorProxy::WebInspectorProxy(WebPageProxy* inspectedPage) 70 : m_inspectedPage(inspectedPage) 125 71 #if PLATFORM(MAC) && WK_API_ENABLED 126 72 , m_closeTimer(RunLoop::main(), this, &WebInspectorProxy::closeTimerFired) 127 73 #endif 128 74 { 129 m_level = WebInspectorPageGroups::singleton().inspectorLevel(m_page->pageGroup()); 130 m_page->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID(), *this); 75 m_inspectedPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID(), *this); 131 76 } 132 77 … … 135 80 } 136 81 137 WebPageGroup* WebInspectorProxy::inspectorPageGroup() const 138 { 139 return WebInspectorPageGroups::singleton().inspectorPageGroupForLevel(m_level); 82 unsigned WebInspectorProxy::inspectorLevel() const 83 { 84 auto findResult = pageLevelMap().find(inspectedPage()); 85 if (findResult != pageLevelMap().end()) 86 return findResult->value + 1; 87 88 return 1; 89 } 90 91 String WebInspectorProxy::inspectorPageGroupIdentifier() const 92 { 93 return String::format("__WebInspectorPageGroupLevel%u__", inspectorLevel()); 140 94 } 141 95 142 96 WebPreferences& WebInspectorProxy::inspectorPagePreferences() const 143 97 { 144 return inspectorPageGroup()->preferences(); 98 ASSERT(m_inspectorPage); 99 return m_inspectorPage->pageGroup().preferences(); 145 100 } 146 101 … … 152 107 #endif 153 108 154 m_ page->process().removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID());109 m_inspectedPage->process().removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID()); 155 110 156 111 didClose(); 157 112 platformInvalidate(); 158 113 159 m_page = nullptr; 114 pageLevelMap().remove(m_inspectedPage); 115 m_inspectedPage = nullptr; 160 116 } 161 117 … … 163 119 bool WebInspectorProxy::isFront() 164 120 { 165 if (!m_ page)121 if (!m_inspectedPage) 166 122 return false; 167 123 … … 171 127 void WebInspectorProxy::connect() 172 128 { 173 if (!m_ page)129 if (!m_inspectedPage) 174 130 return; 175 131 … … 182 138 eagerlyCreateInspectorPage(); 183 139 184 m_ page->process().send(Messages::WebInspector::Show(), m_page->pageID());140 m_inspectedPage->process().send(Messages::WebInspector::Show(), m_inspectedPage->pageID()); 185 141 } 186 142 187 143 void WebInspectorProxy::show() 188 144 { 189 if (!m_ page)145 if (!m_inspectedPage) 190 146 return; 191 147 … … 203 159 void WebInspectorProxy::hide() 204 160 { 205 if (!m_ page)161 if (!m_inspectedPage) 206 162 return; 207 163 … … 213 169 void WebInspectorProxy::close() 214 170 { 215 if (!m_ page)216 return; 217 218 m_ page->process().send(Messages::WebInspector::Close(), m_page->pageID());171 if (!m_inspectedPage) 172 return; 173 174 m_inspectedPage->process().send(Messages::WebInspector::Close(), m_inspectedPage->pageID()); 219 175 220 176 didClose(); … … 223 179 void WebInspectorProxy::didRelaunchInspectorPageProcess() 224 180 { 225 m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_ page->pageID(), *this);181 m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID(), *this); 226 182 m_inspectorPage->process().assumeReadAccessToBaseURL(inspectorBaseURL()); 227 183 … … 229 185 // Any messages we would have sent to a terminated process need to be re-sent. 230 186 231 m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(m_connectionIdentifier, m_ page->pageID(), m_underTest), m_inspectorPage->pageID());187 m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(m_connectionIdentifier, m_inspectedPage->pageID(), m_underTest), m_inspectorPage->pageID()); 232 188 } 233 189 234 190 void WebInspectorProxy::showConsole() 235 191 { 236 if (!m_ page)192 if (!m_inspectedPage) 237 193 return; 238 194 239 195 eagerlyCreateInspectorPage(); 240 196 241 m_ page->process().send(Messages::WebInspector::ShowConsole(), m_page->pageID());197 m_inspectedPage->process().send(Messages::WebInspector::ShowConsole(), m_inspectedPage->pageID()); 242 198 } 243 199 244 200 void WebInspectorProxy::showResources() 245 201 { 246 if (!m_ page)202 if (!m_inspectedPage) 247 203 return; 248 204 249 205 eagerlyCreateInspectorPage(); 250 206 251 m_ page->process().send(Messages::WebInspector::ShowResources(), m_page->pageID());207 m_inspectedPage->process().send(Messages::WebInspector::ShowResources(), m_inspectedPage->pageID()); 252 208 } 253 209 254 210 void WebInspectorProxy::showMainResourceForFrame(WebFrameProxy* frame) 255 211 { 256 if (!m_ page)212 if (!m_inspectedPage) 257 213 return; 258 214 259 215 eagerlyCreateInspectorPage(); 260 216 261 m_ page->process().send(Messages::WebInspector::ShowMainResourceForFrame(frame->frameID()), m_page->pageID());217 m_inspectedPage->process().send(Messages::WebInspector::ShowMainResourceForFrame(frame->frameID()), m_inspectedPage->pageID()); 262 218 } 263 219 264 220 void WebInspectorProxy::attachBottom() 265 221 { 266 attach(AttachmentSide Bottom);222 attach(AttachmentSide::Bottom); 267 223 } 268 224 269 225 void WebInspectorProxy::attachRight() 270 226 { 271 attach(AttachmentSide Right);227 attach(AttachmentSide::Right); 272 228 } 273 229 274 230 void WebInspectorProxy::attach(AttachmentSide side) 275 231 { 276 if (!m_ page || !canAttach())232 if (!m_inspectedPage || !canAttach()) 277 233 return; 278 234 … … 280 236 m_attachmentSide = side; 281 237 282 inspectorPagePreferences().setInspectorAttachmentSide(s ide);238 inspectorPagePreferences().setInspectorAttachmentSide(static_cast<uint32_t>(side)); 283 239 284 240 if (m_isVisible) 285 241 inspectorPagePreferences().setInspectorStartsAttached(true); 286 242 287 m_ page->process().send(Messages::WebInspector::SetAttached(true), m_page->pageID());243 m_inspectedPage->process().send(Messages::WebInspector::SetAttached(true), m_inspectedPage->pageID()); 288 244 289 245 switch (m_attachmentSide) { 290 case AttachmentSide Bottom:246 case AttachmentSide::Bottom: 291 247 m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedBottom(), m_inspectorPage->pageID()); 292 248 break; 293 249 294 case AttachmentSide Right:250 case AttachmentSide::Right: 295 251 m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedRight(), m_inspectorPage->pageID()); 296 252 break; … … 302 258 void WebInspectorProxy::detach() 303 259 { 304 if (!m_ page)260 if (!m_inspectedPage) 305 261 return; 306 262 … … 310 266 inspectorPagePreferences().setInspectorStartsAttached(false); 311 267 312 m_ page->process().send(Messages::WebInspector::SetAttached(false), m_page->pageID());268 m_inspectedPage->process().send(Messages::WebInspector::SetAttached(false), m_inspectedPage->pageID()); 313 269 m_inspectorPage->process().send(Messages::WebInspectorUI::Detached(), m_inspectorPage->pageID()); 314 270 … … 330 286 void WebInspectorProxy::togglePageProfiling() 331 287 { 332 if (!m_ page)288 if (!m_inspectedPage) 333 289 return; 334 290 335 291 if (m_isProfilingPage) 336 m_ page->process().send(Messages::WebInspector::StopPageProfiling(), m_page->pageID());292 m_inspectedPage->process().send(Messages::WebInspector::StopPageProfiling(), m_inspectedPage->pageID()); 337 293 else 338 m_ page->process().send(Messages::WebInspector::StartPageProfiling(), m_page->pageID());294 m_inspectedPage->process().send(Messages::WebInspector::StartPageProfiling(), m_inspectedPage->pageID()); 339 295 340 296 // FIXME: have the WebProcess notify us on state changes. 341 297 m_isProfilingPage = !m_isProfilingPage; 342 }343 344 bool WebInspectorProxy::isInspectorPage(WebPageProxy& page)345 {346 return WebInspectorPageGroups::singleton().isInspectorPageGroup(page.pageGroup());347 298 } 348 299 … … 360 311 } 361 312 313 bool WebInspectorProxy::isInspectorPage(WebPageProxy& webPage) 314 { 315 return pageLevelMap().contains(&webPage); 316 } 317 362 318 static bool isMainOrTestInspectorPage(const WebInspectorProxy* webInspectorProxy, WKURLRequestRef requestRef) 363 319 { … … 410 366 411 367 // And instead load it in the inspected page. 412 webInspectorProxy-> page()->loadRequest(toImpl(requestRef)->resourceRequest());368 webInspectorProxy->inspectedPage()->loadRequest(toImpl(requestRef)->resourceRequest()); 413 369 } 414 370 … … 422 378 void WebInspectorProxy::remoteFrontendConnected() 423 379 { 424 m_ page->process().send(Messages::WebInspector::RemoteFrontendConnected(), m_page->pageID());380 m_inspectedPage->process().send(Messages::WebInspector::RemoteFrontendConnected(), m_inspectedPage->pageID()); 425 381 } 426 382 427 383 void WebInspectorProxy::remoteFrontendDisconnected() 428 384 { 429 m_ page->process().send(Messages::WebInspector::RemoteFrontendDisconnected(), m_page->pageID());385 m_inspectedPage->process().send(Messages::WebInspector::RemoteFrontendDisconnected(), m_inspectedPage->pageID()); 430 386 } 431 387 432 388 void WebInspectorProxy::dispatchMessageFromRemoteFrontend(const String& message) 433 389 { 434 m_ page->process().send(Messages::WebInspector::SendMessageToBackend(message), m_page->pageID());390 m_inspectedPage->process().send(Messages::WebInspector::SendMessageToBackend(message), m_inspectedPage->pageID()); 435 391 } 436 392 #endif … … 445 401 if (!m_inspectorPage) 446 402 return; 403 404 pageLevelMap().set(m_inspectorPage, inspectorLevel()); 447 405 448 406 WKPagePolicyClientV1 policyClient = { … … 502 460 WKPageSetPageLoaderClient(toAPI(m_inspectorPage), &loaderClient.base); 503 461 504 m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_ page->pageID(), *this);462 m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID(), *this); 505 463 m_inspectorPage->process().assumeReadAccessToBaseURL(inspectorBaseURL()); 506 464 } … … 509 467 void WebInspectorProxy::createInspectorPage(IPC::Attachment connectionIdentifier, bool canAttach, bool underTest) 510 468 { 511 if (!m_ page)469 if (!m_inspectedPage) 512 470 return; 513 471 … … 521 479 m_connectionIdentifier = connectionIdentifier; 522 480 523 m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(m_connectionIdentifier, m_ page->pageID(), m_underTest), m_inspectorPage->pageID());481 m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(m_connectionIdentifier, m_inspectedPage->pageID(), m_underTest), m_inspectorPage->pageID()); 524 482 525 483 if (!m_underTest) { … … 528 486 m_attachmentSide = static_cast<AttachmentSide>(inspectorPagePreferences().inspectorAttachmentSide()); 529 487 530 m_ page->process().send(Messages::WebInspector::SetAttached(m_isAttached), m_page->pageID());488 m_inspectedPage->process().send(Messages::WebInspector::SetAttached(m_isAttached), m_inspectedPage->pageID()); 531 489 532 490 if (m_isAttached) { 533 491 switch (m_attachmentSide) { 534 case AttachmentSide Bottom:492 case AttachmentSide::Bottom: 535 493 m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedBottom(), m_inspectorPage->pageID()); 536 494 break; 537 495 538 case AttachmentSide Right:496 case AttachmentSide::Right: 539 497 m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedRight(), m_inspectorPage->pageID()); 540 498 break; … … 562 520 return; 563 521 564 m_inspectorPage->process().removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_ page->pageID());522 m_inspectorPage->process().removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->pageID()); 565 523 m_inspectorPage = nullptr; 566 524 -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h
r179573 r179705 65 65 class WebProcessPool; 66 66 67 enum AttachmentSide {68 AttachmentSideBottom,69 AttachmentSideRight67 enum class AttachmentSide { 68 Bottom, 69 Right 70 70 }; 71 71 72 72 class WebInspectorProxy : public API::ObjectImpl<API::Object::Type::Inspector>, public IPC::MessageReceiver { 73 73 public: 74 static PassRefPtr<WebInspectorProxy> create(WebPageProxy* page)74 static Ref<WebInspectorProxy> create(WebPageProxy* inspectedPage) 75 75 { 76 return adoptRef( new WebInspectorProxy(page));76 return adoptRef(*new WebInspectorProxy(inspectedPage)); 77 77 } 78 78 … … 82 82 83 83 // Public APIs 84 WebPageProxy* page() const { return m_page; }84 WebPageProxy* inspectedPage() const { return m_inspectedPage; } 85 85 86 86 bool isConnected() const { return !!m_inspectorPage; } … … 121 121 void attachRight(); 122 122 void attachBottom(); 123 void attach(AttachmentSide = AttachmentSide Bottom);123 void attach(AttachmentSide = AttachmentSide::Bottom); 124 124 void detach(); 125 125 … … 131 131 void togglePageProfiling(); 132 132 133 static WebProcessPool& inspectorProcessPool(); 133 134 static bool isInspectorPage(WebPageProxy&); 134 static WebProcessPool& inspectorProcessPool();135 135 136 136 // Provided by platform WebInspectorProxy implementations. … … 193 193 void open(); 194 194 195 // FIXME: this should return the page group identifier, not an instance. The Mac port cannot 196 // directly provide a page group instance, and instances are not necessary to compute levels. 197 WebPageGroup* inspectorPageGroup() const; 195 // The inspector level is used to give different preferences to each inspector 196 // level by setting a per-level page group identifier. 197 unsigned inspectorLevel() const; 198 String inspectorPageGroupIdentifier() const; 198 199 WebPreferences& inspectorPagePreferences() const; 199 200 … … 213 214 static const unsigned initialWindowHeight; 214 215 215 WebPageProxy* m_ page {nullptr};216 WebPageProxy* m_inspectedPage {nullptr}; 216 217 WebPageProxy* m_inspectorPage {nullptr}; 217 218 … … 224 225 bool m_ignoreFirstBringToFront {false}; 225 226 226 // The debugger stops all the pages in the same PageGroup. Having227 // all the inspectors in the same group will make it impossible to debug228 // the inspector code, so we use the level to make different page groups.229 unsigned m_level;230 231 227 IPC::Attachment m_connectionIdentifier; 232 228 233 AttachmentSide m_attachmentSide {AttachmentSide Bottom};229 AttachmentSide m_attachmentSide {AttachmentSide::Bottom}; 234 230 235 231 #if PLATFORM(MAC) && WK_API_ENABLED -
trunk/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp
r178820 r179705 90 90 WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() 91 91 { 92 ASSERT(m_ page);92 ASSERT(m_inspectedPage); 93 93 94 94 #ifdef HAVE_ECORE_X … … 104 104 105 105 WKContextRef wkContext = toAPI(&inspectorProcessPool()); 106 WKPageGroupRef wkPageGroup = toAPI(inspectorPageGroup()); 106 WKRetainPtr<WKStringRef> wkGroupIdentifier = adoptWK(WKStringCreateWithUTF8CString(inspectorPageGroupIdentifier().utf8().data())); 107 WKPageGroupRef wkPageGroup = WKPageGroupCreateWithIdentifier(wkGroupIdentifier.get()); 107 108 108 109 m_inspectorView = EWKViewCreate(wkContext, wkPageGroup, ecore_evas_get(m_inspectorWindow), /* smart */ 0); -
trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp
r178820 r179705 31 31 32 32 #include "WebKitWebViewBasePrivate.h" 33 #include "WebPageGroup.h" 33 34 #include "WebProcessProxy.h" 34 35 #include <WebCore/FileSystem.h> … … 59 60 WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() 60 61 { 61 ASSERT( m_page);62 ASSERT(inspectedPage()); 62 63 ASSERT(!m_inspectorView); 63 m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(&inspectorProcessPool(), nullptr, inspectorPageGroup(), nullptr, nullptr)); 64 RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(inspectorPageGroupIdentifier(), false, false).leakRef(); 65 m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(&inspectorProcessPool(), nullptr, pageGroup.get(), nullptr, nullptr)); 64 66 g_object_add_weak_pointer(G_OBJECT(m_inspectorView), reinterpret_cast<void**>(&m_inspectorView)); 65 67 return webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_inspectorView)); … … 69 71 { 70 72 if (button == inspector->m_dockBottomButton) 71 inspector->attach(AttachmentSide Bottom);73 inspector->attach(AttachmentSide::Bottom); 72 74 else if (button == inspector->m_dockRightButton) 73 inspector->attach(AttachmentSide Right);75 inspector->attach(AttachmentSide::Right); 74 76 else 75 77 ASSERT_NOT_REACHED(); … … 84 86 m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); 85 87 86 GtkWidget* inspectedViewParent = gtk_widget_get_toplevel( m_page->viewWidget());88 GtkWidget* inspectedViewParent = gtk_widget_get_toplevel(inspectedPage()->viewWidget()); 87 89 if (WebCore::widgetIsOnscreenToplevelWindow(inspectedViewParent)) 88 90 gtk_window_set_transient_for(GTK_WINDOW(m_inspectorWindow), GTK_WINDOW(inspectedViewParent)); … … 220 222 unsigned WebInspectorProxy::platformInspectedWindowHeight() 221 223 { 222 return gtk_widget_get_allocated_height( m_page->viewWidget());224 return gtk_widget_get_allocated_height(inspectedPage()->viewWidget()); 223 225 } 224 226 225 227 unsigned WebInspectorProxy::platformInspectedWindowWidth() 226 228 { 227 return gtk_widget_get_allocated_width( m_page->viewWidget());229 return gtk_widget_get_allocated_width(inspectedPage()->viewWidget()); 228 230 } 229 231 … … 242 244 static const unsigned minimumAttachedHeight = 250; 243 245 244 if (m_attachmentSide == AttachmentSide Bottom) {246 if (m_attachmentSide == AttachmentSide::Bottom) { 245 247 unsigned maximumAttachedHeight = platformInspectedWindowHeight() * 3 / 4; 246 248 platformSetAttachedWindowHeight(std::max(minimumAttachedHeight, std::min(defaultAttachedSize, maximumAttachedHeight))); … … 253 255 return; 254 256 255 webkitWebViewBaseAddWebInspector(WEBKIT_WEB_VIEW_BASE( m_page->viewWidget()), m_inspectorView, m_attachmentSide);257 webkitWebViewBaseAddWebInspector(WEBKIT_WEB_VIEW_BASE(inspectedPage()->viewWidget()), m_inspectorView, m_attachmentSide); 256 258 gtk_widget_show(m_inspectorView); 257 259 } … … 259 261 void WebInspectorProxy::platformDetach() 260 262 { 261 if (! m_page->isValid())263 if (!inspectedPage()->isValid()) 262 264 return; 263 265 … … 281 283 282 284 m_client.didChangeAttachedHeight(this, height); 283 webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE( m_page->viewWidget()), height);285 webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(inspectedPage()->viewWidget()), height); 284 286 } 285 287 … … 290 292 291 293 m_client.didChangeAttachedWidth(this, width); 292 webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE( m_page->viewWidget()), width);294 webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(inspectedPage()->viewWidget()), width); 293 295 } 294 296 -
trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
r179573 r179705 115 115 - (IBAction)attachRight:(id)sender 116 116 { 117 static_cast<WebInspectorProxy*>(_inspectorProxy)->attach(AttachmentSide Right);117 static_cast<WebInspectorProxy*>(_inspectorProxy)->attach(AttachmentSide::Right); 118 118 } 119 119 120 120 - (IBAction)attachBottom:(id)sender 121 121 { 122 static_cast<WebInspectorProxy*>(_inspectorProxy)->attach(AttachmentSide Bottom);122 static_cast<WebInspectorProxy*>(_inspectorProxy)->attach(AttachmentSide::Bottom); 123 123 } 124 124 … … 286 286 } else 287 287 WKOpenPanelResultListenerCancel(listener); 288 288 289 289 WKRelease(listener); 290 290 }]; … … 349 349 350 350 // Restore the saved window frame, if there was one. 351 NSString *savedWindowFrameString = page()->pageGroup().preferences().inspectorWindowFrame();351 NSString *savedWindowFrameString = inspectedPage()->pageGroup().preferences().inspectorWindowFrame(); 352 352 NSRect savedWindowFrame = NSRectFromString(savedWindowFrameString); 353 353 if (!NSIsEmptyRect(savedWindowFrame)) … … 448 448 WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() 449 449 { 450 ASSERT( m_page);450 ASSERT(inspectedPage()); 451 451 452 452 m_closeTimer.stop(); … … 462 462 NSRect initialRect; 463 463 if (m_isAttached) { 464 NSRect inspectedViewFrame = m_page->wkView().frame;464 NSRect inspectedViewFrame = inspectedPage()->wkView().frame; 465 465 466 466 switch (m_attachmentSide) { 467 case AttachmentSide Bottom:467 case AttachmentSide::Bottom: 468 468 initialRect = NSMakeRect(0, 0, NSWidth(inspectedViewFrame), inspectorPagePreferences().inspectorAttachedHeight()); 469 469 break; 470 case AttachmentSide Right:470 case AttachmentSide::Right: 471 471 initialRect = NSMakeRect(0, 0, inspectorPagePreferences().inspectorAttachedWidth(), NSHeight(inspectedViewFrame)); 472 472 break; … … 475 475 initialRect = NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight); 476 476 477 NSString *windowFrameString = page()->pageGroup().preferences().inspectorWindowFrame();477 NSString *windowFrameString = inspectedPage()->pageGroup().preferences().inspectorWindowFrame(); 478 478 NSRect windowFrame = NSRectFromString(windowFrameString); 479 479 if (!NSIsEmptyRect(windowFrame)) … … 490 490 preferences._allowFileAccessFromFileURLs = YES; 491 491 [configuration setProcessPool: ::WebKit::wrapper(inspectorProcessPool())]; 492 [configuration _setGroupIdentifier:inspectorPageGroup ()->identifier()];492 [configuration _setGroupIdentifier:inspectorPageGroupIdentifier()]; 493 493 494 494 m_inspectorView = adoptNS([[WKWebInspectorWKWebView alloc] initWithFrame:initialRect configuration:configuration.get()]); … … 611 611 // then we need to reopen the Inspector to get it attached to the right window. 612 612 // This can happen when dragging tabs to another window in Safari. 613 if (m_isAttached && m_inspectorView.get().window != m_page->wkView().window) {613 if (m_isAttached && m_inspectorView.get().window != inspectedPage()->wkView().window) { 614 614 platformOpen(); 615 615 return; … … 720 720 721 721 NSString *frameString = NSStringFromRect([m_inspectorWindow frame]); 722 page()->pageGroup().preferences().setInspectorWindowFrame(frameString);722 inspectedPage()->pageGroup().preferences().setInspectorWindowFrame(frameString); 723 723 } 724 724 … … 728 728 return; 729 729 730 WKView *inspectedView = m_page->wkView();730 WKView *inspectedView = inspectedPage()->wkView(); 731 731 NSRect inspectedViewFrame = [inspectedView frame]; 732 732 NSRect inspectorFrame = NSZeroRect; … … 735 735 736 736 switch (m_attachmentSide) { 737 case AttachmentSideBottom: {738 739 740 741 742 743 744 745 746 747 748 749 750 case AttachmentSideRight: {751 752 753 754 755 756 757 758 759 760 761 762 763 737 case AttachmentSide::Bottom: { 738 if (!currentDimension) 739 currentDimension = NSHeight([m_inspectorView frame]); 740 741 CGFloat parentHeight = NSHeight(parentBounds); 742 CGFloat inspectorHeight = InspectorFrontendClientLocal::constrainedAttachedWindowHeight(currentDimension, parentHeight); 743 744 // Preserve the top position of the inspected view so banners in Safari still work. 745 inspectedViewFrame = NSMakeRect(0, inspectorHeight, NSWidth(parentBounds), inspectedViewTop - inspectorHeight); 746 inspectorFrame = NSMakeRect(0, 0, NSWidth(inspectedViewFrame), inspectorHeight); 747 break; 748 } 749 750 case AttachmentSide::Right: { 751 if (!currentDimension) 752 currentDimension = NSWidth([m_inspectorView frame]); 753 754 CGFloat parentWidth = NSWidth(parentBounds); 755 CGFloat inspectorWidth = InspectorFrontendClientLocal::constrainedAttachedWindowWidth(currentDimension, parentWidth); 756 757 // Preserve the top position of the inspected view so banners in Safari still work. But don't use that 758 // top position for the inspector view since the banners only stretch as wide as the the inspected view. 759 inspectedViewFrame = NSMakeRect(0, 0, parentWidth - inspectorWidth, inspectedViewTop); 760 CGFloat insetExcludingBanners = inspectedView._topContentInset - inspectedView._totalHeightOfBanners; 761 inspectorFrame = NSMakeRect(parentWidth - inspectorWidth, 0, inspectorWidth, NSHeight(parentBounds) - insetExcludingBanners); 762 break; 763 } 764 764 } 765 765 … … 778 778 unsigned WebInspectorProxy::platformInspectedWindowHeight() 779 779 { 780 WKView *inspectedView = m_page->wkView();780 WKView *inspectedView = inspectedPage()->wkView(); 781 781 NSRect inspectedViewRect = [inspectedView frame]; 782 782 return static_cast<unsigned>(inspectedViewRect.size.height); … … 785 785 unsigned WebInspectorProxy::platformInspectedWindowWidth() 786 786 { 787 WKView *inspectedView = m_page->wkView();787 WKView *inspectedView = inspectedPage()->wkView(); 788 788 NSRect inspectedViewRect = [inspectedView frame]; 789 789 return static_cast<unsigned>(inspectedViewRect.size.width); … … 792 792 void WebInspectorProxy::platformAttach() 793 793 { 794 WKView *inspectedView = m_page->wkView();794 WKView *inspectedView = inspectedPage()->wkView(); 795 795 [[NSNotificationCenter defaultCenter] addObserver:m_inspectorProxyObjCAdapter.get() selector:@selector(inspectedViewFrameDidChange:) name:NSViewFrameDidChangeNotification object:inspectedView]; 796 796 … … 806 806 807 807 switch (m_attachmentSide) { 808 case AttachmentSide Bottom:808 case AttachmentSide::Bottom: 809 809 [m_inspectorView setAutoresizingMask:NSViewWidthSizable | NSViewMaxYMargin]; 810 810 currentDimension = inspectorPagePreferences().inspectorAttachedHeight(); 811 811 break; 812 case AttachmentSide Right:812 case AttachmentSide::Right: 813 813 [m_inspectorView setAutoresizingMask:NSViewHeightSizable | NSViewMinXMargin]; 814 814 currentDimension = inspectorPagePreferences().inspectorAttachedWidth(); … … 825 825 void WebInspectorProxy::platformDetach() 826 826 { 827 WKView *inspectedView = m_page->wkView();827 WKView *inspectedView = inspectedPage()->wkView(); 828 828 [[NSNotificationCenter defaultCenter] removeObserver:m_inspectorProxyObjCAdapter.get() name:NSViewFrameDidChangeNotification object:inspectedView]; 829 829
Note: See TracChangeset
for help on using the changeset viewer.