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