| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 { | 67 { |
| 68 // Pass the WebPopupMenuImpl's self-reference to the caller. | 68 // Pass the WebPopupMenuImpl's self-reference to the caller. |
| 69 return adoptRef(new WebPopupMenuImpl(client)).leakRef(); | 69 return adoptRef(new WebPopupMenuImpl(client)).leakRef(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // WebWidget ------------------------------------------------------------------ | 72 // WebWidget ------------------------------------------------------------------ |
| 73 | 73 |
| 74 WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client) | 74 WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client) |
| 75 : m_client(client) | 75 : m_client(client) |
| 76 , m_layerTreeView(0) | 76 , m_layerTreeView(0) |
| 77 , m_isAcceleratedCompositingActive(false) | |
| 78 // 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. |
| 79 , m_lastMousePosition(WebPoint(-1, -1)) | 78 , m_lastMousePosition(WebPoint(-1, -1)) |
| 80 , m_widget(0) | 79 , m_widget(0) |
| 81 { | 80 { |
| 82 } | 81 } |
| 83 | 82 |
| 84 WebPopupMenuImpl::~WebPopupMenuImpl() | 83 WebPopupMenuImpl::~WebPopupMenuImpl() |
| 85 { | 84 { |
| 86 if (m_widget) | 85 if (m_widget) |
| 87 m_widget->setClient(0); | 86 m_widget->setClient(0); |
| 88 } | 87 } |
| 89 | 88 |
| 90 void WebPopupMenuImpl::willCloseLayerTreeView() | 89 void WebPopupMenuImpl::willCloseLayerTreeView() |
| 91 { | 90 { |
| 92 enterForceCompositingMode(false); | |
| 93 m_layerTreeView = 0; | 91 m_layerTreeView = 0; |
| 94 } | 92 } |
| 95 | 93 |
| 96 void WebPopupMenuImpl::initialize(FramelessScrollView* widget, const WebRect& bo
unds) | 94 void WebPopupMenuImpl::initialize(FramelessScrollView* widget, const WebRect& bo
unds) |
| 97 { | 95 { |
| 98 m_widget = widget; | 96 m_widget = widget; |
| 99 m_widget->setClient(this); | 97 m_widget->setClient(this); |
| 100 | 98 |
| 101 if (m_client) { | 99 if (m_client) { |
| 102 m_client->setWindowRect(bounds); | 100 m_client->setWindowRect(bounds); |
| 103 m_client->show(WebNavigationPolicy()); // Policy is ignored. | 101 m_client->show(WebNavigationPolicy()); // Policy is ignored. |
| 104 } | 102 } |
| 103 |
| 104 m_client->initializeLayerTreeView(); |
| 105 m_layerTreeView = m_client->layerTreeView(); |
| 106 if (m_layerTreeView) { |
| 107 m_layerTreeView->setVisible(true); |
| 108 m_client->didActivateCompositor(); |
| 109 m_layerTreeView->setDeviceScaleFactor(m_client->deviceScaleFactor()); |
| 110 m_rootLayer = adoptPtr(Platform::current()->compositorSupport()->createC
ontentLayer(this)); |
| 111 m_rootLayer->layer()->setBounds(m_size); |
| 112 m_layerTreeView->setRootLayer(*m_rootLayer->layer()); |
| 113 } else { |
| 114 m_client->didDeactivateCompositor(); |
| 115 } |
| 105 } | 116 } |
| 106 | 117 |
| 107 void WebPopupMenuImpl::handleMouseMove(const WebMouseEvent& event) | 118 void WebPopupMenuImpl::handleMouseMove(const WebMouseEvent& event) |
| 108 { | 119 { |
| 109 // Don't send mouse move messages if the mouse hasn't moved. | 120 // Don't send mouse move messages if the mouse hasn't moved. |
| 110 if (event.x != m_lastMousePosition.x || event.y != m_lastMousePosition.y) { | 121 if (event.x != m_lastMousePosition.x || event.y != m_lastMousePosition.y) { |
| 111 m_lastMousePosition = WebPoint(event.x, event.y); | 122 m_lastMousePosition = WebPoint(event.x, event.y); |
| 112 m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event
)); | 123 m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event
)); |
| 113 | 124 |
| 114 // We cannot call setToolTipText() in PopupContainer, because PopupConta
iner is in WebCore, and we cannot refer to WebKit from Webcore. | 125 // We cannot call setToolTipText() in PopupContainer, because PopupConta
iner is in WebCore, and we cannot refer to WebKit from Webcore. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 208 } |
| 198 | 209 |
| 199 void WebPopupMenuImpl::animate(double) | 210 void WebPopupMenuImpl::animate(double) |
| 200 { | 211 { |
| 201 } | 212 } |
| 202 | 213 |
| 203 void WebPopupMenuImpl::layout() | 214 void WebPopupMenuImpl::layout() |
| 204 { | 215 { |
| 205 } | 216 } |
| 206 | 217 |
| 207 void WebPopupMenuImpl::enterForceCompositingMode(bool enter) | |
| 208 { | |
| 209 // FIXME: Is this function really correct? The other overrides of this funct
ion | |
| 210 // just used to set forceCompositingMode before we removed that setting. | |
| 211 // crbug.com/378029 | |
| 212 if (m_isAcceleratedCompositingActive == enter) | |
| 213 return; | |
| 214 | |
| 215 if (!enter) { | |
| 216 m_isAcceleratedCompositingActive = false; | |
| 217 m_client->didDeactivateCompositor(); | |
| 218 } else if (m_layerTreeView) { | |
| 219 m_isAcceleratedCompositingActive = true; | |
| 220 m_client->didActivateCompositor(); | |
| 221 } else { | |
| 222 TRACE_EVENT0("webkit", "WebPopupMenuImpl::enterForceCompositingMode(true
)"); | |
| 223 | |
| 224 m_client->initializeLayerTreeView(); | |
| 225 m_layerTreeView = m_client->layerTreeView(); | |
| 226 if (m_layerTreeView) { | |
| 227 m_layerTreeView->setVisible(true); | |
| 228 m_client->didActivateCompositor(); | |
| 229 m_isAcceleratedCompositingActive = true; | |
| 230 m_layerTreeView->setDeviceScaleFactor(m_client->deviceScaleFactor())
; | |
| 231 m_rootLayer = adoptPtr(Platform::current()->compositorSupport()->cre
ateContentLayer(this)); | |
| 232 m_rootLayer->layer()->setBounds(m_size); | |
| 233 m_layerTreeView->setRootLayer(*m_rootLayer->layer()); | |
| 234 } else { | |
| 235 m_isAcceleratedCompositingActive = false; | |
| 236 m_client->didDeactivateCompositor(); | |
| 237 } | |
| 238 } | |
| 239 } | |
| 240 | |
| 241 void WebPopupMenuImpl::paintContents(WebCanvas* canvas, const WebRect& rect, boo
l, WebFloatRect&, | 218 void WebPopupMenuImpl::paintContents(WebCanvas* canvas, const WebRect& rect, boo
l, WebFloatRect&, |
| 242 WebContentLayerClient::GraphicsContextStatus contextStatus) | 219 WebContentLayerClient::GraphicsContextStatus contextStatus) |
| 243 { | 220 { |
| 244 if (!m_widget) | 221 if (!m_widget) |
| 245 return; | 222 return; |
| 246 | 223 |
| 247 if (!rect.isEmpty()) { | 224 if (!rect.isEmpty()) { |
| 248 GraphicsContext context(canvas, | 225 GraphicsContext context(canvas, |
| 249 contextStatus == WebContentLayerClient::GraphicsContextEnabled ? Gra
phicsContext::NothingDisabled : GraphicsContext::FullyDisabled); | 226 contextStatus == WebContentLayerClient::GraphicsContextEnabled ? Gra
phicsContext::NothingDisabled : GraphicsContext::FullyDisabled); |
| 250 m_widget->paint(&context, rect); | 227 m_widget->paint(&context, rect); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 ASSERT(widget == m_widget); | 421 ASSERT(widget == m_widget); |
| 445 if (m_widget) { | 422 if (m_widget) { |
| 446 m_widget->setClient(0); | 423 m_widget->setClient(0); |
| 447 m_widget = 0; | 424 m_widget = 0; |
| 448 } | 425 } |
| 449 if (m_client) | 426 if (m_client) |
| 450 m_client->closeWidgetSoon(); | 427 m_client->closeWidgetSoon(); |
| 451 } | 428 } |
| 452 | 429 |
| 453 } // namespace blink | 430 } // namespace blink |
| OLD | NEW |