wxWindow* nativeWindowForRenderObject(RenderObject* o) { FrameView* frameView = o->view()->frameView(); ASSERT(frameView); ASSERT(frameView->hostWindow()); return frameView->hostWindow()->platformPageClient(); }
void PluginView::setBackgroundPlay(bool value) { if (!m_private || m_private->m_isBackgroundPlaying == value) return; FrameView* frameView = toFrameView(m_private->m_view->parent()); m_private->m_isBackgroundPlaying = value; if (m_private->m_isBackgroundPlaying) frameView->hostWindow()->platformPageClient()->onPluginStartBackgroundPlay(this, m_private->m_pluginUniquePrefix.c_str()); else frameView->hostWindow()->platformPageClient()->onPluginStopBackgroundPlay(this, m_private->m_pluginUniquePrefix.c_str()); }
void MediaPlayerPrivateMediaFoundation::createVideoWindow() { HWND hWndParent = nullptr; FrameView* view = nullptr; if (!m_player || !m_player->cachedResourceLoader() || !m_player->cachedResourceLoader()->document()) return; view = m_player->cachedResourceLoader()->document()->view(); if (!view || !view->hostWindow()) return; hWndParent = view->hostWindow()->platformPageClient(); m_hwndVideo = CreateWindowEx(WS_EX_NOACTIVATE | WS_EX_TRANSPARENT, registerVideoWindowClass(), 0, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 0, 0, hWndParent, 0, 0, 0); }
void Widget::setCursor(const Cursor& cursor) { FrameView* view = root(); if (!view) return; view->hostWindow()->setCursor(cursor); }
void PluginView::setParent(ScrollView* parentWidget) { // If parentWidget is 0, lets unregister the plugin with the current parent. if (m_private && (!parentWidget || parentWidget != parent())) { if (FrameView* frameView = toFrameView(parent())) { if (m_private->m_isBackgroundPlaying) frameView->hostWindow()->platformPageClient()->onPluginStopBackgroundPlay(this, m_private->m_pluginUniquePrefix.c_str()); if (m_private->m_isFullScreen) handleFullScreenExitEvent(); // This will unlock the idle (if we have locked it). m_private->preventIdle(false); // This will release any keepVisibleRects if they were set. m_private->clearVisibleRects(); #if USE(ACCELERATED_COMPOSITING) // If we had a hole punch rect set, clear it. if (m_private->m_platformLayer && !m_private->m_holePunchRect.isEmpty()) m_private->m_platformLayer->setHolePunchRect(IntRect()); #endif frameView->hostWindow()->platformPageClient()->registerPlugin(this, false /*shouldRegister*/); } } Widget::setParent(parentWidget); if (parentWidget) { init(); FrameView* frameView = toFrameView(parentWidget); if (frameView && m_private) { frameView->hostWindow()->platformPageClient()->registerPlugin(this, true /*shouldRegister*/); if (frameView->frame() && frameView->frame()->loader() && frameView->frame()->loader()->frameHasLoaded()) handleOnLoadEvent(); if (m_private->m_isBackgroundPlaying) frameView->hostWindow()->platformPageClient()->onPluginStartBackgroundPlay(this, m_private->m_pluginUniquePrefix.c_str()); } } }
bool ScrollingCoordinatorCoordinatedGraphics::requestScrollPositionUpdate(FrameView& frameView, const IntPoint& scrollPosition) { if (!frameView.delegatesScrolling()) return false; frameView.setFixedVisibleContentRect(IntRect(scrollPosition, frameView.visibleContentRect().size())); frameView.hostWindow()->delegatedScrollRequested(scrollPosition); return true; }
void PluginViewPrivate::requestCenterFitZoom() { FrameView* frameView = static_cast<FrameView*>(m_view->parent()); if (!frameView) return; frameView->hostWindow()->platformPageClient()->zoomToContentRect(m_view->m_windowRect); }
void PluginViewPrivate::lockOrientation(bool landscape) { FrameView* frameView = static_cast<FrameView*>(m_view->parent()); if (!frameView) return; frameView->hostWindow()->platformPageClient()->lockOrientation(landscape); m_orientationLocked = true; }
QWebPageClient* PluginView::platformPageClient() const { FrameView* view = m_parentFrame->view(); if (!view) return 0; HostWindow* hostWindow = view->hostWindow(); if (!hostWindow) return 0; return hostWindow->platformPageClient(); }
void PluginViewPrivate::preventIdle(bool preventIdle) { if (preventIdle == m_idlePrevented) return; FrameView* frameView = static_cast<FrameView*>(m_view->parent()); if (!frameView) return; frameView->hostWindow()->platformPageClient()->setPreventsScreenDimming(preventIdle); m_idlePrevented = preventIdle; }
IntRect PluginView::calculateClipRect() const { FrameView* frameView = toFrameView(parent()); bool visible = frameView && isVisible(); RenderObject* renderer = m_element->renderer(); if (visible && frameView->width() && frameView->height() && renderer) { IntSize windowSize = frameView->hostWindow()->platformPageClient()->viewportSize(); // Get the clipped rectangle for this player within the current frame. IntRect visibleContentRect; IntRect contentRect = renderer->absoluteClippedOverflowRect(); FloatPoint contentLocal = renderer->absoluteToLocal(FloatPoint(contentRect.location())); contentRect.setLocation(roundedIntPoint(contentLocal)); contentRect.move(frameRect().x(), frameRect().y()); // Clip against any frames that the widget is inside. Note that if the frames are also clipped // by a div, that will not be included in this calculation. That is an improvement that still // needs to be made. const Widget* current = this; while (current->parent() && visible) { // Determine if it is visible in this scrollview. visibleContentRect = current->parent()->visibleContentRect(); // Special case for the root ScrollView. Its size does not match the actual window size. if (current->parent() == root()) visibleContentRect.setSize(windowSize); contentRect.intersect(visibleContentRect); visible = !contentRect.isEmpty(); // Offset to visible coordinates in scrollview widget's coordinate system (except in the case of // the top scroll view). if (current->parent()->parent()) contentRect.move(-visibleContentRect.x(), -visibleContentRect.y()); current = current->parent(); // Don't include the offset for the root window or we get the wrong coordinates. if (current->parent()) { // Move content rect into the parent scrollview's coordinates. IntRect curFrameRect = current->frameRect(); contentRect.move(curFrameRect.x(), curFrameRect.y()); } } return contentRect; } return IntRect(); }
void PluginViewPrivate::unlockOrientation() { if (!m_orientationLocked) return; FrameView* frameView = static_cast<FrameView*>(m_view->parent()); if (!frameView) return; frameView->hostWindow()->platformPageClient()->unlockOrientation(); m_orientationLocked = false; }
void PluginView::updatePluginWidget() { if (!parent() || !m_private) return; ASSERT(parent()->isFrameView()); FrameView* frameView = toFrameView(parent()); IntRect oldWindowRect = m_windowRect; IntRect oldClipRect = m_clipRect; m_windowRect = IntRect(frameView->contentsToWindow(frameRect().location()), frameRect().size()); ScrollView* theRoot = root(); if (!theRoot) return; // ASSERT(parent()->isFrameView()) should prevent this but check just in case // Map rect to content coordinate space of main frame. m_windowRect.move(theRoot->scrollOffset()); m_clipRect = calculateClipRect(); // Notify the plugin if it may or may not be on/offscreen. handleScrollEvent(); bool zoomFactorChanged = ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->zoomFactor != frameView->hostWindow()->platformPageClient()->currentZoomFactor(); if (!zoomFactorChanged && m_windowRect == oldWindowRect && m_clipRect == oldClipRect) return; // Do not call setNPWindowIfNeeded immediately, will be called on paint(). m_private->m_hasPendingGeometryChange = true; // (i) In order to move/resize the plugin window at the same time as the // rest of frame during e.g. scrolling, we set the window geometry // in the paint() function, but as paint() isn't called when the // plugin window is outside the frame which can be caused by a // scroll, we need to move/resize immediately. // (ii) If we are running layout tests from DRT, paint() won't ever get called // so we need to call setNPWindowIfNeeded() if window geometry has changed. if (m_clipRect.isEmpty() || (platformPluginWidget() && (m_windowRect != oldWindowRect || m_clipRect != oldClipRect || zoomFactorChanged))) setNPWindowIfNeeded(); // Make sure we get repainted afterwards. This is necessary for downward // scrolling to move the plugin widget properly. invalidate(); }
void PluginViewPrivate::setVisibleRects(const NPRect rects[], int32_t count) { m_keepVisibleRect = IntRect(); if (!m_view->parent() || !count) return; for (int i = 0; i < count; i++) { IntRect addRect = IntRect(rects[i].left, rects[i].top, rects[i].right - rects[i].left, rects[i].bottom - rects[i].top); m_keepVisibleRect.unite(addRect); } // Don't cause a possible scroll if the result is an empty rectangle. if (m_keepVisibleRect.isEmpty()) return; // Adjust the rect to the parent window and then adjust for scrolling. m_keepVisibleRect = m_view->convertToContainingWindow(m_keepVisibleRect); FrameView* frameView = static_cast<FrameView*>(m_view->parent()); m_keepVisibleRect.move(frameView->scrollPosition().x(), frameView->scrollPosition().y()); frameView->hostWindow()->platformPageClient()->ensureContentVisible(); }
void PluginViewPrivate::showKeyboard(bool value) { FrameView* frameView = static_cast<FrameView*>(m_view->parent()); frameView->hostWindow()->platformPageClient()->showVirtualKeyboard(value); }
bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* result) { switch (variable) { case NPNVZoomFactor: *(static_cast<void**>(value)) = static_cast<void*>(&((static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info)))->zoomFactor); *result = NPERR_NO_ERROR; return true; case NPNVRootWindowGroup: { FrameView* frameView = toFrameView(parent()); if (frameView) { BlackBerry::Platform::Graphics::Window *window = frameView->hostWindow()->platformPageClient()->platformWindow(); if (window) { void** tempValue = static_cast<void**>(value); *tempValue = (void*)window->rootGroup(); if (*tempValue) { *result = NPERR_NO_ERROR; return true; } } } *result = NPERR_GENERIC_ERROR; return false; } case NPNVBrowserWindowGroup: { FrameView* frameView = toFrameView(parent()); if (frameView) { BlackBerry::Platform::Graphics::Window* window = frameView->hostWindow()->platformPageClient()->platformWindow(); if (window) { void** tempValue = static_cast<void**>(value); *tempValue = reinterpret_cast<void*>(const_cast<char*>(window->windowGroup())); if (*tempValue) { *result = NPERR_NO_ERROR; return true; } } } *result = NPERR_GENERIC_ERROR; return false; } case NPNVBrowserDisplayContext: { FrameView* frameView = toFrameView(parent()); if (frameView) { BlackBerry::Platform::Graphics::PlatformDisplayContextHandle context = BlackBerry::Platform::Graphics::platformDisplayContext(); if (context) { void** tempValue = static_cast<void**>(value); *tempValue = static_cast<void*>(context); if (*tempValue) { *result = NPERR_NO_ERROR; return true; } } } *result = NPERR_GENERIC_ERROR; return false; } case NPNVPluginWindowPrefix: { void** tempValue = static_cast<void**>(value); *tempValue = static_cast<void*>(const_cast<char*>(m_private->m_pluginUniquePrefix.c_str())); if (*tempValue) { *result = NPERR_NO_ERROR; return true; } *result = NPERR_GENERIC_ERROR; return false; } case NPNVxDisplay: case NPNVxtAppContext: case NPNVnetscapeWindow: case NPNVjavascriptEnabledBool: case NPNVasdEnabledBool: case NPNVisOfflineBool: case NPNVserviceManager: case NPNVDOMElement: case NPNVDOMWindow: case NPNVToolkit: case NPNVSupportsXEmbedBool: case NPNVWindowNPObject: case NPNVPluginElementNPObject: case NPNVSupportsWindowless: case NPNVprivateModeBool: case NPNVNPCallbacksPtr: return platformGetValueStatic(variable, value, result); default: ASSERT_NOT_REACHED(); return false; } }
void PluginView::setNPWindowIfNeeded() { if (!m_private || !m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow) return; FrameView* frameView = toFrameView(parent()); if (!frameView->hostWindow()->platformPageClient()->isActive()) return; // If the plugin didn't load sucessfully, no point in calling setwindow if (m_status != PluginStatusLoadedSuccessfully) return; if (m_private->m_isFullScreen) return; if (!m_private->m_hasPendingGeometryChange) return; m_private->m_hasPendingGeometryChange = false; m_npWindow.x = m_windowRect.x(); m_npWindow.y = m_windowRect.y(); m_npWindow.clipRect.left = max(0, m_clipRect.x()); m_npWindow.clipRect.top = max(0, m_clipRect.y()); m_npWindow.clipRect.right = max(0, m_clipRect.maxX()); m_npWindow.clipRect.bottom = max(0, m_clipRect.maxY()); if (m_plugin->quirks().contains(PluginQuirkDontCallSetWindowMoreThanOnce)) { // Only set the width and height of the plugin content the first time setNPWindow() is called // so as to workaround an issue in Flash where multiple calls to setNPWindow() cause the plugin // to crash in windowed mode. if (!m_isWindowed || m_npWindow.width == UninitializedCoordinate || m_npWindow.height == UninitializedCoordinate) { m_npWindow.width = m_windowRect.width(); m_npWindow.height = m_windowRect.height(); } } else { m_npWindow.width = m_windowRect.width(); m_npWindow.height = m_windowRect.height(); } m_npWindow.type = NPWindowTypeDrawable; BlackBerry::Platform::Graphics::Window* window = frameView->hostWindow()->platformPageClient()->platformWindow(); if (window) ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->windowGroup = window->windowGroup(); PluginView::setCurrentPluginView(this); JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM()); setCallingPlugin(true); // FIXME: Passing zoomFactor to setwindow make windowed plugin scale incorrectly. // Handling the zoom factor properly in the plugin side may be a better solution. double oldZoomFactor = ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->zoomFactor; ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->zoomFactor = 1.; m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow); ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->zoomFactor = oldZoomFactor; setCallingPlugin(false); PluginView::setCurrentPluginView(0); }