bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* result) { switch (variable) { case NPNVxDisplay: *reinterpret_cast<void**>(value) = x11Display(); *result = NPERR_NO_ERROR; return true; case NPNVxtAppContext: *result = NPERR_GENERIC_ERROR; return true; case NPNVnetscapeWindow: { QWebPageClient* client = platformPageClient(); QWindow* window = client ? client->ownerWindow() : 0; *reinterpret_cast<XID*>(value) = window ? window->winId() : 0; *result = NPERR_NO_ERROR; return true; } case NPNVToolkit: if (m_plugin->quirks().contains(PluginQuirkRequiresGtkToolKit)) { *((uint32_t *)value) = 2; *result = NPERR_NO_ERROR; return true; } return false; default: return false; } }
int screenDepthPerComponent(Widget* w) { #if HAVE(QT5) int depth = QGuiApplication::primaryScreen()->depth(); // FIXME: Use widget's screen Q_UNUSED(w); #else int depth = QApplication::desktop()->screen(0)->depth(); if (w) { QWebPageClient* client = w->root()->hostWindow()->platformPageClient(); if (client) { QWidget* view = client->ownerWidget(); if (view) depth = view->depth(); } } #endif // An interface to establish the actual number of bits per color // doesn't exist in Qt, or probably at all, so use common-sense // values for each screen depth and assume RGB/RGBA where appropriate. // Per http://www.w3.org/TR/css3-mediaqueries/#color, 'If different color // components are represented by different number of bits, the smallest // number is used.' switch (depth) { case 8: return 2; case 32: return 8; default: return depth / 3; } }
bool PluginView::platformStart() { ASSERT(m_isStarted); ASSERT(m_status == PluginStatusLoadedSuccessfully); show(); if (m_isWindowed) { QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); // FIXME this will not work for QGraphicsView. // But we cannot use winId because it will create a window and on S60, // QWidgets should not create a window. Q_ASSERT(qobject_cast<QWidget*>(client->pluginParent())); setPlatformWidget(new PluginContainerSymbian(this, qobject_cast<QWidget*>(client->pluginParent()))); m_npWindow.type = NPWindowTypeWindow; m_npWindow.window = (void*)platformPluginWidget(); } else { setPlatformWidget(0); m_npWindow.type = NPWindowTypeDrawable; m_npWindow.window = 0; // Not used? } setNPWindowIfNeeded(); return true; }
bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* result) { switch (variable) { case NPNVxDisplay: *(void **)value = QX11Info::display(); *result = NPERR_NO_ERROR; return true; case NPNVxtAppContext: *result = NPERR_GENERIC_ERROR; return true; case NPNVnetscapeWindow: { void* w = reinterpret_cast<void*>(value); QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); *((XID *)w) = client ? client->ownerWidget()->window()->winId() : 0; *result = NPERR_NO_ERROR; return true; } case NPNVToolkit: if (m_plugin->quirks().contains(PluginQuirkRequiresGtkToolKit)) { *((uint32_t *)value) = 2; *result = NPERR_NO_ERROR; return true; } return false; default: return false; } }
bool PluginView::platformStart() { ASSERT(m_isStarted); ASSERT(m_status == PluginStatusLoadedSuccessfully); show(); if (m_isWindowed) { QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); QGraphicsProxyWidget* proxy = 0; if (QGraphicsWebView *webView = qobject_cast<QGraphicsWebView*>(client->pluginParent())) proxy = new QGraphicsProxyWidget(webView); PluginContainerSymbian* container = new PluginContainerSymbian(this, proxy ? 0 : client->ownerWidget(), proxy); setPlatformWidget(container); if (proxy) proxy->setWidget(container); m_npWindow.type = NPWindowTypeWindow; m_npWindow.window = (void*)platformPluginWidget(); } else { setPlatformWidget(0); m_npWindow.type = NPWindowTypeDrawable; m_npWindow.window = 0; // Not used? } updatePluginWidget(); setNPWindowIfNeeded(); if (qtwebkit_page_plugin_created) qtwebkit_page_plugin_created(QWebFramePrivate::kit(m_parentFrame.get()), m_instance, (void*)(m_plugin->pluginFuncs())); return true; }
static int screenNumber(Widget* w) { if (!w) return 0; QWebPageClient* client = w->root()->hostWindow()->platformPageClient(); return client ? client->screenNumber() : 0; }
void PluginView::initXEvent(XEvent* xEvent) { memset(xEvent, 0, sizeof(XEvent)); QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); QWidget* ownerWidget = client ? client->ownerWidget() : 0; setSharedXEventFields(xEvent, ownerWidget); }
void ChromeClientQt::setCursor(const Cursor& cursor) { #ifndef QT_NO_CURSOR QWebPageClient* pageClient = platformPageClient(); if (!pageClient) return; pageClient->setCursor(*cursor.platformCursor()); #else UNUSED_PARAM(cursor); #endif }
QStyle* RenderThemeQStyle::qStyle() const { if (m_page) { QWebPageClient* pageClient = m_page->chrome()->client()->platformPageClient(); if (pageClient) return pageClient->style(); } return QApplication::style(); }
IntPoint ChromeClientQt::screenToRootView(const IntPoint& point) const { QWebPageClient* pageClient = platformPageClient(); if (!pageClient) return point; QWidget* ownerWidget = pageClient->ownerWidget(); if (!ownerWidget) return point; return ownerWidget->mapFromGlobal(point); }
int screenDepthPerComponent(Widget* w) { if (w) { QWebPageClient* client = w->root()->hostWindow()->platformPageClient(); if (client) { QWidget* view = client->ownerWidget(); if (view) return view->depth(); } } return QApplication::desktop()->screen(0)->depth(); }
IntRect ChromeClientQt::rootViewToScreen(const IntRect& rect) const { QWebPageClient* pageClient = platformPageClient(); if (!pageClient) return rect; QWidget* ownerWidget = pageClient->ownerWidget(); if (!ownerWidget) return rect; QRect screenRect(rect); screenRect.translate(ownerWidget->mapToGlobal(QPoint(0, 0))); return screenRect; }
QStyle* RenderThemeQt::qStyle() const { #if USE(QT_MOBILE_THEME) return fallbackStyle(); #endif if (m_page) { QWebPageClient* pageClient = m_page->chrome()->client()->platformPageClient(); if (pageClient) return pageClient->style(); } return QApplication::style(); }
void RenderThemeQt::setPaletteFromPageClientIfExists(QPalette& palette) const { // If the webview has a custom palette, use it if (!m_page) return; Chrome* chrome = m_page->chrome(); if (!chrome) return; ChromeClient* chromeClient = chrome->client(); if (!chromeClient) return; QWebPageClient* pageClient = chromeClient->platformPageClient(); if (!pageClient) return; palette = pageClient->palette(); }
void EditorClientQt::setInputMethodState(bool active) { QWebPageClient* webPageClient = m_page->d->client.get(); if (webPageClient) { Qt::InputMethodHints hints; HTMLInputElement* inputElement = 0; Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame(); if (frame && frame->document() && frame->document()->focusedNode()) if (frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag)) inputElement = static_cast<HTMLInputElement*>(frame->document()->focusedNode()); if (inputElement) { // Set input method hints for "number", "tel", "email", "url" and "password" input elements. if (inputElement->isTelephoneField()) hints |= Qt::ImhDialableCharactersOnly; if (inputElement->isNumberField()) hints |= Qt::ImhDigitsOnly; if (inputElement->isEmailField()) hints |= Qt::ImhEmailCharactersOnly; if (inputElement->isURLField()) hints |= Qt::ImhUrlCharactersOnly; // Setting the Qt::WA_InputMethodEnabled attribute true and Qt::ImhHiddenText flag // for password fields. The Qt platform is responsible for determining which widget // will receive input method events for password fields. if (inputElement->isPasswordField()) { active = true; hints |= Qt::ImhHiddenText; } } #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) // disables auto-uppercase and predictive text for mobile devices hints |= Qt::ImhNoAutoUppercase; hints |= Qt::ImhNoPredictiveText; #endif // Q_WS_MAEMO_5 || Q_WS_MAEMO_6 || Q_OS_SYMBIAN webPageClient->setInputMethodHints(hints); webPageClient->setInputMethodEnabled(active); } emit m_page->microFocusChanged(); }
void RenderThemeQt::setPaletteFromPageClientIfExists(QPalette& palette) const { #if USE(QT_MOBILE_THEME) static QPalette lightGrayPalette(Qt::lightGray); palette = lightGrayPalette; return; #endif // If the webview has a custom palette, use it if (!m_page) return; Chrome* chrome = m_page->chrome(); if (!chrome) return; ChromeClient* chromeClient = chrome->client(); if (!chromeClient) return; QWebPageClient* pageClient = chromeClient->platformPageClient(); if (!pageClient) return; palette = pageClient->palette(); }
void PopupMenu::show(const IntRect& r, FrameView* v, int index) { QWebPageClient* client = v->hostWindow()->platformPageClient(); populate(r); QRect rect = r; rect.moveTopLeft(v->contentsToWindow(r.topLeft())); rect.setHeight(m_popup->sizeHint().height()); if (QGraphicsView* view = qobject_cast<QGraphicsView*>(client->ownerWidget())) { if (!m_proxy) { m_proxy = new QGraphicsProxyWidget(qobject_cast<QGraphicsWebView*>(client->pluginParent())); m_proxy->setWidget(m_popup); } else m_proxy->setVisible(true); m_proxy->setGeometry(rect); } else { m_popup->setParent(client->ownerWidget()); m_popup->setGeometry(rect); } m_popup->setCurrentIndex(index); m_popup->exec(); }
IntRect ChromeClientQt::windowResizerRect() const { #if defined(Q_WS_MAC) if (!m_webPage) return IntRect(); QWebPageClient* pageClient = platformPageClient(); if (!pageClient) return IntRect(); QWidget* ownerWidget = pageClient->ownerWidget(); if (!ownerWidget) return IntRect(); QWidget* topLevelWidget = ownerWidget->window(); QRect topLevelGeometry(topLevelWidget->geometry()); // There's no API in Qt to query for the size of the resizer, so we assume // it has the same width and height as the scrollbar thickness. int scollbarThickness = ScrollbarTheme::theme()->scrollbarThickness(); // There's no API in Qt to query for the position of the resizer. Sometimes // it's drawn by the system, and sometimes it's a QSizeGrip. For RTL locales // it might even be on the lower left side of the window, but in WebKit we // always draw scrollbars on the right hand side, so we assume this to be the // location when computing the resize rect to reserve for WebKit. QPoint resizeCornerTopLeft = ownerWidget->mapFrom(topLevelWidget, QPoint(topLevelGeometry.width(), topLevelGeometry.height()) - QPoint(scollbarThickness, scollbarThickness)); QRect resizeCornerRect = QRect(resizeCornerTopLeft, QSize(scollbarThickness, scollbarThickness)); return resizeCornerRect.intersected(pageClient->geometryRelativeToOwnerWidget()); #else return IntRect(); #endif }
void EditorClientQt::setInputMethodState(bool active) { QWebPageClient* webPageClient = m_page->client.data(); if (webPageClient) { Qt::InputMethodHints hints; HTMLInputElement* inputElement = 0; Frame* frame = m_page->page->focusController()->focusedOrMainFrame(); if (frame && frame->document() && frame->document()->focusedElement()) if (isHTMLInputElement(frame->document()->focusedElement())) inputElement = toHTMLInputElement(frame->document()->focusedElement()); if (inputElement) { // Set input method hints for "number", "tel", "email", "url" and "password" input elements. if (inputElement->isTelephoneField()) hints |= Qt::ImhDialableCharactersOnly; if (inputElement->isNumberField()) hints |= Qt::ImhDigitsOnly; if (inputElement->isEmailField()) hints |= Qt::ImhEmailCharactersOnly; if (inputElement->isURLField()) hints |= Qt::ImhUrlCharactersOnly; // Setting the Qt::WA_InputMethodEnabled attribute true and Qt::ImhHiddenText flag // for password fields. The Qt platform is responsible for determining which widget // will receive input method events for password fields. if (inputElement->isPasswordField()) { active = true; hints |= Qt::ImhHiddenText; } } webPageClient->setInputMethodHints(hints); webPageClient->setInputMethodEnabled(active); } emit m_page->microFocusChanged(); }
bool PluginView::platformStart() { ASSERT(m_isStarted); ASSERT(m_status == PluginStatusLoadedSuccessfully); if (m_plugin->pluginFuncs()->getvalue) { PluginView::setCurrentPluginView(this); #if USE(JSC) JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); #endif setCallingPlugin(true); m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginNeedsXEmbed, &m_needsXEmbed); setCallingPlugin(false); PluginView::setCurrentPluginView(0); } if (m_isWindowed) { QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); if (m_needsXEmbed && client) { setPlatformWidget(new PluginContainerQt(this, client->ownerWidget())); // sync our XEmbed container window creation before sending the xid to plugins. QApplication::syncX(); } else { notImplemented(); m_status = PluginStatusCanNotLoadPlugin; return false; } } else { setPlatformWidget(0); m_pluginDisplay = getPluginDisplay(); #if USE(ACCELERATED_COMPOSITING) && !USE(TEXTURE_MAPPER) if (shouldUseAcceleratedCompositing()) { m_platformLayer = adoptPtr(new PluginGraphicsLayerQt(this)); // Trigger layer computation in RenderLayerCompositor m_element->setNeedsStyleRecalc(SyntheticStyleChange); } #endif } // If the width and the height are not zero we show the PluginView. if (!frameRect().isEmpty()) show(); NPSetWindowCallbackStruct* wsi = new NPSetWindowCallbackStruct(); wsi->type = 0; if (m_isWindowed) { const QX11Info* x11Info = &static_cast<QWidget*>(platformPluginWidget())->x11Info(); wsi->display = x11Info->display(); wsi->visual = (Visual*)x11Info->visual(); wsi->depth = x11Info->depth(); wsi->colormap = x11Info->colormap(); m_npWindow.type = NPWindowTypeWindow; m_npWindow.window = (void*)static_cast<QWidget*>(platformPluginWidget())->winId(); m_npWindow.width = -1; m_npWindow.height = -1; } else { const QX11Info* x11Info = &QApplication::desktop()->x11Info(); if (x11Info->depth() == 32 || !m_plugin->quirks().contains(PluginQuirkRequiresDefaultScreenDepth)) { getVisualAndColormap(32, &m_visual, &m_colormap); wsi->depth = 32; } if (!m_visual) { getVisualAndColormap(x11Info->depth(), &m_visual, &m_colormap); wsi->depth = x11Info->depth(); } wsi->display = x11Info->display(); wsi->visual = m_visual; wsi->colormap = m_colormap; m_npWindow.type = NPWindowTypeDrawable; m_npWindow.window = 0; // Not used? m_npWindow.x = 0; m_npWindow.y = 0; m_npWindow.width = -1; m_npWindow.height = -1; } m_npWindow.ws_info = wsi; if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))) { updatePluginWidget(); setNPWindowIfNeeded(); } return true; }
PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) { // qDebug()<<"------ Creating plugin in FrameLoaderClientQt::createPlugin for "<<url.prettyURL() << mimeType; // qDebug()<<"------\t url = "<<url.prettyURL(); if (!m_webFrame) return 0; QStringList params; QStringList values; QString classid(element->getAttribute("classid")); for (unsigned i = 0; i < paramNames.size(); ++i) { params.append(paramNames[i]); if (paramNames[i] == "classid") classid = paramValues[i]; } for (unsigned i = 0; i < paramValues.size(); ++i) values.append(paramValues[i]); QString urlStr(url.string()); QUrl qurl = urlStr; QObject* object = 0; if (mimeType == "application/x-qt-plugin" || mimeType == "application/x-qt-styled-widget") { object = m_webFrame->page()->createPlugin(classid, qurl, params, values); #ifndef QT_NO_STYLE_STYLESHEET QWidget* widget = qobject_cast<QWidget*>(object); if (widget && mimeType == "application/x-qt-styled-widget") { QString styleSheet = element->getAttribute("style"); if (!styleSheet.isEmpty()) styleSheet += QLatin1Char(';'); for (unsigned i = 0; i < numqStyleSheetProperties; ++i) { CSSPropertyID property = qstyleSheetProperties[i]; styleSheet += QString::fromLatin1(::getPropertyName(property)); styleSheet += QLatin1Char(':'); styleSheet += computedStyle(element)->getPropertyValue(property); styleSheet += QLatin1Char(';'); } widget->setStyleSheet(styleSheet); } #endif // QT_NO_STYLE_STYLESHEET } if (!object) { QWebPluginFactory* factory = m_webFrame->page()->pluginFactory(); if (factory) object = factory->create(mimeType, qurl, params, values); } if (object) { QWidget* widget = qobject_cast<QWidget*>(object); if (widget) { QWidget* parentWidget = 0; if (m_webFrame->page()->d->client) parentWidget = qobject_cast<QWidget*>(m_webFrame->page()->d->client->pluginParent()); if (parentWidget) // don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. widget->setParent(parentWidget); widget->hide(); RefPtr<QtPluginWidget> w = adoptRef(new QtPluginWidget()); w->setPlatformWidget(widget); // Make sure it's invisible until properly placed into the layout w->setFrameRect(IntRect(0, 0, 0, 0)); return w; } #if QT_VERSION >= 0x040600 QGraphicsWidget* graphicsWidget = qobject_cast<QGraphicsWidget*>(object); if (graphicsWidget) { QGraphicsObject* parentWidget = 0; if (m_webFrame->page()->d->client) parentWidget = qobject_cast<QGraphicsObject*>(m_webFrame->page()->d->client->pluginParent()); graphicsWidget->hide(); if (parentWidget) // don't reparent to nothing (i.e. keep whatever parent QWebPage::createPlugin() chose. graphicsWidget->setParentItem(parentWidget); RefPtr<QtPluginGraphicsWidget> w = QtPluginGraphicsWidget::create(graphicsWidget); // Make sure it's invisible until properly placed into the layout w->setFrameRect(IntRect(0, 0, 0, 0)); return w; } #endif // FIXME: make things work for widgetless plugins as well delete object; } else { // NPAPI Plugins Vector<String> params = paramNames; Vector<String> values = paramValues; if (mimeType == "application/x-shockwave-flash") { QWebPageClient* client = m_webFrame->page()->d->client; const bool isQWebView = client && qobject_cast<QWidget*>(client->pluginParent()); #if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5) size_t wmodeIndex = params.find("wmode"); if (wmodeIndex == -1) { // Disable XEmbed mode and force it to opaque mode params.append("wmode"); values.append("opaque"); } else if (!isQWebView) { // Disable transparency if client is not a QWebView values[wmodeIndex] = "opaque"; } #else if (!isQWebView) { // inject wmode=opaque when there is no client or the client is not a QWebView size_t wmodeIndex = params.find("wmode"); if (wmodeIndex == -1) { params.append("wmode"); values.append("opaque"); } else values[wmodeIndex] = "opaque"; } #endif } RefPtr<PluginView> pluginView = PluginView::create(m_frame, pluginSize, element, url, params, values, mimeType, loadManually); return pluginView; } return 0; }
ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const { // Default bits: no focus, no mouse over option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver); if (!isEnabled(o)) option.state &= ~QStyle::State_Enabled; if (isReadOnlyControl(o)) // Readonly is supported on textfields. option.state |= QStyle::State_ReadOnly; if (supportsFocus(o->style()->appearance()) && isFocused(o)) { option.state |= QStyle::State_HasFocus; option.state |= QStyle::State_KeyboardFocusChange; } if (isHovered(o)) option.state |= QStyle::State_MouseOver; option.direction = Qt::LeftToRight; if (o->style() && o->style()->direction() == WebCore::RTL) option.direction = Qt::RightToLeft; ControlPart result = o->style()->appearance(); switch (result) { case PushButtonPart: case SquareButtonPart: case ButtonPart: case ButtonBevelPart: case ListItemPart: case MenulistButtonPart: case SearchFieldResultsButtonPart: case SearchFieldCancelButtonPart: { if (isPressed(o)) option.state |= QStyle::State_Sunken; else if (result == PushButtonPart) option.state |= QStyle::State_Raised; break; } } if (result == RadioPart || result == CheckboxPart) option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off); #ifdef Q_WS_MAEMO_5 static QPalette lightGrayPalette(Qt::lightGray); option.palette = lightGrayPalette; #else // If the owner widget has a custom palette, use it Page* page = o->document()->page(); if (page) { ChromeClient* client = page->chrome()->client(); QWebPageClient* pageClient = client->platformPageClient(); if (pageClient) option.palette = pageClient->palette(); } #endif return result; }
bool PluginView::platformStart() { ASSERT(m_isStarted); ASSERT(m_status == PluginStatusLoadedSuccessfully); if (m_plugin->pluginFuncs()->getvalue) { PluginView::setCurrentPluginView(this); JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); setCallingPlugin(true); m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginNeedsXEmbed, &m_needsXEmbed); setCallingPlugin(false); PluginView::setCurrentPluginView(0); } if (m_isWindowed) { QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); if (m_needsXEmbed && client) { setPlatformWidget(new PluginContainerQt(this, client->ownerWidget())); // sync our XEmbed container window creation before sending the xid to plugins. QApplication::syncX(); } else { notImplemented(); m_status = PluginStatusCanNotLoadPlugin; return false; } } else { setPlatformWidget(0); m_pluginDisplay = getPluginDisplay(); } show(); NPSetWindowCallbackStruct* wsi = new NPSetWindowCallbackStruct(); wsi->type = 0; if (m_isWindowed) { const QX11Info* x11Info = &platformPluginWidget()->x11Info(); wsi->display = x11Info->display(); wsi->visual = (Visual*)x11Info->visual(); wsi->depth = x11Info->depth(); wsi->colormap = x11Info->colormap(); m_npWindow.type = NPWindowTypeWindow; m_npWindow.window = (void*)platformPluginWidget()->winId(); m_npWindow.width = -1; m_npWindow.height = -1; } else { const QX11Info* x11Info = &QApplication::desktop()->x11Info(); if (x11Info->depth() == 32 || !m_plugin->quirks().contains(PluginQuirkRequiresDefaultScreenDepth)) { getVisualAndColormap(32, &m_visual, &m_colormap); wsi->depth = 32; } if (!m_visual) { getVisualAndColormap(x11Info->depth(), &m_visual, &m_colormap); wsi->depth = x11Info->depth(); } wsi->display = x11Info->display(); wsi->visual = m_visual; wsi->colormap = m_colormap; m_npWindow.type = NPWindowTypeDrawable; m_npWindow.window = 0; // Not used? m_npWindow.x = 0; m_npWindow.y = 0; m_npWindow.width = -1; m_npWindow.height = -1; } m_npWindow.ws_info = wsi; if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))) { updatePluginWidget(); setNPWindowIfNeeded(); } return true; }
NPError PluginView::getValue(NPNVariable variable, void* value) { LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data()); switch (variable) { case NPNVxDisplay: *(void **)value = QX11Info::display(); return NPERR_NO_ERROR; case NPNVxtAppContext: return NPERR_GENERIC_ERROR; #if ENABLE(NETSCAPE_PLUGIN_API) case NPNVWindowNPObject: { if (m_isJavaScriptPaused) return NPERR_GENERIC_ERROR; NPObject* windowScriptObject = m_parentFrame->script()->windowScriptNPObject(); // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html> if (windowScriptObject) _NPN_RetainObject(windowScriptObject); void** v = (void**)value; *v = windowScriptObject; return NPERR_NO_ERROR; } case NPNVPluginElementNPObject: { if (m_isJavaScriptPaused) return NPERR_GENERIC_ERROR; NPObject* pluginScriptObject = 0; if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag)) pluginScriptObject = static_cast<HTMLPlugInElement*>(m_element)->getNPObject(); // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html> if (pluginScriptObject) _NPN_RetainObject(pluginScriptObject); void** v = (void**)value; *v = pluginScriptObject; return NPERR_NO_ERROR; } #endif case NPNVnetscapeWindow: { void* w = reinterpret_cast<void*>(value); QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); *((XID *)w) = client ? client->ownerWidget()->window()->winId() : 0; return NPERR_NO_ERROR; } case NPNVToolkit: if (m_plugin->quirks().contains(PluginQuirkRequiresGtkToolKit)) { *((uint32 *)value) = 2; return NPERR_NO_ERROR; } // fall through default: return getValueStatic(variable, value); } }
void PluginView::paint(GraphicsContext* context, const IntRect& rect) { if (!m_isStarted) { paintMissingPluginIcon(context, rect); return; } if (context->paintingDisabled()) return; setNPWindowIfNeeded(); if (m_isWindowed || !m_drawable) return; const bool syncX = m_pluginDisplay && m_pluginDisplay != QX11Info::display(); QPainter* painter = context->platformContext(); IntRect exposedRect(rect); exposedRect.intersect(frameRect()); exposedRect.move(-frameRect().x(), -frameRect().y()); QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared); const int drawableDepth = ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth; ASSERT(drawableDepth == qtDrawable.depth()); // When printing, Qt uses a QPicture to capture the output in preview mode. The // QPicture holds a reference to the X Pixmap. As a result, the print preview would // update itself when the X Pixmap changes. To prevent this, we create a copy. if (m_element->document()->printing()) qtDrawable = qtDrawable.copy(); if (m_isTransparent && drawableDepth != 32) { // Attempt content propagation for drawable with no alpha by copying over from the backing store QPoint offset; QPaintDevice* backingStoreDevice = QPainter::redirected(painter->device(), &offset); offset = -offset; // negating the offset gives us the offset of the view within the backing store pixmap const bool hasValidBackingStore = backingStoreDevice && backingStoreDevice->devType() == QInternal::Pixmap; QPixmap* backingStorePixmap = static_cast<QPixmap*>(backingStoreDevice); // We cannot grab contents from the backing store when painting on QGraphicsView items // (because backing store contents are already transformed). What we really mean to do // here is to check if we are painting on QWebView, but let's be a little permissive :) QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); const bool backingStoreHasUntransformedContents = client && qobject_cast<QWidget*>(client->pluginParent()); if (hasValidBackingStore && backingStorePixmap->depth() == drawableDepth && backingStoreHasUntransformedContents) { GC gc = XDefaultGC(QX11Info::display(), QX11Info::appScreen()); XCopyArea(QX11Info::display(), backingStorePixmap->handle(), m_drawable, gc, offset.x() + m_windowRect.x() + exposedRect.x(), offset.y() + m_windowRect.y() + exposedRect.y(), exposedRect.width(), exposedRect.height(), exposedRect.x(), exposedRect.y()); } else { // no backing store, clean the pixmap because the plugin thinks its transparent QPainter painter(&qtDrawable); painter.fillRect(exposedRect, Qt::white); } if (syncX) QApplication::syncX(); } XEvent xevent; memset(&xevent, 0, sizeof(XEvent)); XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose; exposeEvent.type = GraphicsExpose; exposeEvent.display = QX11Info::display(); exposeEvent.drawable = qtDrawable.handle(); exposeEvent.x = exposedRect.x(); exposeEvent.y = exposedRect.y(); exposeEvent.width = exposedRect.x() + exposedRect.width(); // flash bug? it thinks width is the right in transparent mode exposeEvent.height = exposedRect.y() + exposedRect.height(); // flash bug? it thinks height is the bottom in transparent mode dispatchNPEvent(xevent); if (syncX) XSync(m_pluginDisplay, False); // sync changes by plugin painter->drawPixmap(QPoint(frameRect().x() + exposedRect.x(), frameRect().y() + exposedRect.y()), qtDrawable, exposedRect); }