📄 qwebframe.cpp
字号:
}#ifndef QT_NO_PRINTER/*! Prints the frame to the given \a printer. \sa render()*/void QWebFrame::print(QPrinter *printer) const{ QPainter painter; if (!painter.begin(printer)) return; const qreal zoomFactorX = printer->logicalDpiX() / qt_defaultDpi(); const qreal zoomFactorY = printer->logicalDpiY() / qt_defaultDpi(); PrintContext printContext(d->frame); float pageHeight = 0; QRect qprinterRect = printer->pageRect(); IntRect pageRect(0, 0, int(qprinterRect.width() / zoomFactorX), int(qprinterRect.height() / zoomFactorY)); printContext.begin(pageRect.width()); printContext.computePageRects(pageRect, /*headerHeight*/0, /*footerHeight*/0, /*userScaleFactor*/1.0, pageHeight); int docCopies; int pageCopies; if (printer->collateCopies() == true){ docCopies = 1; pageCopies = printer->numCopies(); } else { docCopies = printer->numCopies(); pageCopies = 1; } int fromPage = printer->fromPage(); int toPage = printer->toPage(); bool ascending = true; if (fromPage == 0 && toPage == 0) { fromPage = 1; toPage = printContext.pageCount(); } // paranoia check fromPage = qMax(1, fromPage); toPage = qMin(printContext.pageCount(), toPage); if (printer->pageOrder() == QPrinter::LastPageFirst) { int tmp = fromPage; fromPage = toPage; toPage = tmp; ascending = false; } painter.scale(zoomFactorX, zoomFactorY); GraphicsContext ctx(&painter); for (int i = 0; i < docCopies; ++i) { int page = fromPage; while (true) { for (int j = 0; j < pageCopies; ++j) { if (printer->printerState() == QPrinter::Aborted || printer->printerState() == QPrinter::Error) { printContext.end(); return; } printContext.spoolPage(ctx, page - 1, pageRect.width()); if (j < pageCopies - 1) printer->newPage(); } if (page == toPage) break; if (ascending) ++page; else --page; printer->newPage(); } if ( i < docCopies - 1) printer->newPage(); } printContext.end();}#endif // QT_NO_PRINTER/*! Evaluates the JavaScript defined by \a scriptSource using this frame as context and returns the result of the last executed statement. \sa addToJavaScriptWindowObject(), javaScriptWindowObjectCleared()*/QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource){ ScriptController *proxy = d->frame->script(); QVariant rc; if (proxy) { JSC::JSValuePtr v = proxy->evaluate(ScriptSourceCode(scriptSource)).jsValue(); if (v) { int distance = 0; rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject()->globalExec(), v, QMetaType::Void, &distance); } } return rc;}/*! \since 4.5 Returns the frame's security origin.*/QWebSecurityOrigin QWebFrame::securityOrigin() const{ QWebFrame* that = const_cast<QWebFrame*>(this); QWebSecurityOriginPrivate* priv = new QWebSecurityOriginPrivate(QWebFramePrivate::core(that)->document()->securityOrigin()); return QWebSecurityOrigin(priv);}WebCore::Frame* QWebFramePrivate::core(QWebFrame* webFrame){ return webFrame->d->frame;}QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame){ return static_cast<FrameLoaderClientQt*>(coreFrame->loader()->client())->webFrame();}/*! \fn void QWebFrame::javaScriptWindowObjectCleared() This signal is emitted whenever the global window object of the JavaScript environment is cleared, e.g., before starting a new load. If you intend to add QObjects to a QWebFrame using addToJavaScriptWindowObject(), you should add them in a slot connected to this signal. This ensures that your objects remain accessible when loading new URLs.*//*! \fn void QWebFrame::provisionalLoad() \internal*//*! \fn void QWebFrame::titleChanged(const QString &title) This signal is emitted whenever the title of the frame changes. The \a title string specifies the new title. \sa title()*//*! \fn void QWebFrame::urlChanged(const QUrl &url) This signal is emitted with the URL of the frame when the frame's title is received. The new URL is specified by \a url. \sa url()*//*! \fn void QWebFrame::initialLayoutCompleted() This signal is emitted when the frame is laid out the first time. This is the first time you will see contents displayed on the frame. \note A frame can be laid out multiple times.*//*! \fn void QWebFrame::iconChanged() This signal is emitted when the icon ("favicon") associated with the frame has been loaded. \sa icon()*//*! \fn void QWebFrame::contentsSizeChanged(const QSize &size) \since 4.6 This signal is emitted when the frame's contents size changes. \sa contentsSize()*//*! \class QWebHitTestResult \since 4.4 \brief The QWebHitTestResult class provides information about the web page content after a hit test. QWebHitTestResult is returned by QWebFrame::hitTestContent() to provide information about the content of the web page at the specified position.*//*! \internal*/QWebHitTestResult::QWebHitTestResult(QWebHitTestResultPrivate *priv) : d(priv){}QWebHitTestResultPrivate::QWebHitTestResultPrivate(const WebCore::HitTestResult &hitTest) : isContentEditable(false) , isContentSelected(false) , isScrollBar(false){ if (!hitTest.innerNode()) return; pos = hitTest.point(); boundingRect = hitTest.boundingBox(); title = hitTest.title(); linkText = hitTest.textContent(); linkUrl = hitTest.absoluteLinkURL(); linkTitle = hitTest.titleDisplayString(); alternateText = hitTest.altDisplayString(); imageUrl = hitTest.absoluteImageURL(); innerNode = hitTest.innerNode(); innerNonSharedNode = hitTest.innerNonSharedNode(); WebCore::Image *img = hitTest.image(); if (img) { QPixmap *pix = img->nativeImageForCurrentFrame(); if (pix) pixmap = *pix; } WebCore::Frame *wframe = hitTest.targetFrame(); if (wframe) linkTargetFrame = QWebFramePrivate::kit(wframe); Element* urlElement = hitTest.URLElement(); if (urlElement) linkTarget = urlElement->target(); isContentEditable = hitTest.isContentEditable(); isContentSelected = hitTest.isSelected(); isScrollBar = hitTest.scrollbar(); if (innerNonSharedNode && innerNonSharedNode->document() && innerNonSharedNode->document()->frame()) frame = QWebFramePrivate::kit(innerNonSharedNode->document()->frame()); if (Node *block = WebCore::enclosingBlock(innerNode.get())) { RenderObject *renderBlock = block->renderer(); while (renderBlock && renderBlock->isListItem()) renderBlock = renderBlock->containingBlock(); if (renderBlock) enclosingBlock = renderBlock->absoluteClippedOverflowRect(); }}/*! Constructs a null hit test result.*/QWebHitTestResult::QWebHitTestResult() : d(0){}/*! Constructs a hit test result from \a other.*/QWebHitTestResult::QWebHitTestResult(const QWebHitTestResult &other) : d(0){ if (other.d) d = new QWebHitTestResultPrivate(*other.d);}/*! Assigns the \a other hit test result to this.*/QWebHitTestResult &QWebHitTestResult::operator=(const QWebHitTestResult &other){ if (this != &other) { if (other.d) { if (!d) d = new QWebHitTestResultPrivate; *d = *other.d; } else { delete d; d = 0; } } return *this;}/*! Destructor.*/QWebHitTestResult::~QWebHitTestResult(){ delete d;}/*! Returns true if the hit test result is null; otherwise returns false.*/bool QWebHitTestResult::isNull() const{ return !d;}/*! Returns the position where the hit test occured.*/QPoint QWebHitTestResult::pos() const{ if (!d) return QPoint(); return d->pos;}/*! \since 4.5 Returns the bounding rect of the element.*/QRect QWebHitTestResult::boundingRect() const{ if (!d) return QRect(); return d->boundingRect;}/*! \since 4.6 Returns the rect of the smallest enclosing block element.*/QRect QWebHitTestResult::enclosingBlock() const{ if (!d) return QRect(); return d->enclosingBlock;}/*! Returns the title of the nearest enclosing HTML element.*/QString QWebHitTestResult::title() const{ if (!d) return QString(); return d->title;}/*! Returns the text of the link.*/QString QWebHitTestResult::linkText() const{ if (!d) return QString(); return d->linkText;}/*! Returns the url to which the link points to.*/QUrl QWebHitTestResult::linkUrl() const{ if (!d) return QUrl(); return d->linkUrl;}/*! Returns the title of the link.*/QUrl QWebHitTestResult::linkTitle() const{ if (!d) return QUrl(); return d->linkTitle;}/*! \since 4.6 Returns the name of the target frame that will load the link if it is activated. \sa linkTargetFrame*/QString QWebHitTestResult::linkTarget() const{ if (!d) return 0; return d->linkTarget;}/*! Returns the frame that will load the link if it is activated. \sa linkTarget*/QWebFrame *QWebHitTestResult::linkTargetFrame() const{ if (!d) return 0; return d->linkTargetFrame;}/*! Returns the alternate text of the element. This corresponds to the HTML alt attribute.*/QString QWebHitTestResult::alternateText() const{ if (!d) return QString(); return d->alternateText;}/*! Returns the url of the image.*/QUrl QWebHitTestResult::imageUrl() const{ if (!d) return QUrl(); return d->imageUrl;}/*! Returns a QPixmap containing the image. A null pixmap is returned if the element being tested is not an image.*/QPixmap QWebHitTestResult::pixmap() const{ if (!d) return QPixmap(); return d->pixmap;}/*! Returns true if the content is editable by the user; otherwise returns false.*/bool QWebHitTestResult::isContentEditable() const{ if (!d) return false; return d->isContentEditable;}/*! Returns true if the content tested is part of the selection; otherwise returns false.*/bool QWebHitTestResult::isContentSelected() const{ if (!d) return false; return d->isContentSelected;}/*! Returns the frame the hit test was executed in.*/QWebFrame *QWebHitTestResult::frame() const{ if (!d) return 0; return d->frame;}/*! \since 4.6 Returns true if the test includes a scrollbar.*/bool QWebHitTestResult::isScrollBar() const{ if (!d) return false; return d->isScrollBar;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -