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

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

Issue 1894333002: Make WebWidget::resize early out if the size doesn't change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 months 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
« no previous file with comments | « third_party/WebKit/Source/web/WebPagePopupImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 DCHECK(m_popup->widgetClient()); 84 DCHECK(m_popup->widgetClient());
85 } 85 }
86 86
87 void closeWindowSoon() override 87 void closeWindowSoon() override
88 { 88 {
89 m_popup->closePopup(); 89 m_popup->closePopup();
90 } 90 }
91 91
92 IntRect windowRect() override 92 IntRect windowRect() override
93 { 93 {
94 return m_popup->m_windowRectInScreen; 94 return m_popup->windowRectInScreen();
95 } 95 }
96 96
97 IntRect viewportToScreen(const IntRect& rect, const Widget* widget) const ov erride 97 IntRect viewportToScreen(const IntRect& rect, const Widget* widget) const ov erride
98 { 98 {
99 WebRect rectInScreen(rect); 99 WebRect rectInScreen(rect);
100 WebRect windowRect = m_popup->windowRectInScreen();
100 m_popup->widgetClient()->convertViewportToWindow(&rectInScreen); 101 m_popup->widgetClient()->convertViewportToWindow(&rectInScreen);
101 rectInScreen.x += m_popup->m_windowRectInScreen.x; 102 rectInScreen.x += windowRect.x;
102 rectInScreen.y += m_popup->m_windowRectInScreen.y; 103 rectInScreen.y += windowRect.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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 Document* document = toLocalFrame(m_page->mainFrame())->document(); 331 Document* document = toLocalFrame(m_page->mainFrame())->document();
331 if (!document) 332 if (!document)
332 return 0; 333 return 0;
333 AXObjectCache* cache = document->axObjectCache(); 334 AXObjectCache* cache = document->axObjectCache();
334 DCHECK(cache); 335 DCHECK(cache);
335 return toAXObjectCacheImpl(cache)->getOrCreate(document->layoutView()); 336 return toAXObjectCacheImpl(cache)->getOrCreate(document->layoutView());
336 } 337 }
337 338
338 void WebPagePopupImpl::setWindowRect(const IntRect& rectInScreen) 339 void WebPagePopupImpl::setWindowRect(const IntRect& rectInScreen)
339 { 340 {
340 m_windowRectInScreen = rectInScreen; 341 widgetClient()->setWindowRect(rectInScreen);
341 widgetClient()->setWindowRect(m_windowRectInScreen);
342 } 342 }
343 343
344 void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer) 344 void WebPagePopupImpl::setRootGraphicsLayer(GraphicsLayer* layer)
345 { 345 {
346 m_rootGraphicsLayer = layer; 346 m_rootGraphicsLayer = layer;
347 m_rootLayer = layer ? layer->platformLayer() : 0; 347 m_rootLayer = layer ? layer->platformLayer() : 0;
348 348
349 setIsAcceleratedCompositingActive(layer); 349 setIsAcceleratedCompositingActive(layer);
350 if (m_layerTreeView) { 350 if (m_layerTreeView) {
351 if (m_rootLayer) { 351 if (m_rootLayer) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 { 409 {
410 if (!m_closing) 410 if (!m_closing)
411 PageWidgetDelegate::paint(*m_page, canvas, rect, *m_page->deprecatedLoca lMainFrame()); 411 PageWidgetDelegate::paint(*m_page, canvas, rect, *m_page->deprecatedLoca lMainFrame());
412 } 412 }
413 413
414 void WebPagePopupImpl::resize(const WebSize& newSizeInViewport) 414 void WebPagePopupImpl::resize(const WebSize& newSizeInViewport)
415 { 415 {
416 WebRect newSize(0, 0, newSizeInViewport.width, newSizeInViewport.height); 416 WebRect newSize(0, 0, newSizeInViewport.width, newSizeInViewport.height);
417 widgetClient()->convertViewportToWindow(&newSize); 417 widgetClient()->convertViewportToWindow(&newSize);
418 418
419 setWindowRect(WebRect(m_windowRectInScreen.x, m_windowRectInScreen.y, newSiz e.width, newSize.height)); 419 WebRect windowRect = windowRectInScreen();
420
421 if (windowRect.width != newSize.width
422 && windowRect.height != newSize.height) {
423 windowRect.width = newSize.width;
424 windowRect.height = newSize.height;
425 setWindowRect(windowRect);
426 }
427
420 if (m_page) { 428 if (m_page) {
421 toLocalFrame(m_page->mainFrame())->view()->resize(newSizeInViewport); 429 toLocalFrame(m_page->mainFrame())->view()->resize(newSizeInViewport);
422 m_page->frameHost().visualViewport().setSize(newSizeInViewport); 430 m_page->frameHost().visualViewport().setSize(newSizeInViewport);
423 } 431 }
424 432
425 m_widgetClient->didInvalidateRect(WebRect(0, 0, newSize.width, newSize.heigh t)); 433 m_widgetClient->didInvalidateRect(WebRect(0, 0, newSize.width, newSize.heigh t));
426 } 434 }
427 435
428 WebInputEventResult WebPagePopupImpl::handleKeyEvent(const WebKeyboardEvent& eve nt) 436 WebInputEventResult WebPagePopupImpl::handleKeyEvent(const WebKeyboardEvent& eve nt)
429 { 437 {
(...skipping 30 matching lines...) Expand all
460 if (isViewportPointInWindow(event.x, event.y)) 468 if (isViewportPointInWindow(event.x, event.y))
461 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); 469 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event);
462 cancel(); 470 cancel();
463 return WebInputEventResult::NotHandled; 471 return WebInputEventResult::NotHandled;
464 } 472 }
465 473
466 bool WebPagePopupImpl::isViewportPointInWindow(int x, int y) 474 bool WebPagePopupImpl::isViewportPointInWindow(int x, int y)
467 { 475 {
468 WebRect pointInWindow(x, y, 0, 0); 476 WebRect pointInWindow(x, y, 0, 0);
469 widgetClient()->convertViewportToWindow(&pointInWindow); 477 widgetClient()->convertViewportToWindow(&pointInWindow);
470 return IntRect(0, 0, m_windowRectInScreen.width, m_windowRectInScreen.height ).contains(IntPoint(pointInWindow.x, pointInWindow.y)); 478 WebRect windowRect = windowRectInScreen();
479 return IntRect(0, 0, windowRect.width, windowRect.height).contains(IntPoint( pointInWindow.x, pointInWindow.y));
471 } 480 }
472 481
473 WebInputEventResult WebPagePopupImpl::handleInputEvent(const WebInputEvent& even t) 482 WebInputEventResult WebPagePopupImpl::handleInputEvent(const WebInputEvent& even t)
474 { 483 {
475 if (m_closing) 484 if (m_closing)
476 return WebInputEventResult::NotHandled; 485 return WebInputEventResult::NotHandled;
477 return PageWidgetDelegate::handleInputEvent(*this, event, m_page->deprecated LocalMainFrame()); 486 return PageWidgetDelegate::handleInputEvent(*this, event, m_page->deprecated LocalMainFrame());
478 } 487 }
479 488
480 WebInputEventResult WebPagePopupImpl::handleKeyEvent(const PlatformKeyboardEvent & event) 489 WebInputEventResult WebPagePopupImpl::handleKeyEvent(const PlatformKeyboardEvent & event)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 } 549 }
541 550
542 void WebPagePopupImpl::compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCal lback* callback) 551 void WebPagePopupImpl::compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCal lback* callback)
543 { 552 {
544 DCHECK(isAcceleratedCompositingActive()); 553 DCHECK(isAcceleratedCompositingActive());
545 m_layerTreeView->compositeAndReadbackAsync(callback); 554 m_layerTreeView->compositeAndReadbackAsync(callback);
546 } 555 }
547 556
548 WebPoint WebPagePopupImpl::positionRelativeToOwner() 557 WebPoint WebPagePopupImpl::positionRelativeToOwner()
549 { 558 {
550 WebRect windowRect = m_webView->client()->rootWindowRect(); 559 WebRect rootWindowRect = m_webView->client()->rootWindowRect();
551 return WebPoint(m_windowRectInScreen.x - windowRect.x, m_windowRectInScreen. y - windowRect.y); 560 WebRect windowRect = windowRectInScreen();
561 return WebPoint(windowRect.x - rootWindowRect.x, windowRect.y - rootWindowRe ct.y);
552 } 562 }
553 563
554 void WebPagePopupImpl::cancel() 564 void WebPagePopupImpl::cancel()
555 { 565 {
556 if (m_popupClient) 566 if (m_popupClient)
557 m_popupClient->closePopup(); 567 m_popupClient->closePopup();
558 } 568 }
559 569
570 WebRect WebPagePopupImpl::windowRectInScreen() const
571 {
572 return widgetClient()->windowRect();
573 }
574
560 // WebPagePopup ---------------------------------------------------------------- 575 // WebPagePopup ----------------------------------------------------------------
561 576
562 WebPagePopup* WebPagePopup::create(WebWidgetClient* client) 577 WebPagePopup* WebPagePopup::create(WebWidgetClient* client)
563 { 578 {
564 if (!client) 579 if (!client)
565 CRASH(); 580 CRASH();
566 // A WebPagePopupImpl instance usually has two references. 581 // A WebPagePopupImpl instance usually has two references.
567 // - One owned by the instance itself. It represents the visible widget. 582 // - One owned by the instance itself. It represents the visible widget.
568 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the 583 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the
569 // WebPagePopupImpl to close. 584 // WebPagePopupImpl to close.
570 // We need them because the closing operation is asynchronous and the widget 585 // We need them because the closing operation is asynchronous and the widget
571 // can be closed while the WebViewImpl is unaware of it. 586 // can be closed while the WebViewImpl is unaware of it.
572 return adoptRef(new WebPagePopupImpl(client)).leakRef(); 587 return adoptRef(new WebPagePopupImpl(client)).leakRef();
573 } 588 }
574 589
575 } // namespace blink 590 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebPagePopupImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698