本文整理汇总了C++中KHTMLPart类的典型用法代码示例。如果您正苦于以下问题:C++ KHTMLPart类的具体用法?C++ KHTMLPart怎么用?C++ KHTMLPart使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KHTMLPart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: aspect_ratioMediaFeatureEval
static bool aspect_ratioMediaFeatureEval(CSSValueImpl *value, RenderStyle *, KHTMLPart *part, MediaFeaturePrefix op)
{
if (value) {
KHTMLPart *rootPart = part;
while (rootPart->parentPart()) {
rootPart = rootPart->parentPart();
}
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
QSize vs;
int h = 0, v = 0;
if (printing) {
vs = QSize(pd->width(), pd->height());
} else {
vs = QSize(part->view()->visibleWidth(), part->view()->visibleHeight());
}
if (parseAspectRatio(value, h, v)) {
return v != 0 && compareValue(vs.width() * v, vs.height() * h, op);
}
return false;
}
// ({,min-,max-}aspect-ratio)
// assume if we have a viewport, its aspect ratio is non-zero
return true;
}
示例2: orientationMediaFeatureEval
static bool orientationMediaFeatureEval(CSSValueImpl *value, RenderStyle *, KHTMLPart *part, MediaFeaturePrefix /*op*/)
{
if (value) {
CSSPrimitiveValueImpl *pv = static_cast<CSSPrimitiveValueImpl *>(value);
if (!value->isPrimitiveValue() || pv->primitiveType() != CSSPrimitiveValue::CSS_IDENT ||
(pv->getIdent() != CSS_VAL_PORTRAIT && pv->getIdent() != CSS_VAL_LANDSCAPE)) {
return false;
}
KHTMLPart *rootPart = part;
while (rootPart->parentPart()) {
rootPart = rootPart->parentPart();
}
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
if (printing) {
if (pd->width() > pd->height()) {
return (pv->getIdent() == CSS_VAL_LANDSCAPE);
}
} else {
if (part->view()->visibleWidth() > part->view()->visibleHeight()) {
return (pv->getIdent() == CSS_VAL_LANDSCAPE);
}
}
return (pv->getIdent() == CSS_VAL_PORTRAIT);
}
return false;
}
示例3: device_aspect_ratioMediaFeatureEval
static bool device_aspect_ratioMediaFeatureEval(CSSValueImpl *value, RenderStyle *, KHTMLPart *part, MediaFeaturePrefix op)
{
if (value) {
KHTMLPart *rootPart = part;
while (rootPart->parentPart()) {
rootPart = rootPart->parentPart();
}
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
QRect sg;
int h = 0, v = 0;
if (printing) {
sg = QRect(0, 0, pd->width(), pd->height());
} else {
sg = QApplication::desktop()->screen(QApplication::desktop()->screenNumber(rootPart->view()))->rect();
}
if (parseAspectRatio(value, h, v)) {
return v != 0 && compareValue(sg.width() * v, sg.height() * h, op);
}
return false;
}
// ({,min-,max-}device-aspect-ratio)
// assume if we have a device, its aspect ratio is non-zero
return true;
}
示例4: colorMediaFeatureEval
static bool colorMediaFeatureEval(CSSValueImpl *value, RenderStyle *, KHTMLPart *part, MediaFeaturePrefix op)
{
KHTMLPart *rootPart = part;
while (rootPart->parentPart()) {
rootPart = rootPart->parentPart();
}
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
int bitsPerComponent = 0;
if (printing) {
if (pd->colorCount() > 2) {
bitsPerComponent = pd->depth() / 3;
}
// assume printer is either b&w or color.
} else {
int sn = QApplication::desktop()->screenNumber(rootPart->view());
if (QColormap::instance(sn).mode() != QColormap::Gray) {
bitsPerComponent = QApplication::desktop()->screen(sn)->depth() / 3;
}
}
if (value && bitsPerComponent) {
float number = 0;
return numberValue(value, number) && compareValue(bitsPerComponent, static_cast<int>(number), op);
}
return bitsPerComponent;
}
示例5: color_indexMediaFeatureEval
static bool color_indexMediaFeatureEval(CSSValueImpl *value, RenderStyle *, KHTMLPart *part, MediaFeaturePrefix op)
{
KHTMLPart *rootPart = part;
while (rootPart->parentPart()) {
rootPart = rootPart->parentPart();
}
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
unsigned int numColors = 0;
if (printing) {
numColors = pd->colorCount();
} else {
int sn = QApplication::desktop()->screenNumber(rootPart->view());
numColors = QApplication::desktop()->screen(sn)->colorCount();
}
if (numColors == INT_MAX) {
numColors = UINT_MAX;
}
if (value) {
float number = 0;
return numberValue(value, number) && compareValue(numColors, static_cast<unsigned int>(number), op);
}
return numColors;
}
示例6: detach
void HTMLFrameElementImpl::setLocation(const DOMString &str)
{
url = str;
if(!attached())
return;
if(!m_render)
{
detach();
attach();
return;
}
if(!getDocument()->isURLAllowed(url.string()))
return;
// load the frame contents
KHTMLView *w = getDocument()->view();
if(w)
{
KHTMLPart *part = w->part()->findFrame(name.string());
if(part)
{
part->openURL(KURL(getDocument()->completeURL(url.string())));
}
else
{
w->part()->requestFrame(static_cast< RenderFrame * >(m_render), url.string(), name.string());
}
}
}
示例7: getDocument
bool HTMLElementImpl::isURLAllowed(const QString& url) const
{
KHTMLView *w = getDocument()->view();
KURL newURL(getDocument()->completeURL(url));
newURL.setRef(QString::null);
// Prohibit non-file URLs if we are asked to.
if (!w || w->part()->onlyLocalReferences() && newURL.protocol() != "file")
return false;
// do we allow this suburl ?
if ( !kapp || !kapp->kapp->authorizeURLAction("redirect", w->part()->url(), newURL) )
return false;
// We allow one level of self-reference because some sites depend on that.
// But we don't allow more than one.
bool foundSelfReference = false;
for (KHTMLPart *part = w->part(); part; part = part->parentPart()) {
KURL partURL = part->url();
partURL.setRef(QString::null);
if (partURL == newURL) {
if (foundSelfReference)
return false;
foundSelfReference = true;
}
}
return true;
}
示例8: handleEvent
void JSEventListener::handleEvent(DOM::Event &evt)
{
KHTMLPart *part = qobject_cast<KHTMLPart*>(static_cast<Window*>(win.get())->part());
KJSProxy *proxy = 0L;
if (part)
proxy = part->jScript();
if (proxy && listener && listener->implementsCall()) {
#ifdef KJS_DEBUGGER
//### This is the wrong place to do this --- we need
// a more global/general stategy to prevent unwanted event loop recursion issues.
if (proxy->debugEnabled() && DebugWindow::window()->inSession())
return;
#endif
ref();
KJS::ScriptInterpreter *interpreter = static_cast<KJS::ScriptInterpreter *>(proxy->interpreter());
ExecState *exec = interpreter->globalExec();
List args;
args.append(getDOMEvent(exec,evt.handle()));
JSObject *thisObj = 0;
// Check whether handler is a function or an object with handleEvent method
if (listener == compareListenerImp) {
// Set "this" to the event's current target
thisObj = getEventTarget(exec,evt.handle()->currentTarget())->getObject();
} else {
thisObj = compareListenerImp;
}
if ( !thisObj ) {
// ### can this still happen? eventTarget should be window on Window events now.
thisObj = win;
}
Window *window = static_cast<Window*>(win.get());
// Set the event we're handling in the Window object
window->setCurrentEvent( evt.handle() );
// ... and in the interpreter
interpreter->setCurrentEvent( &evt );
interpreter->startCPUGuard();
JSValue *retval = listener->call(exec, thisObj, args);
interpreter->stopCPUGuard();
window->setCurrentEvent( 0 );
interpreter->setCurrentEvent( 0 );
if ( exec->hadException() )
exec->clearException();
else if (html)
{
QVariant ret = ValueToVariant(exec, retval);
if (ret.type() == QVariant::Bool && ret.toBool() == false)
evt.preventDefault();
}
window->afterScriptExecution();
deref();
}
}
示例9: KJS_CHECK_THIS
Value MozillaSidebarExtensionFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
KJS_CHECK_THIS(KJS::MozillaSidebarExtension, thisObj);
MozillaSidebarExtension *mse = static_cast< MozillaSidebarExtension * >(thisObj.imp());
KHTMLPart *part = mse->part();
if(!part)
return Undefined();
// addPanel() id == 0
KParts::BrowserExtension *ext = part->browserExtension();
if(ext)
{
QString url, name;
if(args.size() == 1)
{ // I've seen this, don't know if it's legal.
name = QString::null;
url = args[0].toString(exec).qstring();
}
else if(args.size() == 2 || args.size() == 3)
{
name = args[0].toString(exec).qstring();
url = args[1].toString(exec).qstring();
// 2 is the "CURL" which I don't understand and don't think we need.
}
else
{
return Boolean(false);
}
emit ext->addWebSideBar(KURL(url), name);
return Boolean(true);
}
return Undefined();
}
示例10: SetViewColor
void RootView::AttachedToWindow()
{
SetViewColor( 216,216,216 );
mURLView->SetDivider( 40 );
mTopView->show();
AddChild( mURLView );
AddChild( mTopView );
AddChild( mStatusBar );
KHTMLPart *htmlPart = new KHTMLPart( mTopView, "khtmlpart" );
KHTMLView* pcView = htmlPart->view();
BRect rect = mTopView->Bounds();
pcView->SetResizingMode( B_FOLLOW_ALL );
pcView->MoveTo( rect.LeftTop() );
pcView->ResizeTo( rect.Width(), rect.Height() );
// pcView->MakeFocus( true );
pcView->SetTarget( BMessenger( Window() ) );
pcView->show();
BrowserWindow *bw = (BrowserWindow *)Window();
bw->SetPart( htmlPart );
bw->SetStatusBar( mStatusBar );
bw->SetURLView( mURLView );
}
示例11: monochromeMediaFeatureEval
static bool monochromeMediaFeatureEval(CSSValueImpl* value, RenderStyle*, KHTMLPart* part, MediaFeaturePrefix op)
{
KHTMLPart* rootPart = part;
while (rootPart->parentPart()) rootPart = rootPart->parentPart();
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl*>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
int depth = 0;
if (printing) {
if (pd->numColors() < 2)
depth = 1;
// assume printer is either b&w or color.
} else {
int sn = QApplication::desktop()->screenNumber( rootPart->view() );
if (QApplication::desktop()->screen(sn)->depth() == 1)
depth = 1;
else if (QColormap::instance(sn).mode() == QColormap::Gray)
depth = QApplication::desktop()->screen(sn)->depth();
}
if (value)
{
float number = 0;
return numberValue(value, number) && compareValue(depth, static_cast<int>(number), op);
}
return depth;
}
示例12: getDocument
bool HTMLEmbedElementImpl::rendererIsNeeded(RenderStyle *style)
{
KHTMLPart *part = getDocument()->part();
if (!part)
return false;
return part->pluginsEnabled() && parentNode()->id() != ID_OBJECT;
}
示例13: m_image
KHTMLImage::KHTMLImage(QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name, KHTMLPart::GUIProfile prof)
: KParts::ReadOnlyPart(parent, name), m_image(0)
{
KHTMLPart *parentPart = ::qt_cast< KHTMLPart * >(parent);
setInstance(KHTMLImageFactory::instance(), prof == KHTMLPart::BrowserViewGUI && !parentPart);
QVBox *box = new QVBox(parentWidget, widgetName);
m_khtml = new KHTMLPart(box, widgetName, this, "htmlimagepart", prof);
m_khtml->setAutoloadImages(true);
m_khtml->widget()->installEventFilter(this);
connect(m_khtml->view(), SIGNAL(finishedLayout()), this, SLOT(restoreScrollPosition()));
setWidget(box);
// VBox can't take focus, so pass it on to sub-widget
box->setFocusProxy(m_khtml->widget());
m_ext = new KHTMLImageBrowserExtension(this, "be");
// Remove unnecessary actions.
KAction *encodingAction = actionCollection()->action("setEncoding");
if(encodingAction)
{
encodingAction->unplugAll();
delete encodingAction;
}
KAction *viewSourceAction = actionCollection()->action("viewDocumentSource");
if(viewSourceAction)
{
viewSourceAction->unplugAll();
delete viewSourceAction;
}
KAction *selectAllAction = actionCollection()->action("selectAll");
if(selectAllAction)
{
selectAllAction->unplugAll();
delete selectAllAction;
}
// forward important signals from the khtml part
// forward opening requests to parent frame (if existing)
KHTMLPart *p = ::qt_cast< KHTMLPart * >(parent);
KParts::BrowserExtension *be = p ? p->browserExtension() : m_ext;
connect(m_khtml->browserExtension(), SIGNAL(openURLRequestDelayed(const KURL &, const KParts::URLArgs &)), be,
SIGNAL(openURLRequestDelayed(const KURL &, const KParts::URLArgs &)));
connect(m_khtml->browserExtension(),
SIGNAL(popupMenu(KXMLGUIClient *, const QPoint &, const KURL &, const KParts::URLArgs &, KParts::BrowserExtension::PopupFlags, mode_t)),
m_ext,
SIGNAL(popupMenu(KXMLGUIClient *, const QPoint &, const KURL &, const KParts::URLArgs &, KParts::BrowserExtension::PopupFlags, mode_t)));
connect(m_khtml->browserExtension(), SIGNAL(enableAction(const char *, bool)), m_ext, SIGNAL(enableAction(const char *, bool)));
m_ext->setURLDropHandlingEnabled(true);
}
示例14: getAttribute
void HTMLLinkElementImpl::process()
{
if(!inDocument())
return;
QString type = getAttribute(ATTR_TYPE).string().lower();
QString rel = getAttribute(ATTR_REL).string().lower();
KHTMLPart *part = getDocument()->view() ? getDocument()->view()->part() : 0;
// IE extension: location of small icon for locationbar / bookmarks
// Uses both "shortcut icon" and "icon"
if(part && rel.contains("icon") && !m_url.isEmpty() && !part->parentPart())
part->browserExtension()->setIconURL(KURL(m_url.string()));
// Stylesheet
else if(!m_isDisabled && (type.contains("text/css") || rel.contains("stylesheet")))
{
// no need to load style sheets which aren't for the screen output
// ### there may be in some situations e.g. for an editor or script to manipulate
if(m_media.isNull() || m_media.contains("screen") || m_media.contains("all") || m_media.contains("print"))
{
m_loading = true;
// Add ourselves as a pending sheet, but only if we aren't an alternate
// stylesheet. Alternate stylesheets don't hold up render tree construction.
m_alternate = rel.contains("alternate");
if(!isAlternate())
getDocument()->addPendingSheet();
QString chset = getAttribute(ATTR_CHARSET).string();
// set chset to charset of referring document when attribute CHARSET is absent.
// http://www.w3.org/TR/CSS21/syndata.html(4.4)
if(chset.isEmpty() && part)
chset = part->encoding();
if(m_cachedSheet)
m_cachedSheet->deref(this);
m_cachedSheet = getDocument()->docLoader()->requestStyleSheet(m_url, chset);
if(m_cachedSheet)
{
m_isCSSSheet = true;
m_cachedSheet->ref(this);
}
else if(!isAlternate())
{
// Error requesting sheet; decrement pending sheet count
getDocument()->styleSheetLoaded();
}
}
}
else if(m_sheet)
{
// we no longer contain a stylesheet, e.g. perhaps rel or type was changed
m_sheet->deref();
m_sheet = 0;
m_isCSSSheet = false;
getDocument()->updateStyleSelector();
}
}
示例15: parent
void KGet_plug_in::slotShowLinks()
{
if ( !parent() || !parent()->inherits( "KHTMLPart" ) )
return;
KHTMLPart *htmlPart = static_cast<KHTMLPart*>( parent() );
KParts::Part *activePart = 0L;
if ( htmlPart->partManager() )
{
activePart = htmlPart->partManager()->activePart();
if ( activePart && activePart->inherits( "KHTMLPart" ) )
htmlPart = static_cast<KHTMLPart*>( activePart );
}
DOM::HTMLDocument doc = htmlPart->htmlDocument();
if ( doc.isNull() )
return;
DOM::HTMLCollection links = doc.links();
QPtrList<LinkItem> linkList;
std::set<QString> dupeCheck;
for ( uint i = 0; i < links.length(); i++ )
{
DOM::Node link = links.item( i );
if ( link.isNull() || link.nodeType() != DOM::Node::ELEMENT_NODE )
continue;
LinkItem *item = new LinkItem( (DOM::Element) link );
if ( item->isValid() &&
dupeCheck.find( item->url.url() ) == dupeCheck.end() )
{
linkList.append( item );
dupeCheck.insert( item->url.url() );
}
else
delete item;
}
if ( linkList.isEmpty() )
{
KMessageBox::sorry( htmlPart->widget(),
i18n("There are no links in the active frame of the current HTML page."),
i18n("No Links") );
return;
}
KGetLinkView *view = new KGetLinkView();
QString url = doc.URL().string();
view->setPageURL( url );
view->setLinks( linkList );
view->show();
}