本文整理汇总了C++中KHTMLPart::parentPart方法的典型用法代码示例。如果您正苦于以下问题:C++ KHTMLPart::parentPart方法的具体用法?C++ KHTMLPart::parentPart怎么用?C++ KHTMLPart::parentPart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KHTMLPart
的用法示例。
在下文中一共展示了KHTMLPart::parentPart方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: process
void HTMLLinkElementImpl::process()
{
if (!inDocument())
return;
QString type = m_type.string().lower();
QString rel = m_rel.string().lower();
KHTMLPart* part = getDocument()->part();
// IE extension: location of small icon for locationbar / bookmarks
#if APPLE_CHANGES
if ( part && rel == "shortcut icon" && !m_url.isEmpty() && !part->parentPart())
part->browserExtension()->setIconURL( KURL(m_url.string()) );
// Mozilla extension to IE extension: icon specified with type
if ( part && rel == "icon" && !m_url.isEmpty() && !part->parentPart())
part->browserExtension()->setTypedIconURL( KURL(m_url.string()), type );
#else
// Uses both "shortcut icon" and "icon"
if ( part && rel.contains("icon") && !m_url.isEmpty() && !part->parentPart())
part->browserExtension()->setIconURL( KURL(m_url.string()) );
#endif
// Stylesheet
// This was buggy and would incorrectly match <link rel="alternate">, which has a different specified meaning. -dwh
if(m_disabledState != 2 && (type.contains("text/css") || rel == "stylesheet" || (rel.contains("alternate") && rel.contains("stylesheet"))) && getDocument()->part()) {
// 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
// also, don't load style sheets for standalone documents
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();
if (m_cachedSheet)
m_cachedSheet->deref(this);
m_cachedSheet = getDocument()->docLoader()->requestStyleSheet(m_url, chset);
if (m_cachedSheet)
m_cachedSheet->ref(this);
}
}
else if (m_sheet) {
// we no longer contain a stylesheet, e.g. perhaps rel or type was changed
m_sheet->deref();
m_sheet = 0;
getDocument()->updateStyleSelector();
}
}
示例8: isURLAllowed
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;
}
示例9: process
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();
}
}
示例10: heightMediaFeatureEval
static bool heightMediaFeatureEval(CSSValueImpl* value, RenderStyle* style, 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 height;
if (printing)
height = pd->height();
else {
height = part->view()->visibleHeight();
doc = static_cast<DOM::DocumentImpl*>(part->document().handle());
}
int logicalDpiY = doc->logicalDpiY();
if (value)
return value->isPrimitiveValue() && compareValue(height, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style, logicalDpiY), op);
return height > 0;
}
示例11: device_widthMediaFeatureEval
static bool device_widthMediaFeatureEval(CSSValueImpl* value, RenderStyle* style, 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;
int width;
if (printing)
width = pd->width();
else {
width = QApplication::desktop()->screen(QApplication::desktop()->screenNumber( rootPart->view() ))->rect().width();
doc = static_cast<DOM::DocumentImpl*>(part->document().handle());
}
int logicalDpiY = doc->logicalDpiY();
return value->isPrimitiveValue() && compareValue(width, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style,logicalDpiY), op);
}
// ({,min-,max-}device-width)
// assume if we have a device, assume non-zero
return true;
}
示例12: widthMediaFeatureEval
static bool widthMediaFeatureEval(CSSValueImpl *value, RenderStyle *style, 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 width;
if (printing) {
width = pd->width();
} else {
width = part->view()->visibleWidth();
doc = static_cast<DOM::DocumentImpl *>(part->document().handle());
}
int logicalDpiY = doc->logicalDpiY();
if (value) {
return value->isPrimitiveValue() && compareValue(width, static_cast<CSSPrimitiveValueImpl *>(value)->computeLength(style, style, logicalDpiY), op);
}
return width > 0;
}