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

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

Issue 513723003: Add pixel readback to page popup (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed Created 6 years, 3 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 | Annotate | Revision Log
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 26 matching lines...) Expand all
37 #include "core/frame/Settings.h" 37 #include "core/frame/Settings.h"
38 #include "core/loader/EmptyClients.h" 38 #include "core/loader/EmptyClients.h"
39 #include "core/loader/FrameLoadRequest.h" 39 #include "core/loader/FrameLoadRequest.h"
40 #include "core/page/Chrome.h" 40 #include "core/page/Chrome.h"
41 #include "core/page/DOMWindowPagePopup.h" 41 #include "core/page/DOMWindowPagePopup.h"
42 #include "core/page/EventHandler.h" 42 #include "core/page/EventHandler.h"
43 #include "core/page/FocusController.h" 43 #include "core/page/FocusController.h"
44 #include "core/page/Page.h" 44 #include "core/page/Page.h"
45 #include "core/page/PagePopupClient.h" 45 #include "core/page/PagePopupClient.h"
46 #include "platform/TraceEvent.h" 46 #include "platform/TraceEvent.h"
47 #include "public/platform/WebCompositeAndReadbackAsyncCallback.h"
47 #include "public/platform/WebCursorInfo.h" 48 #include "public/platform/WebCursorInfo.h"
48 #include "public/web/WebAXObject.h" 49 #include "public/web/WebAXObject.h"
49 #include "public/web/WebFrameClient.h" 50 #include "public/web/WebFrameClient.h"
50 #include "public/web/WebViewClient.h" 51 #include "public/web/WebViewClient.h"
51 #include "public/web/WebWidgetClient.h" 52 #include "public/web/WebWidgetClient.h"
52 #include "web/WebInputEventConversion.h" 53 #include "web/WebInputEventConversion.h"
53 #include "web/WebLocalFrameImpl.h" 54 #include "web/WebLocalFrameImpl.h"
54 #include "web/WebSettingsImpl.h" 55 #include "web/WebSettingsImpl.h"
55 #include "web/WebViewImpl.h" 56 #include "web/WebViewImpl.h"
56 57
57 namespace blink { 58 namespace blink {
58 59
59 class PagePopupChromeClient : public EmptyChromeClient { 60 class PagePopupChromeClient : public EmptyChromeClient {
60 WTF_MAKE_NONCOPYABLE(PagePopupChromeClient); 61 WTF_MAKE_NONCOPYABLE(PagePopupChromeClient);
61 WTF_MAKE_FAST_ALLOCATED; 62 WTF_MAKE_FAST_ALLOCATED;
62 63
63 public: 64 public:
64 explicit PagePopupChromeClient(WebPagePopupImpl* popup) 65 explicit PagePopupChromeClient(WebPagePopupImpl* popup)
65 : m_popup(popup) 66 : m_popup(popup)
66 { 67 {
67 ASSERT(m_popup->widgetClient()); 68 ASSERT(m_popup->client());
68 } 69 }
69 70
70 private: 71 private:
71 virtual void closeWindowSoon() OVERRIDE 72 virtual void closeWindowSoon() OVERRIDE
72 { 73 {
73 m_popup->closePopup(); 74 m_popup->closePopup();
74 } 75 }
75 76
76 virtual FloatRect windowRect() OVERRIDE 77 virtual FloatRect windowRect() OVERRIDE
77 { 78 {
78 return FloatRect(m_popup->m_windowRectInScreen.x, m_popup->m_windowRectI nScreen.y, m_popup->m_windowRectInScreen.width, m_popup->m_windowRectInScreen.he ight); 79 return FloatRect(m_popup->m_windowRectInScreen.x, m_popup->m_windowRectI nScreen.y, m_popup->m_windowRectInScreen.width, m_popup->m_windowRectInScreen.he ight);
79 } 80 }
80 81
81 virtual void setWindowRect(const FloatRect& rect) OVERRIDE 82 virtual void setWindowRect(const FloatRect& rect) OVERRIDE
82 { 83 {
83 m_popup->m_windowRectInScreen = IntRect(rect); 84 m_popup->m_windowRectInScreen = IntRect(rect);
84 m_popup->widgetClient()->setWindowRect(m_popup->m_windowRectInScreen); 85 m_popup->client()->setWindowRect(m_popup->m_windowRectInScreen);
85 } 86 }
86 87
87 virtual IntRect rootViewToScreen(const IntRect& rect) const OVERRIDE 88 virtual IntRect rootViewToScreen(const IntRect& rect) const OVERRIDE
88 { 89 {
89 IntRect rectInScreen(rect); 90 IntRect rectInScreen(rect);
90 rectInScreen.move(m_popup->m_windowRectInScreen.x, m_popup->m_windowRect InScreen.y); 91 rectInScreen.move(m_popup->m_windowRectInScreen.x, m_popup->m_windowRect InScreen.y);
91 return rectInScreen; 92 return rectInScreen;
92 } 93 }
93 94
94 virtual void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, c onst String& message, unsigned lineNumber, const String&, const String&) OVERRID E 95 virtual void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, c onst String& message, unsigned lineNumber, const String&, const String&) OVERRID E
95 { 96 {
96 #ifndef NDEBUG 97 #ifndef NDEBUG
97 fprintf(stderr, "CONSOLE MESSSAGE:%u: %s\n", lineNumber, message.utf8(). data()); 98 fprintf(stderr, "CONSOLE MESSSAGE:%u: %s\n", lineNumber, message.utf8(). data());
98 #endif 99 #endif
99 } 100 }
100 101
101 virtual void invalidateContentsAndRootView(const IntRect& paintRect) OVERRID E 102 virtual void invalidateContentsAndRootView(const IntRect& paintRect) OVERRID E
102 { 103 {
103 if (paintRect.isEmpty()) 104 if (paintRect.isEmpty())
104 return; 105 return;
105 m_popup->widgetClient()->didInvalidateRect(paintRect); 106 m_popup->client()->didInvalidateRect(paintRect);
106 } 107 }
107 108
108 virtual void invalidateContentsForSlowScroll(const IntRect& updateRect) OVER RIDE 109 virtual void invalidateContentsForSlowScroll(const IntRect& updateRect) OVER RIDE
109 { 110 {
110 invalidateContentsAndRootView(updateRect); 111 invalidateContentsAndRootView(updateRect);
111 } 112 }
112 113
113 virtual void scheduleAnimation() OVERRIDE 114 virtual void scheduleAnimation() OVERRIDE
114 { 115 {
115 if (m_popup->isAcceleratedCompositingActive()) { 116 if (m_popup->isAcceleratedCompositingActive()) {
116 ASSERT(m_popup->m_layerTreeView); 117 ASSERT(m_popup->m_layerTreeView);
117 m_popup->m_layerTreeView->setNeedsAnimate(); 118 m_popup->m_layerTreeView->setNeedsAnimate();
118 return; 119 return;
119 } 120 }
120 m_popup->widgetClient()->scheduleAnimation(); 121 m_popup->client()->scheduleAnimation();
121 } 122 }
122 123
123 virtual WebScreenInfo screenInfo() const OVERRIDE 124 virtual WebScreenInfo screenInfo() const OVERRIDE
124 { 125 {
125 return m_popup->m_webView->client() ? m_popup->m_webView->client()->scre enInfo() : WebScreenInfo(); 126 return m_popup->m_webView->client() ? m_popup->m_webView->client()->scre enInfo() : WebScreenInfo();
126 } 127 }
127 128
128 virtual void* webView() const OVERRIDE 129 virtual void* webView() const OVERRIDE
129 { 130 {
130 return m_popup->m_webView; 131 return m_popup->m_webView;
131 } 132 }
132 133
133 virtual FloatSize minimumWindowSize() const OVERRIDE 134 virtual FloatSize minimumWindowSize() const OVERRIDE
134 { 135 {
135 return FloatSize(0, 0); 136 return FloatSize(0, 0);
136 } 137 }
137 138
138 virtual void setCursor(const Cursor& cursor) OVERRIDE 139 virtual void setCursor(const Cursor& cursor) OVERRIDE
139 { 140 {
140 if (m_popup->m_webView->client()) 141 if (m_popup->m_webView->client())
141 m_popup->m_webView->client()->didChangeCursor(WebCursorInfo(cursor)) ; 142 m_popup->m_webView->client()->didChangeCursor(WebCursorInfo(cursor)) ;
142 } 143 }
143 144
144 virtual void needTouchEvents(bool needsTouchEvents) OVERRIDE 145 virtual void needTouchEvents(bool needsTouchEvents) OVERRIDE
145 { 146 {
146 m_popup->widgetClient()->hasTouchEventHandlers(needsTouchEvents); 147 m_popup->client()->hasTouchEventHandlers(needsTouchEvents);
147 } 148 }
148 149
149 virtual GraphicsLayerFactory* graphicsLayerFactory() const OVERRIDE 150 virtual GraphicsLayerFactory* graphicsLayerFactory() const OVERRIDE
150 { 151 {
151 return m_popup->m_webView->graphicsLayerFactory(); 152 return m_popup->m_webView->graphicsLayerFactory();
152 } 153 }
153 154
154 virtual void attachRootGraphicsLayer(GraphicsLayer* graphicsLayer) OVERRIDE 155 virtual void attachRootGraphicsLayer(GraphicsLayer* graphicsLayer) OVERRIDE
155 { 156 {
156 m_popup->setRootGraphicsLayer(graphicsLayer); 157 m_popup->setRootGraphicsLayer(graphicsLayer);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 418
418 // m_widgetClient might be 0 because this widget might be already closed. 419 // m_widgetClient might be 0 because this widget might be already closed.
419 if (m_widgetClient) { 420 if (m_widgetClient) {
420 // closeWidgetSoon() will call this->close() later. 421 // closeWidgetSoon() will call this->close() later.
421 m_widgetClient->closeWidgetSoon(); 422 m_widgetClient->closeWidgetSoon();
422 } 423 }
423 424
424 m_popupClient->didClosePopup(); 425 m_popupClient->didClosePopup();
425 } 426 }
426 427
428 void WebPagePopupImpl::compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCal lback* callback)
429 {
430 ASSERT(isAcceleratedCompositingActive());
431 m_layerTreeView->compositeAndReadbackAsync(callback);
432 }
433
427 // WebPagePopup ---------------------------------------------------------------- 434 // WebPagePopup ----------------------------------------------------------------
428 435
429 WebPagePopup* WebPagePopup::create(WebWidgetClient* client) 436 WebPagePopup* WebPagePopup::create(WebWidgetClient* client)
430 { 437 {
431 if (!client) 438 if (!client)
432 CRASH(); 439 CRASH();
433 // A WebPagePopupImpl instance usually has two references. 440 // A WebPagePopupImpl instance usually has two references.
434 // - One owned by the instance itself. It represents the visible widget. 441 // - One owned by the instance itself. It represents the visible widget.
435 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the 442 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the
436 // WebPagePopupImpl to close. 443 // WebPagePopupImpl to close.
437 // We need them because the closing operation is asynchronous and the widget 444 // We need them because the closing operation is asynchronous and the widget
438 // can be closed while the WebViewImpl is unaware of it. 445 // can be closed while the WebViewImpl is unaware of it.
439 return adoptRef(new WebPagePopupImpl(client)).leakRef(); 446 return adoptRef(new WebPagePopupImpl(client)).leakRef();
440 } 447 }
441 448
442 } // namespace blink 449 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698