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

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

Issue 1152413003: General code cleanup of ChromeClient-related classes. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "public/web/WebFrameClient.h" 58 #include "public/web/WebFrameClient.h"
59 #include "public/web/WebViewClient.h" 59 #include "public/web/WebViewClient.h"
60 #include "public/web/WebWidgetClient.h" 60 #include "public/web/WebWidgetClient.h"
61 #include "web/WebInputEventConversion.h" 61 #include "web/WebInputEventConversion.h"
62 #include "web/WebLocalFrameImpl.h" 62 #include "web/WebLocalFrameImpl.h"
63 #include "web/WebSettingsImpl.h" 63 #include "web/WebSettingsImpl.h"
64 #include "web/WebViewImpl.h" 64 #include "web/WebViewImpl.h"
65 65
66 namespace blink { 66 namespace blink {
67 67
68 class PagePopupChromeClient : public EmptyChromeClient { 68 class PagePopupChromeClient final : public EmptyChromeClient {
69 WTF_MAKE_NONCOPYABLE(PagePopupChromeClient); 69 WTF_MAKE_NONCOPYABLE(PagePopupChromeClient);
70 WTF_MAKE_FAST_ALLOCATED(PagePopupChromeClient); 70 WTF_MAKE_FAST_ALLOCATED(PagePopupChromeClient);
71 71
72 public: 72 public:
73 explicit PagePopupChromeClient(WebPagePopupImpl* popup) 73 explicit PagePopupChromeClient(WebPagePopupImpl* popup)
74 : m_popup(popup) 74 : m_popup(popup)
75 { 75 {
76 ASSERT(m_popup->widgetClient()); 76 ASSERT(m_popup->widgetClient());
77 } 77 }
78 78
79 virtual void setWindowRect(const IntRect& rect) override 79 void setWindowRect(const IntRect& rect) override
80 { 80 {
81 m_popup->m_windowRectInScreen = rect; 81 m_popup->m_windowRectInScreen = rect;
82 m_popup->widgetClient()->setWindowRect(m_popup->m_windowRectInScreen); 82 m_popup->widgetClient()->setWindowRect(m_popup->m_windowRectInScreen);
83 } 83 }
84 84
85 private: 85 private:
86 virtual void closeWindowSoon() override 86 void closeWindowSoon() override
87 { 87 {
88 m_popup->closePopup(); 88 m_popup->closePopup();
89 } 89 }
90 90
91 virtual IntRect windowRect() override 91 IntRect windowRect() override
92 { 92 {
93 return IntRect(m_popup->m_windowRectInScreen.x, m_popup->m_windowRectInS creen.y, m_popup->m_windowRectInScreen.width, m_popup->m_windowRectInScreen.heig ht); 93 return IntRect(m_popup->m_windowRectInScreen.x, m_popup->m_windowRectInS creen.y, m_popup->m_windowRectInScreen.width, m_popup->m_windowRectInScreen.heig ht);
94 } 94 }
95 95
96 virtual IntRect viewportToScreen(const IntRect& rect) const override 96 IntRect viewportToScreen(const IntRect& rect) const override
97 { 97 {
98 IntRect rectInScreen(rect); 98 IntRect rectInScreen(rect);
99 rectInScreen.move(m_popup->m_windowRectInScreen.x, m_popup->m_windowRect InScreen.y); 99 rectInScreen.move(m_popup->m_windowRectInScreen.x, m_popup->m_windowRect InScreen.y);
100 return rectInScreen; 100 return rectInScreen;
101 } 101 }
102 102
103 virtual void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, c onst String& message, unsigned lineNumber, const String&, const String&) overrid e 103 void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const Str ing& message, unsigned lineNumber, const String&, const String&) override
104 { 104 {
105 #ifndef NDEBUG 105 #ifndef NDEBUG
106 fprintf(stderr, "CONSOLE MESSSAGE:%u: %s\n", lineNumber, message.utf8(). data()); 106 fprintf(stderr, "CONSOLE MESSSAGE:%u: %s\n", lineNumber, message.utf8(). data());
107 #endif 107 #endif
108 } 108 }
109 109
110 virtual void invalidateRect(const IntRect& paintRect) override 110 void invalidateRect(const IntRect& paintRect) override
111 { 111 {
112 if (paintRect.isEmpty()) 112 if (!paintRect.isEmpty())
113 return; 113 m_popup->widgetClient()->didInvalidateRect(paintRect);
114 m_popup->widgetClient()->didInvalidateRect(paintRect);
115 } 114 }
116 115
117 virtual void scheduleAnimation() override 116 void scheduleAnimation() override
118 { 117 {
119 // Calling scheduleAnimation on m_webView so WebTestProxy will call begi nFrame. 118 // Calling scheduleAnimation on m_webView so WebTestProxy will call begi nFrame.
120 if (LayoutTestSupport::isRunningLayoutTest()) 119 if (LayoutTestSupport::isRunningLayoutTest())
121 m_popup->m_webView->scheduleAnimation(); 120 m_popup->m_webView->scheduleAnimation();
122 121
123 if (m_popup->isAcceleratedCompositingActive()) { 122 if (m_popup->isAcceleratedCompositingActive()) {
124 ASSERT(m_popup->m_layerTreeView); 123 ASSERT(m_popup->m_layerTreeView);
125 m_popup->m_layerTreeView->setNeedsAnimate(); 124 m_popup->m_layerTreeView->setNeedsAnimate();
126 return; 125 return;
127 } 126 }
128 m_popup->m_widgetClient->scheduleAnimation(); 127 m_popup->m_widgetClient->scheduleAnimation();
129 } 128 }
130 129
131 virtual WebScreenInfo screenInfo() const override 130 WebScreenInfo screenInfo() const override
132 { 131 {
133 return m_popup->m_webView->client() ? m_popup->m_webView->client()->scre enInfo() : WebScreenInfo(); 132 return m_popup->m_webView->client() ? m_popup->m_webView->client()->scre enInfo() : WebScreenInfo();
134 } 133 }
135 134
136 virtual void* webView() const override 135 void* webView() const override
137 { 136 {
138 return m_popup->m_webView; 137 return m_popup->m_webView;
139 } 138 }
140 139
141 virtual IntSize minimumWindowSize() const override 140 IntSize minimumWindowSize() const override
142 { 141 {
143 return IntSize(0, 0); 142 return IntSize(0, 0);
144 } 143 }
145 144
146 virtual void setCursorInternal(const Cursor& cursor) override 145 void setCursorInternal(const Cursor& cursor) override
147 { 146 {
148 if (m_popup->m_webView->client()) 147 if (m_popup->m_webView->client())
149 m_popup->m_webView->client()->didChangeCursor(WebCursorInfo(cursor)) ; 148 m_popup->m_webView->client()->didChangeCursor(WebCursorInfo(cursor)) ;
150 } 149 }
151 150
152 virtual void needTouchEvents(bool needsTouchEvents) override 151 void needTouchEvents(bool needsTouchEvents) override
153 { 152 {
154 m_popup->widgetClient()->hasTouchEventHandlers(needsTouchEvents); 153 m_popup->widgetClient()->hasTouchEventHandlers(needsTouchEvents);
155 } 154 }
156 155
157 virtual GraphicsLayerFactory* graphicsLayerFactory() const override 156 GraphicsLayerFactory* graphicsLayerFactory() const override
158 { 157 {
159 return m_popup->m_webView->graphicsLayerFactory(); 158 return m_popup->m_webView->graphicsLayerFactory();
160 } 159 }
161 160
162 virtual void attachRootGraphicsLayer(GraphicsLayer* graphicsLayer, LocalFram e* localRoot) override 161 void attachRootGraphicsLayer(GraphicsLayer* graphicsLayer, LocalFrame* local Root) override
163 { 162 {
164 m_popup->setRootGraphicsLayer(graphicsLayer); 163 m_popup->setRootGraphicsLayer(graphicsLayer);
165 } 164 }
166 165
167 virtual void postAccessibilityNotification(AXObject* obj, AXObjectCache::AXN otification notification) override 166 void postAccessibilityNotification(AXObject* obj, AXObjectCache::AXNotificat ion notification) override
168 { 167 {
169 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(m_popup->m_popup Client->ownerElement().document().frame()); 168 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(m_popup->m_popup Client->ownerElement().document().frame());
170 if (obj && frame && frame->client()) 169 if (obj && frame && frame->client())
171 frame->client()->postAccessibilityEvent(WebAXObject(obj), static_cas t<WebAXEvent>(notification)); 170 frame->client()->postAccessibilityEvent(WebAXObject(obj), static_cas t<WebAXEvent>(notification));
172 171
173 // FIXME: Delete these lines once Chromium only uses the frame client in terface, above. 172 // FIXME: Delete these lines once Chromium only uses the frame client in terface, above.
174 if (obj && m_popup->m_webView->client()) 173 if (obj && m_popup->m_webView->client())
175 m_popup->m_webView->client()->postAccessibilityEvent(WebAXObject(obj ), static_cast<WebAXEvent>(notification)); 174 m_popup->m_webView->client()->postAccessibilityEvent(WebAXObject(obj ), static_cast<WebAXEvent>(notification));
176 } 175 }
177 176
178 virtual void setToolTip(const String& tooltipText, TextDirection dir) overri de 177 void setToolTip(const String& tooltipText, TextDirection dir) override
179 { 178 {
180 if (m_popup->widgetClient()) 179 if (m_popup->widgetClient())
181 m_popup->widgetClient()->setToolTipText(tooltipText, toWebTextDirect ion(dir)); 180 m_popup->widgetClient()->setToolTipText(tooltipText, toWebTextDirect ion(dir));
182 } 181 }
183 182
184 WebPagePopupImpl* m_popup; 183 WebPagePopupImpl* m_popup;
185 }; 184 };
186 185
187 class PagePopupFeaturesClient : public ContextFeaturesClient { 186 class PagePopupFeaturesClient : public ContextFeaturesClient {
188 virtual bool isEnabled(Document*, ContextFeatures::FeatureType, bool) overri de; 187 bool isEnabled(Document*, ContextFeatures::FeatureType, bool) override;
189 }; 188 };
190 189
191 bool PagePopupFeaturesClient::isEnabled(Document*, ContextFeatures::FeatureType type, bool defaultValue) 190 bool PagePopupFeaturesClient::isEnabled(Document*, ContextFeatures::FeatureType type, bool defaultValue)
192 { 191 {
193 if (type == ContextFeatures::PagePopup) 192 if (type == ContextFeatures::PagePopup)
194 return true; 193 return true;
195 return defaultValue; 194 return defaultValue;
196 } 195 }
197 196
198 // WebPagePopupImpl ------------------------------------------------------------ ---- 197 // WebPagePopupImpl ------------------------------------------------------------ ----
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 // A WebPagePopupImpl instance usually has two references. 519 // A WebPagePopupImpl instance usually has two references.
521 // - One owned by the instance itself. It represents the visible widget. 520 // - One owned by the instance itself. It represents the visible widget.
522 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the 521 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the
523 // WebPagePopupImpl to close. 522 // WebPagePopupImpl to close.
524 // We need them because the closing operation is asynchronous and the widget 523 // We need them because the closing operation is asynchronous and the widget
525 // can be closed while the WebViewImpl is unaware of it. 524 // can be closed while the WebViewImpl is unaware of it.
526 return adoptRef(new WebPagePopupImpl(client)).leakRef(); 525 return adoptRef(new WebPagePopupImpl(client)).leakRef();
527 } 526 }
528 527
529 } // namespace blink 528 } // namespace blink
OLDNEW
« Source/core/svg/graphics/SVGImageChromeClient.h ('K') | « Source/web/ChromeClientImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698