| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 frame->loader().load(FrameLoadRequest(0, blankURL(), SubstituteData(data, "t
ext/html", "UTF-8", KURL(), ForceSynchronousLoad))); | 232 frame->loader().load(FrameLoadRequest(0, blankURL(), SubstituteData(data, "t
ext/html", "UTF-8", KURL(), ForceSynchronousLoad))); |
| 233 return true; | 233 return true; |
| 234 } | 234 } |
| 235 | 235 |
| 236 void WebPagePopupImpl::destroyPage() | 236 void WebPagePopupImpl::destroyPage() |
| 237 { | 237 { |
| 238 if (!m_page) | 238 if (!m_page) |
| 239 return; | 239 return; |
| 240 | 240 |
| 241 if (m_page->mainFrame()) | 241 if (m_page->mainFrame()) |
| 242 m_page->mainFrame()->loader().frameDetached(); | 242 toLocalFrame(m_page->mainFrame())->loader().frameDetached(); |
| 243 | 243 |
| 244 m_page->willBeDestroyed(); | 244 m_page->willBeDestroyed(); |
| 245 m_page.clear(); | 245 m_page.clear(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer) | 248 void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer) |
| 249 { | 249 { |
| 250 m_rootGraphicsLayer = layer; | 250 m_rootGraphicsLayer = layer; |
| 251 m_rootLayer = layer ? layer->platformLayer() : 0; | 251 m_rootLayer = layer ? layer->platformLayer() : 0; |
| 252 | 252 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 if (!m_closing) | 310 if (!m_closing) |
| 311 PageWidgetDelegate::paint(m_page.get(), 0, canvas, rect, PageWidgetDeleg
ate::Opaque); | 311 PageWidgetDelegate::paint(m_page.get(), 0, canvas, rect, PageWidgetDeleg
ate::Opaque); |
| 312 } | 312 } |
| 313 | 313 |
| 314 void WebPagePopupImpl::resize(const WebSize& newSize) | 314 void WebPagePopupImpl::resize(const WebSize& newSize) |
| 315 { | 315 { |
| 316 m_windowRectInScreen = WebRect(m_windowRectInScreen.x, m_windowRectInScreen.
y, newSize.width, newSize.height); | 316 m_windowRectInScreen = WebRect(m_windowRectInScreen.x, m_windowRectInScreen.
y, newSize.width, newSize.height); |
| 317 m_widgetClient->setWindowRect(m_windowRectInScreen); | 317 m_widgetClient->setWindowRect(m_windowRectInScreen); |
| 318 | 318 |
| 319 if (m_page) | 319 if (m_page) |
| 320 m_page->mainFrame()->view()->resize(newSize); | 320 toLocalFrame(m_page->mainFrame())->view()->resize(newSize); |
| 321 m_widgetClient->didInvalidateRect(WebRect(0, 0, newSize.width, newSize.heigh
t)); | 321 m_widgetClient->didInvalidateRect(WebRect(0, 0, newSize.width, newSize.heigh
t)); |
| 322 } | 322 } |
| 323 | 323 |
| 324 bool WebPagePopupImpl::handleKeyEvent(const WebKeyboardEvent&) | 324 bool WebPagePopupImpl::handleKeyEvent(const WebKeyboardEvent&) |
| 325 { | 325 { |
| 326 // The main WebView receives key events and forward them to this via handleK
eyEvent(). | 326 // The main WebView receives key events and forward them to this via handleK
eyEvent(). |
| 327 ASSERT_NOT_REACHED(); | 327 ASSERT_NOT_REACHED(); |
| 328 return false; | 328 return false; |
| 329 } | 329 } |
| 330 | 330 |
| 331 bool WebPagePopupImpl::handleCharEvent(const WebKeyboardEvent&) | 331 bool WebPagePopupImpl::handleCharEvent(const WebKeyboardEvent&) |
| 332 { | 332 { |
| 333 // The main WebView receives key events and forward them to this via handleK
eyEvent(). | 333 // The main WebView receives key events and forward them to this via handleK
eyEvent(). |
| 334 ASSERT_NOT_REACHED(); | 334 ASSERT_NOT_REACHED(); |
| 335 return false; | 335 return false; |
| 336 } | 336 } |
| 337 | 337 |
| 338 bool WebPagePopupImpl::handleGestureEvent(const WebGestureEvent& event) | 338 bool WebPagePopupImpl::handleGestureEvent(const WebGestureEvent& event) |
| 339 { | 339 { |
| 340 if (m_closing || !m_page || !m_page->mainFrame() || !m_page->mainFrame()->vi
ew()) | 340 if (m_closing || !m_page || !m_page->mainFrame() || !toLocalFrame(m_page->ma
inFrame())->view()) |
| 341 return false; | 341 return false; |
| 342 LocalFrame& frame = *m_page->mainFrame(); | 342 LocalFrame& frame = *toLocalFrame(m_page->mainFrame()); |
| 343 return frame.eventHandler().handleGestureEvent(PlatformGestureEventBuilder(f
rame.view(), event)); | 343 return frame.eventHandler().handleGestureEvent(PlatformGestureEventBuilder(f
rame.view(), event)); |
| 344 } | 344 } |
| 345 | 345 |
| 346 bool WebPagePopupImpl::handleInputEvent(const WebInputEvent& event) | 346 bool WebPagePopupImpl::handleInputEvent(const WebInputEvent& event) |
| 347 { | 347 { |
| 348 if (m_closing) | 348 if (m_closing) |
| 349 return false; | 349 return false; |
| 350 return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, event); | 350 return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, event); |
| 351 } | 351 } |
| 352 | 352 |
| 353 bool WebPagePopupImpl::handleKeyEvent(const PlatformKeyboardEvent& event) | 353 bool WebPagePopupImpl::handleKeyEvent(const PlatformKeyboardEvent& event) |
| 354 { | 354 { |
| 355 if (m_closing || !m_page->mainFrame() || !m_page->mainFrame()->view()) | 355 if (m_closing || !m_page->mainFrame() || !toLocalFrame(m_page->mainFrame())-
>view()) |
| 356 return false; | 356 return false; |
| 357 return m_page->mainFrame()->eventHandler().keyEvent(event); | 357 return toLocalFrame(m_page->mainFrame())->eventHandler().keyEvent(event); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void WebPagePopupImpl::setFocus(bool enable) | 360 void WebPagePopupImpl::setFocus(bool enable) |
| 361 { | 361 { |
| 362 if (!m_page) | 362 if (!m_page) |
| 363 return; | 363 return; |
| 364 m_page->focusController().setFocused(enable); | 364 m_page->focusController().setFocused(enable); |
| 365 if (enable) | 365 if (enable) |
| 366 m_page->focusController().setActive(true); | 366 m_page->focusController().setActive(true); |
| 367 } | 367 } |
| 368 | 368 |
| 369 void WebPagePopupImpl::close() | 369 void WebPagePopupImpl::close() |
| 370 { | 370 { |
| 371 m_closing = true; | 371 m_closing = true; |
| 372 destroyPage(); // In case closePopup() was not called. | 372 destroyPage(); // In case closePopup() was not called. |
| 373 m_widgetClient = 0; | 373 m_widgetClient = 0; |
| 374 deref(); | 374 deref(); |
| 375 } | 375 } |
| 376 | 376 |
| 377 void WebPagePopupImpl::closePopup() | 377 void WebPagePopupImpl::closePopup() |
| 378 { | 378 { |
| 379 if (m_page) { | 379 if (m_page) { |
| 380 m_page->mainFrame()->loader().stopAllLoaders(); | 380 toLocalFrame(m_page->mainFrame())->loader().stopAllLoaders(); |
| 381 ASSERT(m_page->mainFrame()->domWindow()); | 381 ASSERT(m_page->mainFrame()->domWindow()); |
| 382 DOMWindowPagePopup::uninstall(*m_page->mainFrame()->domWindow()); | 382 DOMWindowPagePopup::uninstall(*m_page->mainFrame()->domWindow()); |
| 383 } | 383 } |
| 384 m_closing = true; | 384 m_closing = true; |
| 385 | 385 |
| 386 destroyPage(); | 386 destroyPage(); |
| 387 | 387 |
| 388 // m_widgetClient might be 0 because this widget might be already closed. | 388 // m_widgetClient might be 0 because this widget might be already closed. |
| 389 if (m_widgetClient) { | 389 if (m_widgetClient) { |
| 390 // closeWidgetSoon() will call this->close() later. | 390 // closeWidgetSoon() will call this->close() later. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 403 // A WebPagePopupImpl instance usually has two references. | 403 // A WebPagePopupImpl instance usually has two references. |
| 404 // - One owned by the instance itself. It represents the visible widget. | 404 // - One owned by the instance itself. It represents the visible widget. |
| 405 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the | 405 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the |
| 406 // WebPagePopupImpl to close. | 406 // WebPagePopupImpl to close. |
| 407 // We need them because the closing operation is asynchronous and the widget | 407 // We need them because the closing operation is asynchronous and the widget |
| 408 // can be closed while the WebViewImpl is unaware of it. | 408 // can be closed while the WebViewImpl is unaware of it. |
| 409 return adoptRef(new WebPagePopupImpl(client)).leakRef(); | 409 return adoptRef(new WebPagePopupImpl(client)).leakRef(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 } // namespace blink | 412 } // namespace blink |
| OLD | NEW |