Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "platform/Cursor.h" | 42 #include "platform/Cursor.h" |
| 43 #include "platform/NotImplemented.h" | 43 #include "platform/NotImplemented.h" |
| 44 #include "platform/PlatformGestureEvent.h" | 44 #include "platform/PlatformGestureEvent.h" |
| 45 #include "platform/PlatformKeyboardEvent.h" | 45 #include "platform/PlatformKeyboardEvent.h" |
| 46 #include "platform/PlatformMouseEvent.h" | 46 #include "platform/PlatformMouseEvent.h" |
| 47 #include "platform/PlatformWheelEvent.h" | 47 #include "platform/PlatformWheelEvent.h" |
| 48 #include "platform/geometry/IntRect.h" | 48 #include "platform/geometry/IntRect.h" |
| 49 #include "platform/graphics/GraphicsContext.h" | 49 #include "platform/graphics/GraphicsContext.h" |
| 50 #include "platform/graphics/skia/SkiaUtils.h" | 50 #include "platform/graphics/skia/SkiaUtils.h" |
| 51 #include "platform/scroll/FramelessScrollView.h" | 51 #include "platform/scroll/FramelessScrollView.h" |
| 52 #include "public/platform/Platform.h" | |
| 53 #include "public/platform/WebCompositorSupport.h" | |
| 54 #include "public/platform/WebContentLayer.h" | |
| 55 #include "public/platform/WebLayerTreeView.h" | |
| 52 #include "public/platform/WebRect.h" | 56 #include "public/platform/WebRect.h" |
| 53 #include <skia/ext/platform_canvas.h> | 57 #include <skia/ext/platform_canvas.h> |
| 54 | 58 |
| 55 using namespace WebCore; | 59 using namespace WebCore; |
| 56 | 60 |
| 57 namespace blink { | 61 namespace blink { |
| 58 | 62 |
| 59 // WebPopupMenu --------------------------------------------------------------- | 63 // WebPopupMenu --------------------------------------------------------------- |
| 60 | 64 |
| 61 WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client) | 65 WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client) |
| 62 { | 66 { |
| 63 // Pass the WebPopupMenuImpl's self-reference to the caller. | 67 // Pass the WebPopupMenuImpl's self-reference to the caller. |
| 64 return adoptRef(new WebPopupMenuImpl(client)).leakRef(); | 68 return adoptRef(new WebPopupMenuImpl(client)).leakRef(); |
| 65 } | 69 } |
| 66 | 70 |
| 67 // WebWidget ------------------------------------------------------------------ | 71 // WebWidget ------------------------------------------------------------------ |
| 68 | 72 |
| 69 WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client) | 73 WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client) |
| 70 : m_client(client) | 74 : m_client(client) |
| 75 , m_layerTreeView(0) | |
| 71 , m_widget(0) | 76 , m_widget(0) |
| 72 { | 77 { |
| 73 // Set to impossible point so we always get the first mouse position. | 78 // Set to impossible point so we always get the first mouse position. |
| 74 m_lastMousePosition = WebPoint(-1, -1); | 79 m_lastMousePosition = WebPoint(-1, -1); |
| 75 } | 80 } |
| 76 | 81 |
| 77 WebPopupMenuImpl::~WebPopupMenuImpl() | 82 WebPopupMenuImpl::~WebPopupMenuImpl() |
| 78 { | 83 { |
| 79 if (m_widget) | 84 if (m_widget) |
| 80 m_widget->setClient(0); | 85 m_widget->setClient(0); |
| 81 } | 86 } |
| 82 | 87 |
| 88 void WebPopupMenuImpl::willCloseLayerTreeView() | |
| 89 { | |
| 90 enterForceCompositingMode(false); | |
| 91 m_layerTreeView = 0; | |
| 92 } | |
| 93 | |
| 83 void WebPopupMenuImpl::initialize(FramelessScrollView* widget, const WebRect& bo unds) | 94 void WebPopupMenuImpl::initialize(FramelessScrollView* widget, const WebRect& bo unds) |
| 84 { | 95 { |
| 85 m_widget = widget; | 96 m_widget = widget; |
| 86 m_widget->setClient(this); | 97 m_widget->setClient(this); |
| 87 | 98 |
| 88 if (m_client) { | 99 if (m_client) { |
| 89 m_client->setWindowRect(bounds); | 100 m_client->setWindowRect(bounds); |
| 90 m_client->show(WebNavigationPolicy()); // Policy is ignored. | 101 m_client->show(WebNavigationPolicy()); // Policy is ignored. |
| 91 } | 102 } |
| 92 } | 103 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 | 178 |
| 168 if (m_widget) { | 179 if (m_widget) { |
| 169 IntRect newGeometry(0, 0, m_size.width, m_size.height); | 180 IntRect newGeometry(0, 0, m_size.width, m_size.height); |
| 170 m_widget->setFrameRect(newGeometry); | 181 m_widget->setFrameRect(newGeometry); |
| 171 } | 182 } |
| 172 | 183 |
| 173 if (m_client) { | 184 if (m_client) { |
| 174 WebRect damagedRect(0, 0, m_size.width, m_size.height); | 185 WebRect damagedRect(0, 0, m_size.width, m_size.height); |
| 175 m_client->didInvalidateRect(damagedRect); | 186 m_client->didInvalidateRect(damagedRect); |
| 176 } | 187 } |
| 188 | |
| 189 if (m_rootLayer) | |
| 190 m_rootLayer->layer()->setBounds(newSize); | |
| 177 } | 191 } |
| 178 | 192 |
| 179 void WebPopupMenuImpl::willEndLiveResize() | 193 void WebPopupMenuImpl::willEndLiveResize() |
| 180 { | 194 { |
| 181 } | 195 } |
| 182 | 196 |
| 183 void WebPopupMenuImpl::animate(double) | 197 void WebPopupMenuImpl::animate(double) |
| 184 { | 198 { |
| 185 } | 199 } |
| 186 | 200 |
| 187 void WebPopupMenuImpl::layout() | 201 void WebPopupMenuImpl::layout() |
| 188 { | 202 { |
| 189 } | 203 } |
| 190 | 204 |
| 205 void WebPopupMenuImpl::enterForceCompositingMode(bool enter) | |
| 206 { | |
| 207 if (m_isAcceleratedCompositingActive == enter) | |
| 208 return; | |
| 209 | |
| 210 if (!enter) { | |
| 211 m_isAcceleratedCompositingActive = false; | |
| 212 m_client->didDeactivateCompositor(); | |
| 213 } else if (m_layerTreeView) { | |
| 214 m_isAcceleratedCompositingActive = true; | |
| 215 m_client->didActivateCompositor(0); | |
| 216 } else { | |
| 217 TRACE_EVENT0("webkit", "WebPopupMenuImpl::enterForceCompositingMode(true )"); | |
| 218 | |
| 219 m_client->initializeLayerTreeView(); | |
| 220 m_layerTreeView = m_client->layerTreeView(); | |
| 221 if (m_layerTreeView) { | |
| 222 m_layerTreeView->setVisible(true); | |
| 223 m_client->didActivateCompositor(0); | |
| 224 m_isAcceleratedCompositingActive = true; | |
| 225 m_layerTreeView->setDeviceScaleFactor(m_client->deviceScaleFactor()) ; | |
| 226 m_rootLayer = adoptPtr(Platform::current()->compositorSupport()->cre ateContentLayer(this)); | |
| 227 m_rootLayer->layer()->setBounds(m_size); | |
| 228 m_layerTreeView->setRootLayer(*m_rootLayer->layer()); | |
| 229 } else { | |
| 230 m_isAcceleratedCompositingActive = false; | |
| 231 m_client->didDeactivateCompositor(); | |
| 232 } | |
| 233 } | |
| 234 } | |
| 235 | |
| 236 void WebPopupMenuImpl::didExitCompositingMode() | |
| 237 { | |
| 238 enterForceCompositingMode(false); | |
| 239 m_client->didInvalidateRect(IntRect(0, 0, m_size.width, m_size.height)); | |
|
jamesr
2014/01/21 21:59:23
hmm, does this mean the popups are still switching
| |
| 240 } | |
| 241 | |
| 242 void WebPopupMenuImpl::paintContents(WebCanvas* canvas, const WebRect& rect, boo l, WebFloatRect&) | |
| 243 { | |
| 244 if (!m_widget) | |
| 245 return; | |
| 246 | |
| 247 if (!rect.isEmpty()) { | |
| 248 GraphicsContext context(canvas); | |
| 249 m_widget->paint(&context, rect); | |
| 250 } | |
| 251 } | |
| 252 | |
| 191 void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOption s) | 253 void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOption s) |
| 192 { | 254 { |
| 193 if (!m_widget) | 255 if (!m_widget) |
| 194 return; | 256 return; |
| 195 | 257 |
| 196 if (!rect.isEmpty()) { | 258 if (!rect.isEmpty()) { |
| 197 GraphicsContext context(canvas); | 259 GraphicsContext context(canvas); |
| 198 context.applyDeviceScaleFactor(m_client->deviceScaleFactor()); | 260 context.applyDeviceScaleFactor(m_client->deviceScaleFactor()); |
| 199 m_widget->paint(&context, rect); | 261 m_widget->paint(&context, rect); |
| 200 } | 262 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 | 398 |
| 337 //----------------------------------------------------------------------------- | 399 //----------------------------------------------------------------------------- |
| 338 // WebCore::HostWindow | 400 // WebCore::HostWindow |
| 339 | 401 |
| 340 void WebPopupMenuImpl::invalidateContentsAndRootView(const IntRect& paintRect) | 402 void WebPopupMenuImpl::invalidateContentsAndRootView(const IntRect& paintRect) |
| 341 { | 403 { |
| 342 if (paintRect.isEmpty()) | 404 if (paintRect.isEmpty()) |
| 343 return; | 405 return; |
| 344 if (m_client) | 406 if (m_client) |
| 345 m_client->didInvalidateRect(paintRect); | 407 m_client->didInvalidateRect(paintRect); |
| 408 if (m_rootLayer) | |
| 409 m_rootLayer->layer()->invalidateRect(FloatRect(paintRect)); | |
| 346 } | 410 } |
| 347 | 411 |
| 348 void WebPopupMenuImpl::invalidateContentsForSlowScroll(const IntRect& updateRect ) | 412 void WebPopupMenuImpl::invalidateContentsForSlowScroll(const IntRect& updateRect ) |
| 349 { | 413 { |
| 350 invalidateContentsAndRootView(updateRect); | 414 invalidateContentsAndRootView(updateRect); |
| 351 } | 415 } |
| 352 | 416 |
| 353 void WebPopupMenuImpl::scheduleAnimation() | 417 void WebPopupMenuImpl::scheduleAnimation() |
| 354 { | 418 { |
| 355 } | 419 } |
| 356 | 420 |
| 357 void WebPopupMenuImpl::scroll(const IntSize& scrollDelta, const IntRect& scrollR ect, const IntRect& clipRect) | 421 void WebPopupMenuImpl::scroll(const IntSize& scrollDelta, const IntRect& scrollR ect, const IntRect& clipRect) |
| 358 { | 422 { |
| 359 if (m_client) { | 423 if (m_client) { |
| 360 int dx = scrollDelta.width(); | 424 int dx = scrollDelta.width(); |
| 361 int dy = scrollDelta.height(); | 425 int dy = scrollDelta.height(); |
| 362 m_client->didScrollRect(dx, dy, clipRect); | 426 m_client->didScrollRect(dx, dy, clipRect); |
| 363 } | 427 } |
| 428 if (m_rootLayer) | |
| 429 m_rootLayer->layer()->invalidateRect(FloatRect(clipRect)); | |
| 364 } | 430 } |
| 365 | 431 |
| 366 IntPoint WebPopupMenuImpl::screenToRootView(const IntPoint& point) const | 432 IntPoint WebPopupMenuImpl::screenToRootView(const IntPoint& point) const |
| 367 { | 433 { |
| 368 notImplemented(); | 434 notImplemented(); |
| 369 return IntPoint(); | 435 return IntPoint(); |
| 370 } | 436 } |
| 371 | 437 |
| 372 IntRect WebPopupMenuImpl::rootViewToScreen(const IntRect& rect) const | 438 IntRect WebPopupMenuImpl::rootViewToScreen(const IntRect& rect) const |
| 373 { | 439 { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 388 ASSERT(widget == m_widget); | 454 ASSERT(widget == m_widget); |
| 389 if (m_widget) { | 455 if (m_widget) { |
| 390 m_widget->setClient(0); | 456 m_widget->setClient(0); |
| 391 m_widget = 0; | 457 m_widget = 0; |
| 392 } | 458 } |
| 393 if (m_client) | 459 if (m_client) |
| 394 m_client->closeWidgetSoon(); | 460 m_client->closeWidgetSoon(); |
| 395 } | 461 } |
| 396 | 462 |
| 397 } // namespace blink | 463 } // namespace blink |
| OLD | NEW |