| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 class PagePopupChromeClient final : public EmptyChromeClient { | 69 class PagePopupChromeClient final : public EmptyChromeClient { |
| 70 public: | 70 public: |
| 71 static PassOwnPtrWillBeRawPtr<PagePopupChromeClient> create(WebPagePopupImpl
* popup) | 71 static PassOwnPtrWillBeRawPtr<PagePopupChromeClient> create(WebPagePopupImpl
* popup) |
| 72 { | 72 { |
| 73 return adoptPtrWillBeNoop(new PagePopupChromeClient(popup)); | 73 return adoptPtrWillBeNoop(new PagePopupChromeClient(popup)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void setWindowRect(const IntRect& rect) override | 76 void setWindowRect(const IntRect& rect) override |
| 77 { | 77 { |
| 78 m_popup->m_windowRectInScreen = rect; | 78 m_popup->setWindowRect(rect); |
| 79 m_popup->widgetClient()->setWindowRect(m_popup->m_windowRectInScreen); | |
| 80 } | 79 } |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 explicit PagePopupChromeClient(WebPagePopupImpl* popup) | 82 explicit PagePopupChromeClient(WebPagePopupImpl* popup) |
| 84 : m_popup(popup) | 83 : m_popup(popup) |
| 85 { | 84 { |
| 86 ASSERT(m_popup->widgetClient()); | 85 ASSERT(m_popup->widgetClient()); |
| 87 } | 86 } |
| 88 | 87 |
| 89 void closeWindowSoon() override | 88 void closeWindowSoon() override |
| 90 { | 89 { |
| 91 m_popup->closePopup(); | 90 m_popup->closePopup(); |
| 92 } | 91 } |
| 93 | 92 |
| 94 IntRect windowRect() override | 93 IntRect windowRect() override |
| 95 { | 94 { |
| 96 return IntRect(m_popup->m_windowRectInScreen.x, m_popup->m_windowRectInS
creen.y, m_popup->m_windowRectInScreen.width, m_popup->m_windowRectInScreen.heig
ht); | 95 return m_popup->m_windowRectInScreen; |
| 97 } | 96 } |
| 98 | 97 |
| 99 IntRect viewportToScreen(const IntRect& rect) const override | 98 IntRect viewportToScreen(const IntRect& rect) const override |
| 100 { | 99 { |
| 101 IntRect rectInScreen(rect); | 100 WebRect rectInScreen(rect); |
| 102 rectInScreen.move(m_popup->m_windowRectInScreen.x, m_popup->m_windowRect
InScreen.y); | 101 m_popup->widgetClient()->convertViewportToWindow(&rectInScreen); |
| 102 rectInScreen.x += m_popup->m_windowRectInScreen.x; |
| 103 rectInScreen.y += m_popup->m_windowRectInScreen.y; |
| 103 return rectInScreen; | 104 return rectInScreen; |
| 104 } | 105 } |
| 105 | 106 |
| 106 void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const Str
ing& message, unsigned lineNumber, const String&, const String&) override | 107 void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const Str
ing& message, unsigned lineNumber, const String&, const String&) override |
| 107 { | 108 { |
| 108 #ifndef NDEBUG | 109 #ifndef NDEBUG |
| 109 fprintf(stderr, "CONSOLE MESSSAGE:%u: %s\n", lineNumber, message.utf8().
data()); | 110 fprintf(stderr, "CONSOLE MESSSAGE:%u: %s\n", lineNumber, message.utf8().
data()); |
| 110 #endif | 111 #endif |
| 111 } | 112 } |
| 112 | 113 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 cache->childrenChanged(&m_popupClient->ownerElement()); | 265 cache->childrenChanged(&m_popupClient->ownerElement()); |
| 265 | 266 |
| 266 ASSERT(frame->localDOMWindow()); | 267 ASSERT(frame->localDOMWindow()); |
| 267 DOMWindowPagePopup::install(*frame->localDOMWindow(), *this, m_popupClient); | 268 DOMWindowPagePopup::install(*frame->localDOMWindow(), *this, m_popupClient); |
| 268 ASSERT(m_popupClient->ownerElement().document().existingAXObjectCache() == f
rame->document()->existingAXObjectCache()); | 269 ASSERT(m_popupClient->ownerElement().document().existingAXObjectCache() == f
rame->document()->existingAXObjectCache()); |
| 269 | 270 |
| 270 RefPtr<SharedBuffer> data = SharedBuffer::create(); | 271 RefPtr<SharedBuffer> data = SharedBuffer::create(); |
| 271 m_popupClient->writeDocument(data.get()); | 272 m_popupClient->writeDocument(data.get()); |
| 272 frame->loader().load(FrameLoadRequest(0, blankURL(), SubstituteData(data, "t
ext/html", "UTF-8", KURL(), ForceSynchronousLoad))); | 273 frame->loader().load(FrameLoadRequest(0, blankURL(), SubstituteData(data, "t
ext/html", "UTF-8", KURL(), ForceSynchronousLoad))); |
| 273 frame->setPageZoomFactor(m_popupClient->zoomFactor()); | 274 frame->setPageZoomFactor(m_popupClient->zoomFactor()); |
| 274 | |
| 275 return true; | 275 return true; |
| 276 } | 276 } |
| 277 | 277 |
| 278 void WebPagePopupImpl::postMessage(const String& message) | 278 void WebPagePopupImpl::postMessage(const String& message) |
| 279 { | 279 { |
| 280 if (!m_page) | 280 if (!m_page) |
| 281 return; | 281 return; |
| 282 ScriptForbiddenScope::AllowUserAgentScript allowScript; | 282 ScriptForbiddenScope::AllowUserAgentScript allowScript; |
| 283 if (LocalDOMWindow* window = toLocalFrame(m_page->mainFrame())->localDOMWind
ow()) | 283 if (LocalDOMWindow* window = toLocalFrame(m_page->mainFrame())->localDOMWind
ow()) |
| 284 window->dispatchEvent(MessageEvent::create(message)); | 284 window->dispatchEvent(MessageEvent::create(message)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 298 if (!m_page || !m_page->mainFrame()) | 298 if (!m_page || !m_page->mainFrame()) |
| 299 return 0; | 299 return 0; |
| 300 Document* document = toLocalFrame(m_page->mainFrame())->document(); | 300 Document* document = toLocalFrame(m_page->mainFrame())->document(); |
| 301 if (!document) | 301 if (!document) |
| 302 return 0; | 302 return 0; |
| 303 AXObjectCache* cache = document->axObjectCache(); | 303 AXObjectCache* cache = document->axObjectCache(); |
| 304 ASSERT(cache); | 304 ASSERT(cache); |
| 305 return toAXObjectCacheImpl(cache)->getOrCreate(document->layoutView()); | 305 return toAXObjectCacheImpl(cache)->getOrCreate(document->layoutView()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void WebPagePopupImpl::setWindowRect(const IntRect& rect) | 308 void WebPagePopupImpl::setWindowRect(const IntRect& rectInScreen) |
| 309 { | 309 { |
| 310 m_chromeClient->setWindowRect(rect); | 310 m_windowRectInScreen = rectInScreen; |
| 311 widgetClient()->setWindowRect(m_windowRectInScreen); |
| 311 } | 312 } |
| 312 | 313 |
| 313 void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer) | 314 void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer) |
| 314 { | 315 { |
| 315 m_rootGraphicsLayer = layer; | 316 m_rootGraphicsLayer = layer; |
| 316 m_rootLayer = layer ? layer->platformLayer() : 0; | 317 m_rootLayer = layer ? layer->platformLayer() : 0; |
| 317 | 318 |
| 318 setIsAcceleratedCompositingActive(layer); | 319 setIsAcceleratedCompositingActive(layer); |
| 319 if (m_layerTreeView) { | 320 if (m_layerTreeView) { |
| 320 if (m_rootLayer) { | 321 if (m_rootLayer) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 335 } else if (m_layerTreeView) { | 336 } else if (m_layerTreeView) { |
| 336 m_isAcceleratedCompositingActive = true; | 337 m_isAcceleratedCompositingActive = true; |
| 337 } else { | 338 } else { |
| 338 TRACE_EVENT0("blink", "WebPagePopupImpl::setIsAcceleratedCompositingActi
ve(true)"); | 339 TRACE_EVENT0("blink", "WebPagePopupImpl::setIsAcceleratedCompositingActi
ve(true)"); |
| 339 | 340 |
| 340 m_widgetClient->initializeLayerTreeView(); | 341 m_widgetClient->initializeLayerTreeView(); |
| 341 m_layerTreeView = m_widgetClient->layerTreeView(); | 342 m_layerTreeView = m_widgetClient->layerTreeView(); |
| 342 if (m_layerTreeView) { | 343 if (m_layerTreeView) { |
| 343 m_layerTreeView->setVisible(true); | 344 m_layerTreeView->setVisible(true); |
| 344 m_isAcceleratedCompositingActive = true; | 345 m_isAcceleratedCompositingActive = true; |
| 345 m_layerTreeView->setDeviceScaleFactor(m_webView->deviceScaleFactor()
); | |
| 346 m_page->layerTreeViewInitialized(*m_layerTreeView); | 346 m_page->layerTreeViewInitialized(*m_layerTreeView); |
| 347 } else { | 347 } else { |
| 348 m_isAcceleratedCompositingActive = false; | 348 m_isAcceleratedCompositingActive = false; |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 | 352 |
| 353 void WebPagePopupImpl::beginFrame(double lastFrameTimeMonotonic) | 353 void WebPagePopupImpl::beginFrame(double lastFrameTimeMonotonic) |
| 354 { | 354 { |
| 355 if (!m_page) | 355 if (!m_page) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 374 return; | 374 return; |
| 375 PageWidgetDelegate::updateAllLifecyclePhases(*m_page, *m_page->deprecatedLoc
alMainFrame()); | 375 PageWidgetDelegate::updateAllLifecyclePhases(*m_page, *m_page->deprecatedLoc
alMainFrame()); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void WebPagePopupImpl::paint(WebCanvas* canvas, const WebRect& rect) | 378 void WebPagePopupImpl::paint(WebCanvas* canvas, const WebRect& rect) |
| 379 { | 379 { |
| 380 if (!m_closing) | 380 if (!m_closing) |
| 381 PageWidgetDelegate::paint(*m_page, canvas, rect, *m_page->deprecatedLoca
lMainFrame()); | 381 PageWidgetDelegate::paint(*m_page, canvas, rect, *m_page->deprecatedLoca
lMainFrame()); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void WebPagePopupImpl::resize(const WebSize& newSize) | 384 void WebPagePopupImpl::resize(const WebSize& newSizeInViewport) |
| 385 { | 385 { |
| 386 m_windowRectInScreen = WebRect(m_windowRectInScreen.x, m_windowRectInScreen.
y, newSize.width, newSize.height); | 386 WebRect newSize(0, 0, newSizeInViewport.width, newSizeInViewport.height); |
| 387 m_widgetClient->setWindowRect(m_windowRectInScreen); | 387 widgetClient()->convertViewportToWindow(&newSize); |
| 388 | 388 |
| 389 setWindowRect(WebRect(m_windowRectInScreen.x, m_windowRectInScreen.y, newSiz
e.width, newSize.height)); |
| 389 if (m_page) { | 390 if (m_page) { |
| 390 toLocalFrame(m_page->mainFrame())->view()->resize(newSize); | 391 toLocalFrame(m_page->mainFrame())->view()->resize(newSizeInViewport); |
| 391 m_page->frameHost().visualViewport().setSize(newSize); | 392 m_page->frameHost().visualViewport().setSize(newSizeInViewport); |
| 392 } | 393 } |
| 393 | 394 |
| 394 m_widgetClient->didInvalidateRect(WebRect(0, 0, newSize.width, newSize.heigh
t)); | 395 m_widgetClient->didInvalidateRect(WebRect(0, 0, newSize.width, newSize.heigh
t)); |
| 395 } | 396 } |
| 396 | 397 |
| 397 WebInputEventResult WebPagePopupImpl::handleKeyEvent(const WebKeyboardEvent& eve
nt) | 398 WebInputEventResult WebPagePopupImpl::handleKeyEvent(const WebKeyboardEvent& eve
nt) |
| 398 { | 399 { |
| 399 return handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 400 return handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
| 400 } | 401 } |
| 401 | 402 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 // A WebPagePopupImpl instance usually has two references. | 536 // A WebPagePopupImpl instance usually has two references. |
| 536 // - One owned by the instance itself. It represents the visible widget. | 537 // - One owned by the instance itself. It represents the visible widget. |
| 537 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the | 538 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the |
| 538 // WebPagePopupImpl to close. | 539 // WebPagePopupImpl to close. |
| 539 // We need them because the closing operation is asynchronous and the widget | 540 // We need them because the closing operation is asynchronous and the widget |
| 540 // can be closed while the WebViewImpl is unaware of it. | 541 // can be closed while the WebViewImpl is unaware of it. |
| 541 return adoptRef(new WebPagePopupImpl(client)).leakRef(); | 542 return adoptRef(new WebPagePopupImpl(client)).leakRef(); |
| 542 } | 543 } |
| 543 | 544 |
| 544 } // namespace blink | 545 } // namespace blink |
| OLD | NEW |