Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: third_party/WebKit/Source/web/WebPagePopupImpl.cpp

Issue 1456753002: Compute the popup location/size correctly when use-zoom-for-dsf is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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()->convertViewportToScreen(&rectInScreen);
103 return rectInScreen; 102 return rectInScreen;
104 } 103 }
105 104
106 void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const Str ing& message, unsigned lineNumber, const String&, const String&) override 105 void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const Str ing& message, unsigned lineNumber, const String&, const String&) override
107 { 106 {
108 #ifndef NDEBUG 107 #ifndef NDEBUG
109 fprintf(stderr, "CONSOLE MESSSAGE:%u: %s\n", lineNumber, message.utf8(). data()); 108 fprintf(stderr, "CONSOLE MESSSAGE:%u: %s\n", lineNumber, message.utf8(). data());
110 #endif 109 #endif
111 } 110 }
112 111
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 bool WebPagePopupImpl::initializePage() 242 bool WebPagePopupImpl::initializePage()
244 { 243 {
245 Page::PageClients pageClients; 244 Page::PageClients pageClients;
246 fillWithEmptyClients(pageClients); 245 fillWithEmptyClients(pageClients);
247 m_chromeClient = PagePopupChromeClient::create(this); 246 m_chromeClient = PagePopupChromeClient::create(this);
248 pageClients.chromeClient = m_chromeClient.get(); 247 pageClients.chromeClient = m_chromeClient.get();
249 248
250 m_page = adoptPtrWillBeNoop(new Page(pageClients)); 249 m_page = adoptPtrWillBeNoop(new Page(pageClients));
251 m_page->settings().setScriptEnabled(true); 250 m_page->settings().setScriptEnabled(true);
252 m_page->settings().setAllowScriptsToCloseWindows(true); 251 m_page->settings().setAllowScriptsToCloseWindows(true);
253 m_page->setDeviceScaleFactor(m_webView->deviceScaleFactor());
254 m_page->settings().setDeviceSupportsTouch(m_webView->page()->settings().devi ceSupportsTouch()); 252 m_page->settings().setDeviceSupportsTouch(m_webView->page()->settings().devi ceSupportsTouch());
255 // FIXME: Should we support enabling a11y while a popup is shown? 253 // FIXME: Should we support enabling a11y while a popup is shown?
256 m_page->settings().setAccessibilityEnabled(m_webView->page()->settings().acc essibilityEnabled()); 254 m_page->settings().setAccessibilityEnabled(m_webView->page()->settings().acc essibilityEnabled());
257 m_page->settings().setScrollAnimatorEnabled(m_webView->page()->settings().sc rollAnimatorEnabled()); 255 m_page->settings().setScrollAnimatorEnabled(m_webView->page()->settings().sc rollAnimatorEnabled());
258 256
259 provideContextFeaturesTo(*m_page, adoptPtr(new PagePopupFeaturesClient())); 257 provideContextFeaturesTo(*m_page, adoptPtr(new PagePopupFeaturesClient()));
260 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<FrameLoaderClient>, emptyFrameLoa derClient, (EmptyFrameLoaderClient::create())); 258 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<FrameLoaderClient>, emptyFrameLoa derClient, (EmptyFrameLoaderClient::create()));
261 RefPtrWillBeRawPtr<LocalFrame> frame = LocalFrame::create(emptyFrameLoaderCl ient.get(), &m_page->frameHost(), 0); 259 RefPtrWillBeRawPtr<LocalFrame> frame = LocalFrame::create(emptyFrameLoaderCl ient.get(), &m_page->frameHost(), 0);
262 frame->setPagePopupOwner(m_popupClient->ownerElement()); 260 frame->setPagePopupOwner(m_popupClient->ownerElement());
263 frame->setView(FrameView::create(frame.get())); 261 frame->setView(FrameView::create(frame.get()));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if (!m_page || !m_page->mainFrame()) 299 if (!m_page || !m_page->mainFrame())
302 return 0; 300 return 0;
303 Document* document = toLocalFrame(m_page->mainFrame())->document(); 301 Document* document = toLocalFrame(m_page->mainFrame())->document();
304 if (!document) 302 if (!document)
305 return 0; 303 return 0;
306 AXObjectCache* cache = document->axObjectCache(); 304 AXObjectCache* cache = document->axObjectCache();
307 ASSERT(cache); 305 ASSERT(cache);
308 return toAXObjectCacheImpl(cache)->getOrCreate(document->layoutView()); 306 return toAXObjectCacheImpl(cache)->getOrCreate(document->layoutView());
309 } 307 }
310 308
311 void WebPagePopupImpl::setWindowRect(const IntRect& rect) 309 void WebPagePopupImpl::setWindowRect(const IntRect& rectInScreen)
312 { 310 {
313 m_chromeClient->setWindowRect(rect); 311 m_windowRectInScreen = rectInScreen;
312 widgetClient()->setWindowRect(m_windowRectInScreen);
314 } 313 }
315 314
316 void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer) 315 void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer)
317 { 316 {
318 m_rootGraphicsLayer = layer; 317 m_rootGraphicsLayer = layer;
319 m_rootLayer = layer ? layer->platformLayer() : 0; 318 m_rootLayer = layer ? layer->platformLayer() : 0;
320 319
321 setIsAcceleratedCompositingActive(layer); 320 setIsAcceleratedCompositingActive(layer);
322 if (m_layerTreeView) { 321 if (m_layerTreeView) {
323 if (m_rootLayer) { 322 if (m_rootLayer) {
(...skipping 14 matching lines...) Expand all
338 } else if (m_layerTreeView) { 337 } else if (m_layerTreeView) {
339 m_isAcceleratedCompositingActive = true; 338 m_isAcceleratedCompositingActive = true;
340 } else { 339 } else {
341 TRACE_EVENT0("blink", "WebPagePopupImpl::setIsAcceleratedCompositingActi ve(true)"); 340 TRACE_EVENT0("blink", "WebPagePopupImpl::setIsAcceleratedCompositingActi ve(true)");
342 341
343 m_widgetClient->initializeLayerTreeView(); 342 m_widgetClient->initializeLayerTreeView();
344 m_layerTreeView = m_widgetClient->layerTreeView(); 343 m_layerTreeView = m_widgetClient->layerTreeView();
345 if (m_layerTreeView) { 344 if (m_layerTreeView) {
346 m_layerTreeView->setVisible(true); 345 m_layerTreeView->setVisible(true);
347 m_isAcceleratedCompositingActive = true; 346 m_isAcceleratedCompositingActive = true;
348 m_layerTreeView->setDeviceScaleFactor(m_webView->deviceScaleFactor() );
349 } else { 347 } else {
350 m_isAcceleratedCompositingActive = false; 348 m_isAcceleratedCompositingActive = false;
351 } 349 }
352 } 350 }
353 } 351 }
354 352
355 WebSize WebPagePopupImpl::size() 353 WebSize WebPagePopupImpl::size()
356 { 354 {
357 return m_popupClient->contentSize(); 355 return m_popupClient->contentSize();
358 } 356 }
(...skipping 19 matching lines...) Expand all
378 return; 376 return;
379 PageWidgetDelegate::updateAllLifecyclePhases(*m_page, *m_page->deprecatedLoc alMainFrame()); 377 PageWidgetDelegate::updateAllLifecyclePhases(*m_page, *m_page->deprecatedLoc alMainFrame());
380 } 378 }
381 379
382 void WebPagePopupImpl::paint(WebCanvas* canvas, const WebRect& rect) 380 void WebPagePopupImpl::paint(WebCanvas* canvas, const WebRect& rect)
383 { 381 {
384 if (!m_closing) 382 if (!m_closing)
385 PageWidgetDelegate::paint(*m_page, canvas, rect, *m_page->deprecatedLoca lMainFrame()); 383 PageWidgetDelegate::paint(*m_page, canvas, rect, *m_page->deprecatedLoca lMainFrame());
386 } 384 }
387 385
388 void WebPagePopupImpl::resize(const WebSize& newSize) 386 void WebPagePopupImpl::resize(const WebSize& newSizeInViewport)
389 { 387 {
390 m_windowRectInScreen = WebRect(m_windowRectInScreen.x, m_windowRectInScreen. y, newSize.width, newSize.height); 388 WebRect newSize(0, 0, newSizeInViewport.width, newSizeInViewport.height);
391 m_widgetClient->setWindowRect(m_windowRectInScreen); 389 widgetClient()->convertViewportToScreen(&newSize);
392 390
391 setWindowRect(WebRect(m_windowRectInScreen.x, m_windowRectInScreen.y, newSiz e.width, newSize.height));
393 if (m_page) { 392 if (m_page) {
394 toLocalFrame(m_page->mainFrame())->view()->resize(newSize); 393 toLocalFrame(m_page->mainFrame())->view()->resize(newSizeInViewport);
395 m_page->frameHost().visualViewport().setSize(newSize); 394 m_page->frameHost().visualViewport().setSize(newSizeInViewport);
396 } 395 }
397 396
398 m_widgetClient->didInvalidateRect(WebRect(0, 0, newSize.width, newSize.heigh t)); 397 m_widgetClient->didInvalidateRect(WebRect(0, 0, newSize.width, newSize.heigh t));
399 } 398 }
400 399
401 bool WebPagePopupImpl::handleKeyEvent(const WebKeyboardEvent& event) 400 bool WebPagePopupImpl::handleKeyEvent(const WebKeyboardEvent& event)
402 { 401 {
403 return handleKeyEvent(PlatformKeyboardEventBuilder(event)); 402 return handleKeyEvent(PlatformKeyboardEventBuilder(event));
404 } 403 }
405 404
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 // A WebPagePopupImpl instance usually has two references. 538 // A WebPagePopupImpl instance usually has two references.
540 // - One owned by the instance itself. It represents the visible widget. 539 // - One owned by the instance itself. It represents the visible widget.
541 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the 540 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the
542 // WebPagePopupImpl to close. 541 // WebPagePopupImpl to close.
543 // We need them because the closing operation is asynchronous and the widget 542 // We need them because the closing operation is asynchronous and the widget
544 // can be closed while the WebViewImpl is unaware of it. 543 // can be closed while the WebViewImpl is unaware of it.
545 return adoptRef(new WebPagePopupImpl(client)).leakRef(); 544 return adoptRef(new WebPagePopupImpl(client)).leakRef();
546 } 545 }
547 546
548 } // namespace blink 547 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698