Changeset 107028 in webkit
- Timestamp:
- Feb 7, 2012 7:20:07 PM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r107026 r107028 1 2012-02-07 Timothy Hatcher <timothy@apple.com> 2 3 Avoid making a window for the Web Inspector when it is docked. 4 5 This also makes sure the inspector WKView is in a window before the page is loaded. 6 This avoids some redundant work caused by moving it to a window later. 7 8 https://webkit.org/b/78064 9 10 Reviewed by Brian Weinstein. 11 12 * UIProcess/WebInspectorProxy.cpp: 13 (WebKit::WebInspectorProxy::createInspectorPage): Set m_isAttached here... 14 (WebKit::WebInspectorProxy::didLoadInspectorPage): ... instead of here. 15 * UIProcess/WebInspectorProxy.h: 16 (WebInspectorProxy): 17 * UIProcess/mac/WebInspectorProxyMac.mm: 18 (WebKit::WebInspectorProxy::createInspectorWindow): Added. Factored out of platformOpen. 19 (WebKit::WebInspectorProxy::updateInspectorWindowTitle): Added. Factored out of platformInspectedURLChanged. 20 (WebKit::WebInspectorProxy::platformCreateInspectorPage): Call platformAttach or createInspectorWindow. 21 (WebKit::WebInspectorProxy::platformOpen): Make the view or window visible. 22 (WebKit::WebInspectorProxy::platformDidClose): Only message m_inspectorWindow if it isn't nil. 23 (WebKit::WebInspectorProxy::platformInspectedURLChanged): Store the urlString and call updateInspectorWindowTitle. 24 (WebKit::WebInspectorProxy::inspectedViewFrameDidChange): Return early if not visible. 25 (WebKit::WebInspectorProxy::platformAttach): Start out hidden if we are not visible yet. Destroy the window. 26 (WebKit::WebInspectorProxy::platformDetach): Use createInspectorWindow to create it again. 27 1 28 2012-02-07 Tony Chang <tony@chromium.org> 2 29 -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp
r105571 r107028 208 208 return; 209 209 210 m_isAttached = shouldOpenAttached(); 211 210 212 WebPageProxy* inspectorPage = platformCreateInspectorPage(); 211 213 ASSERT(inspectorPage); … … 217 219 218 220 String url = inspectorPageURL(); 219 if ( shouldOpenAttached())221 if (m_isAttached) 220 222 url += "?docked=true"; 221 223 m_page->process()->assumeReadAccessToBaseURL(inspectorBaseURL()); … … 226 228 { 227 229 m_isVisible = true; 228 m_isAttached = shouldOpenAttached();229 230 230 231 // platformOpen is responsible for rendering attached mode depending on m_isAttached. -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h
r96383 r107028 35 35 #include <wtf/PassRefPtr.h> 36 36 #include <wtf/RefPtr.h> 37 #include <wtf/text/WTFString.h> 37 38 38 39 #if PLATFORM(MAC) … … 83 84 84 85 #if PLATFORM(MAC) 86 void createInspectorWindow(); 87 void updateInspectorWindowTitle() const; 85 88 void inspectedViewFrameDidChange(); 86 89 #elif PLATFORM(GTK) … … 176 179 RetainPtr<NSWindow> m_inspectorWindow; 177 180 RetainPtr<WKWebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter; 181 String m_urlString; 178 182 #elif PLATFORM(WIN) 179 183 HWND m_inspectorWindow; -
trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
r105571 r107028 100 100 namespace WebKit { 101 101 102 WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() 103 { 104 ASSERT(m_page); 105 ASSERT(!m_inspectorView); 106 107 m_inspectorView.adoptNS([[WKWebInspectorWKView alloc] initWithFrame:NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight) contextRef:toAPI(page()->process()->context()) pageGroupRef:toAPI(inspectorPageGroup())]); 108 ASSERT(m_inspectorView); 109 110 [m_inspectorView.get() setDrawsBackground:NO]; 111 112 return toImpl(m_inspectorView.get().pageRef); 113 } 114 115 void WebInspectorProxy::platformOpen() 102 void WebInspectorProxy::createInspectorWindow() 116 103 { 117 104 ASSERT(!m_inspectorWindow); 118 119 m_inspectorProxyObjCAdapter.adoptNS([[WKWebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]);120 105 121 106 bool useTexturedWindow = page()->process()->context()->overrideWebInspectorPagePath().isEmpty(); … … 136 121 } 137 122 123 NSView *contentView = [window contentView]; 124 [m_inspectorView.get() setFrame:[contentView bounds]]; 125 [contentView addSubview:m_inspectorView.get()]; 126 138 127 // Center the window initially before setting the frame autosave name so that the window will be in a good 139 128 // position if there is no saved frame yet. … … 141 130 [window setFrameAutosaveName:@"Web Inspector 2"]; 142 131 143 NSView *contentView = [window contentView]; 144 [m_inspectorView.get() setFrame:[contentView bounds]]; 132 m_inspectorWindow.adoptNS(window); 133 134 updateInspectorWindowTitle(); 135 } 136 137 void WebInspectorProxy::updateInspectorWindowTitle() const 138 { 139 if (!m_inspectorWindow) 140 return; 141 142 NSString *title = [NSString stringWithFormat:WEB_UI_STRING("Web Inspector — %@", "Web Inspector window title"), (NSString *)m_urlString]; 143 [m_inspectorWindow.get() setTitle:title]; 144 } 145 146 WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() 147 { 148 ASSERT(m_page); 149 ASSERT(!m_inspectorView); 150 151 m_inspectorView.adoptNS([[WKWebInspectorWKView alloc] initWithFrame:NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight) contextRef:toAPI(page()->process()->context()) pageGroupRef:toAPI(inspectorPageGroup())]); 152 ASSERT(m_inspectorView); 153 154 [m_inspectorView.get() setDrawsBackground:NO]; 145 155 [m_inspectorView.get() setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; 146 [contentView addSubview:m_inspectorView.get()]; 147 148 m_inspectorWindow.adoptNS(window); 156 157 m_inspectorProxyObjCAdapter.adoptNS([[WKWebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]); 149 158 150 159 if (m_isAttached) 151 160 platformAttach(); 152 161 else 153 [window makeKeyAndOrderFront:nil]; 162 createInspectorWindow(); 163 164 return toImpl(m_inspectorView.get().pageRef); 165 } 166 167 void WebInspectorProxy::platformOpen() 168 { 169 if (m_isAttached) { 170 // Make the inspector view visible since it was hidden while loading. 171 [m_inspectorView.get() setHidden:NO]; 172 173 // Adjust the frames now that we are visible and inspectedViewFrameDidChange wont return early. 174 inspectedViewFrameDidChange(); 175 } else 176 [m_inspectorWindow.get() makeKeyAndOrderFront:nil]; 154 177 } 155 178 156 179 void WebInspectorProxy::platformDidClose() 157 180 { 158 [m_inspectorWindow.get() setDelegate:nil]; 159 [m_inspectorWindow.get() orderOut:nil]; 160 161 m_inspectorWindow = 0; 181 if (m_inspectorWindow) { 182 [m_inspectorWindow.get() setDelegate:nil]; 183 [m_inspectorWindow.get() orderOut:nil]; 184 m_inspectorWindow = 0; 185 } 186 162 187 m_inspectorView = 0; 188 163 189 m_inspectorProxyObjCAdapter = 0; 164 190 } … … 172 198 void WebInspectorProxy::platformInspectedURLChanged(const String& urlString) 173 199 { 174 NSString *title = [NSString stringWithFormat:WEB_UI_STRING("Web Inspector — %@", "Web Inspector window title"), (NSString *)urlString]; 175 [m_inspectorWindow.get() setTitle:title]; 200 m_urlString = urlString; 201 202 updateInspectorWindowTitle(); 176 203 } 177 204 178 205 void WebInspectorProxy::inspectedViewFrameDidChange() 179 206 { 180 if (!m_isAttached )207 if (!m_isAttached || !m_isVisible) 181 208 return; 182 209 … … 188 215 CGFloat inspectedWidth = NSWidth(inspectedViewFrame); 189 216 CGFloat inspectorHeight = NSHeight([m_inspectorView.get() frame]); 190 217 191 218 CGFloat parentHeight = NSHeight([[inspectedView superview] frame]); 192 219 inspectorHeight = InspectorFrontendClientLocal::constrainedAttachedWindowHeight(inspectorHeight, parentHeight); … … 214 241 [m_inspectorView.get() setFrame:NSMakeRect(NSMinX(inspectedViewFrame), 0, NSWidth(inspectedViewFrame), inspectorPageGroup()->preferences()->inspectorAttachedHeight())]; 215 242 243 // Start out hidden if we are not visible yet. When platformOpen is called, hidden will be set to NO. 244 [m_inspectorView.get() setHidden:!m_isVisible]; 245 216 246 [[inspectedView superview] addSubview:m_inspectorView.get() positioned:NSWindowBelow relativeTo:inspectedView]; 217 247 218 [m_inspectorWindow.get() orderOut:nil]; 248 if (m_inspectorWindow) { 249 [m_inspectorWindow.get() setDelegate:nil]; 250 [m_inspectorWindow.get() orderOut:nil]; 251 m_inspectorWindow = 0; 252 } 219 253 220 254 inspectedViewFrameDidChange(); … … 228 262 [m_inspectorView.get() removeFromSuperview]; 229 263 230 // Move the inspector view back into the inspector window.231 NSView *inspectorWindowContentView = [m_inspectorWindow.get() contentView]; 232 [m_inspectorView.get() setFrame:[inspectorWindowContentView bounds]];233 [ inspectorWindowContentView addSubview:m_inspectorView.get()];264 createInspectorWindow(); 265 266 // Make the inspector view visible in case it is still hidden from loading while attached. 267 [m_inspectorView.get() setHidden:NO]; 234 268 235 269 // Make sure that we size the inspected view's frame after detaching so that it takes up the space that the
Note: See TracChangeset
for help on using the changeset viewer.