VMdEditor::VMdEditor(VFile *p_file, VDocument *p_doc, MarkdownConverterType p_type, QWidget *p_parent) : VTextEdit(p_parent), VEditor(p_file, this), m_mdHighlighter(NULL), m_freshEdit(true), m_textToHtmlDialog(NULL), m_zoomDelta(0) { Q_ASSERT(p_file->getDocType() == DocType::Markdown); VEditor::init(); // Hook functions from VEditor. connect(this, &VTextEdit::cursorPositionChanged, this, [this]() { highlightOnCursorPositionChanged(); }); connect(this, &VTextEdit::selectionChanged, this, [this]() { highlightSelectedWord(); }); // End. setReadOnly(true); m_mdHighlighter = new HGMarkdownHighlighter(g_config->getMdHighlightingStyles(), g_config->getCodeBlockStyles(), g_config->getMarkdownHighlightInterval(), document()); connect(m_mdHighlighter, &HGMarkdownHighlighter::headersUpdated, this, &VMdEditor::updateHeaders); // After highlight, the cursor may trun into non-visible. We should make it visible // in this case. connect(m_mdHighlighter, &HGMarkdownHighlighter::highlightCompleted, this, [this]() { makeBlockVisible(textCursor().block()); if (m_freshEdit) { m_freshEdit = false; emit m_object->ready(); } }); m_cbHighlighter = new VCodeBlockHighlightHelper(m_mdHighlighter, p_doc, p_type); m_previewMgr = new VPreviewManager(this, m_mdHighlighter); connect(m_mdHighlighter, &HGMarkdownHighlighter::imageLinksUpdated, m_previewMgr, &VPreviewManager::imageLinksUpdated); connect(m_previewMgr, &VPreviewManager::requestUpdateImageLinks, m_mdHighlighter, &HGMarkdownHighlighter::updateHighlight); m_editOps = new VMdEditOperations(this, m_file); connect(m_editOps, &VEditOperations::statusMessage, m_object, &VEditorObject::statusMessage); connect(m_editOps, &VEditOperations::vimStatusUpdated, m_object, &VEditorObject::vimStatusUpdated); connect(this, &VTextEdit::cursorPositionChanged, this, &VMdEditor::updateCurrentHeader); updateFontAndPalette(); updateConfig(); }
void KateEditRemoveLineUndo::redo () { KateDocument *doc = document(); doc->editRemoveLine (m_line); }
void KateEditMarkLineAutoWrappedUndo::redo () { KateDocument *doc = document(); doc->editMarkLineAutoWrapped (m_line, m_autowrapped); }
void KateEditUnWrapLineUndo::undo () { KateDocument *doc = document(); doc->editWrapLine (m_line, m_col, m_removeLine); }
void KateEditUnWrapLineUndo::redo () { KateDocument *doc = document(); doc->editUnWrapLine (m_line, m_removeLine, m_len); }
void FrmInformacionFarmaco::finishedSlotBuscarMedicamento(QNetworkReply* reply) { //qDebug()<<reply->readAll(); QString data=(QString)reply->readAll(); QString cXML = data; // Extract values from XML QDomDocument document("XmlDoc"); document.setContent(cXML); QDomElement root = document.documentElement(); if (root .tagName() != "object") qDebug("Bad root element."); QDomNode drugList = root.firstChild(); QDomNode n = drugList.firstChild(); QDomNode n2 = n.firstChild(); QDomNode n3 = n2.firstChild(); while (!n.isNull()) { if (n.isElement()) { QDomNodeList attributes = n.childNodes(); for (int i = 0; i < attributes.count(); i ++) { QDomElement e = attributes.at(i).toElement(); if (e.tagName() == "name_speciality") { ui->txtNombre->setText(e.text()); } if (e.tagName() == "dosage_form") { ui->txtDosificacion->setText(e.text()); } if (e.tagName() == "national_code") { ui->txtcodigo_nacional->setText(e.text()); } if (e.tagName() == "name_laboratory") { ui->txtLaboratorio->setText(e.text()); } if (e.tagName() == "name_atc") { ui->txtNombreATC->setText(e.text()); } if (e.tagName() == "drug_type") { ui->txtTipoMedicamento->setText(e.text()); } if (e.tagName() == "package") { ui->txtCaja->setText(e.text()); } if (e.tagName() == "price") { ui->txtPVP->setText(e.text()); } if (e.tagName() == "laboratory_price") { ui->txtPVC->setText(e.text()); } if (e.tagName() == "TLD") { ui->txtTLD->setText(e.text()); } if (e.tagName() == "RECETA") { ui->txtReceta->setText(e.text()); } if (e.tagName() == "FINAN") { ui->txtFinanciado->setText(e.text()); } if (e.tagName() == "fecha_alta") { QDate alta; int ano,mes,dia; ano = e.text().left(4).toInt(); mes = e.text().mid(5,2).toInt(); dia = e.text().mid(8,2).toInt(); alta.setDate(ano,mes,dia); ui->txtfecha_alta->setDate(alta); } if (e.tagName() == "fecha_baja") { if (e.text()!="0" && !e.text().isEmpty()) { QDate baja; int ano,mes,dia; ano = e.text().left(4).toInt(); mes = e.text().mid(5,2).toInt(); dia = e.text().mid(8,2).toInt(); baja.setDate(ano,mes,dia); ui->txtFechaBaja->setVisible(true); ui->lblfechabaja->setVisible(true); ui->txtFechaBaja->setDate(baja); } else { ui->txtFechaBaja->setVisible(false); ui->lblfechabaja->setVisible(false); } } if (e.tagName() == "baja") { if(e.text()=="1") ui->lblDadodeBaja->setVisible(true); else ui->lblDadodeBaja->setVisible(false); } if (e.tagName() == "id_laboratory") { QUrl uUrl; QString cUrl = "http://svadcf.es/documentos/image/fotos/laboratorio/"+e.text().trimmed()+".gif"; uUrl.setUrl(cUrl); ui->webLogoLaboratorio->load(uUrl); } if (e.tagName() == "id_speciality") { connect(ui->webimagen1,SIGNAL(loadFinished(bool)),this, SLOT(cargaFinalizada1(bool))); connect(ui->webimagen2,SIGNAL(loadFinished(bool)),this, SLOT(cargaFinalizada2(bool))); connect(ui->webimagen3,SIGNAL(loadFinished(bool)),this, SLOT(cargaFinalizada3(bool))); connect(ui->webLogoLaboratorio,SIGNAL(loadFinished(bool)),this, SLOT(cargaFinalizadaLogo(bool))); QUrl uUrl; QString cUrl = "http://svadcf.es/documentos/image/fotos/medicamento/"+e.text().trimmed()+"_1.jpg"; uUrl.setUrl(cUrl); ui->webimagen1->load(uUrl); cUrl = "http://svadcf.es/documentos/image/fotos/medicamento/"+e.text().trimmed()+"_2.jpg"; uUrl.setUrl(cUrl); ui->webimagen2->load(uUrl); cUrl = "http://svadcf.es/documentos/image/fotos/medicamento/"+e.text().trimmed()+"_3.jpg"; uUrl.setUrl(cUrl); ui->webimagen3->load(uUrl); } //---------------------------- // Llenar tabla indicaciones //---------------------------- if (e.tagName() == "Indications_set") { ui->listaIndicaciones->setColumnCount(2); ui->listaIndicaciones->setColumnWidth(0,200); ui->listaIndicaciones->setColumnWidth(1,0); //int nrow = 0; int pos = 0; while (!n2.isNull()) { if (n2.isElement()) { QDomNodeList attributes = n2.childNodes(); for (int i = 0; i < attributes.count(); i ++) { QDomElement e2 = attributes.at(i).toElement(); if (e2.tagName() == "") while (!n3.isNull()) { if (n3.isElement()) { QDomNodeList attributes = n3.childNodes(); for (int i = 0; i < attributes.count(); i ++) { QDomElement e3 = attributes.at(i).toElement(); if (e3.tagName() == "id_IND") { ui->listaIndicaciones->setRowCount(pos+1); QTableWidgetItem *newItem = new QTableWidgetItem(e3.text()); // para que los elementos no sean editables newItem->setFlags(newItem->flags() & (~Qt::ItemIsEditable)); newItem->setTextColor(Qt::blue); // color de los items ui->listaIndicaciones->setItem(pos,1,newItem); } if (e3.tagName() == "TITINDMIN") { ui->listaIndicaciones->setRowCount(pos+1); QTableWidgetItem *newItem = new QTableWidgetItem(e3.text()); // para que los elementos no sean editables newItem->setFlags(newItem->flags() & (~Qt::ItemIsEditable)); newItem->setTextColor(Qt::blue); // color de los items ui->listaIndicaciones->setItem(pos,0,newItem); } } pos++; //data.append(s); } n3 = n3.nextSibling(); } } n2 = n2.nextSibling(); } } } } n = n.nextSibling(); }
void UndoCommand::onExecute(Context* context) { ContextWriter writer(context); Doc* document(writer.document()); DocUndo* undo = document->undoHistory(); #ifdef ENABLE_UI Sprite* sprite = document->sprite(); SpritePosition spritePosition; const bool gotoModified = (Preferences::instance().undo.gotoModified() && context->isUIAvailable() && current_editor); if (gotoModified) { SpritePosition currentPosition(writer.site()->layer(), writer.site()->frame()); if (m_type == Undo) spritePosition = undo->nextUndoSpritePosition(); else spritePosition = undo->nextRedoSpritePosition(); if (spritePosition != currentPosition) { Layer* selectLayer = spritePosition.layer(); if (selectLayer) current_editor->setLayer(selectLayer); current_editor->setFrame(spritePosition.frame()); // Draw the current layer/frame (which is not undone yet) so the // user can see the doUndo/doRedo effect. current_editor->drawSpriteClipped( gfx::Region(gfx::Rect(0, 0, sprite->width(), sprite->height()))); current_editor->manager()->flipDisplay(); base::this_thread::sleep_for(0.01); } } // Get the stream to deserialize the document range after executing // the undo/redo action. We cannot yet deserialize the document // range because there could be inexistent layers. std::istream* docRangeStream; if (m_type == Undo) docRangeStream = undo->nextUndoDocRange(); else docRangeStream = undo->nextRedoDocRange(); StatusBar* statusbar = StatusBar::instance(); if (statusbar) { std::string msg; if (m_type == Undo) msg = "Undid " + undo->nextUndoLabel(); else msg = "Redid " + undo->nextRedoLabel(); if (Preferences::instance().undo.showTooltip()) statusbar->showTip(1000, msg.c_str()); else statusbar->setStatusText(0, msg.c_str()); } #endif // ENABLE_UI // Effectively undo/redo. if (m_type == Undo) undo->undo(); else undo->redo(); #ifdef ENABLE_UI // After redo/undo, we retry to change the current SpritePosition // (because new frames/layers could be added, positions that we // weren't able to reach before the undo). if (gotoModified) { Site newSite = context->activeSite(); SpritePosition currentPosition( newSite.layer(), newSite.frame()); if (spritePosition != currentPosition) { Layer* selectLayer = spritePosition.layer(); if (selectLayer) current_editor->setLayer(selectLayer); current_editor->setFrame(spritePosition.frame()); } } // Update timeline range. We've to deserialize the DocRange at // this point when objects (possible layers) are re-created after // the undo and we can deserialize them. if (docRangeStream) { Timeline* timeline = App::instance()->timeline(); if (timeline) { DocRange docRange; if (docRange.read(*docRangeStream)) timeline->setRange(docRange); } } #endif // ENABLE_UI document->generateMaskBoundaries(); document->setExtraCel(ExtraCelRef(nullptr)); #ifdef ENABLE_UI update_screen_for_document(document); #endif set_current_palette(writer.palette(), false); }
int SVGTextContentElement::getCharNumAtPosition(const SVGPoint& point) { document().updateLayoutIgnorePendingStylesheets(); return SVGTextQuery(renderer()).characterNumberAtPosition(point); }
PassRefPtr<Node> Text::cloneNode(bool /*deep*/) { return document()->createTextNode(str); }
unsigned SVGTextContentElement::getNumberOfChars() { document().updateLayoutIgnorePendingStylesheets(); return SVGTextQuery(renderer()).numberOfCharacters(); }
float SVGTextContentElement::getComputedTextLength() { document().updateLayoutIgnorePendingStylesheets(); return SVGTextQuery(renderer()).textLength(); }
QSize TextEditExWithTrScrollBar::contentSize() const { QSize sizeRect(document()->size().width(), document()->size().height()); return sizeRect; }
bool VMdEditor::jumpTitle(bool p_forward, int p_relativeLevel, int p_repeat) { if (m_headers.isEmpty()) { return false; } QTextCursor cursor = textCursor(); int cursorLine = cursor.block().blockNumber(); int targetIdx = -1; // -1: skip level check. int targetLevel = 0; int idx = indexOfCurrentHeader(); if (idx == -1) { // Cursor locates at the beginning, before any headers. if (p_relativeLevel < 0 || !p_forward) { return false; } } int delta = 1; if (!p_forward) { delta = -1; } bool firstHeader = true; for (targetIdx = idx == -1 ? 0 : idx; targetIdx >= 0 && targetIdx < m_headers.size(); targetIdx += delta) { const VTableOfContentItem &header = m_headers[targetIdx]; if (header.isEmpty()) { continue; } if (targetLevel == 0) { // The target level has not been init yet. Q_ASSERT(firstHeader); targetLevel = header.m_level; if (p_relativeLevel < 0) { targetLevel += p_relativeLevel; if (targetLevel < 1) { // Invalid level. return false; } } else if (p_relativeLevel > 0) { targetLevel = -1; } } if (targetLevel == -1 || header.m_level == targetLevel) { if (firstHeader && (cursorLine == header.m_blockNumber || p_forward) && idx != -1) { // This header is not counted for the repeat. firstHeader = false; continue; } if (--p_repeat == 0) { // Found. break; } } else if (header.m_level < targetLevel) { // Stop by higher level. return false; } firstHeader = false; } if (targetIdx < 0 || targetIdx >= m_headers.size()) { return false; } // Jump to target header. int line = m_headers[targetIdx].m_blockNumber; if (line > -1) { QTextBlock block = document()->findBlockByNumber(line); if (block.isValid()) { cursor.setPosition(block.position()); setTextCursor(cursor); return true; } } return false; }
void VMdEditor::updateHeaders(const QVector<VElementRegion> &p_headerRegions) { QTextDocument *doc = document(); QVector<VTableOfContentItem> headers; QVector<int> headerBlockNumbers; QVector<QString> headerSequences; if (!p_headerRegions.isEmpty()) { headers.reserve(p_headerRegions.size()); headerBlockNumbers.reserve(p_headerRegions.size()); headerSequences.reserve(p_headerRegions.size()); } // Assume that each block contains only one line // Only support # syntax for now QRegExp headerReg(VUtils::c_headerRegExp); int baseLevel = -1; for (auto const & reg : p_headerRegions) { QTextBlock block = doc->findBlock(reg.m_startPos); if (!block.isValid()) { continue; } if (!block.contains(reg.m_endPos - 1)) { qWarning() << "header accross multiple blocks, starting from block" << block.blockNumber() << block.text(); } if ((block.userState() == HighlightBlockState::Normal) && headerReg.exactMatch(block.text())) { int level = headerReg.cap(1).length(); VTableOfContentItem header(headerReg.cap(2).trimmed(), level, block.blockNumber(), headers.size()); headers.append(header); headerBlockNumbers.append(block.blockNumber()); headerSequences.append(headerReg.cap(3)); if (baseLevel == -1) { baseLevel = level; } else if (baseLevel > level) { baseLevel = level; } } } m_headers.clear(); bool autoSequence = m_config.m_enableHeadingSequence && !isReadOnly() && m_file->isModifiable(); int headingSequenceBaseLevel = g_config->getHeadingSequenceBaseLevel(); if (headingSequenceBaseLevel < 1 || headingSequenceBaseLevel > 6) { headingSequenceBaseLevel = 1; } QVector<int> seqs(7, 0); QRegExp preReg(VUtils::c_headerPrefixRegExp); int curLevel = baseLevel - 1; for (int i = 0; i < headers.size(); ++i) { VTableOfContentItem &item = headers[i]; while (item.m_level > curLevel + 1) { curLevel += 1; // Insert empty level which is an invalid header. m_headers.append(VTableOfContentItem(c_emptyHeaderName, curLevel, -1, m_headers.size())); if (autoSequence) { addHeaderSequence(seqs, curLevel, headingSequenceBaseLevel); } } item.m_index = m_headers.size(); m_headers.append(item); curLevel = item.m_level; if (autoSequence) { addHeaderSequence(seqs, item.m_level, headingSequenceBaseLevel); QString seqStr = headerSequenceStr(seqs); if (headerSequences[i] != seqStr) { // Insert correct sequence. insertSequenceToHeader(doc->findBlockByNumber(headerBlockNumbers[i]), headerReg, preReg, seqStr); } } } emit headersChanged(m_headers); updateCurrentHeader(); }
SVGDocumentExtensions* SVGElement::accessDocumentSVGExtensions() { // This function is provided for use by SVGAnimatedProperty to avoid // global inclusion of Document.h in SVG code. return document() ? document()->accessSVGExtensions() : 0; }
Text *Text::createNew(StringImpl *_str) { return new Text(document(), _str); }
void SongInfoTextView::ReloadSettings() { document()->setDefaultFont(Font()); }
bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url, bool forPreload) { if (document() && !document()->securityOrigin()->canDisplay(url)) { if (!forPreload) FrameLoader::reportLocalLoadFailed(frame(), url.elidedString()); LOG(ResourceLoading, "CachedResourceLoader::requestResource URL was not allowed by SecurityOrigin::canDisplay"); return 0; } // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved. bool shouldBypassMainWorldContentSecurityPolicy = (frame() && frame()->script()->shouldBypassMainWorldContentSecurityPolicy()); // Some types of resources can be loaded only from the same origin. Other // types of resources, like Images, Scripts, and CSS, can be loaded from // any URL. switch (type) { case CachedResource::MainResource: case CachedResource::ImageResource: case CachedResource::CSSStyleSheet: case CachedResource::Script: case CachedResource::FontResource: case CachedResource::RawResource: #if ENABLE(LINK_PREFETCH) case CachedResource::LinkPrefetch: case CachedResource::LinkSubresource: #endif #if ENABLE(VIDEO_TRACK) case CachedResource::TextTrackResource: #endif #if ENABLE(CSS_SHADERS) case CachedResource::ShaderResource: #endif // These types of resources can be loaded from any origin. // FIXME: Are we sure about CachedResource::FontResource? break; #if ENABLE(SVG) case CachedResource::SVGDocumentResource: #endif #if ENABLE(XSLT) case CachedResource::XSLStyleSheet: if (!m_document->securityOrigin()->canRequest(url)) { printAccessDeniedMessage(url); return false; } #endif break; } switch (type) { #if ENABLE(XSLT) case CachedResource::XSLStyleSheet: if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowScriptFromSource(url)) return false; break; #endif case CachedResource::Script: if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowScriptFromSource(url)) return false; if (frame()) { Settings* settings = frame()->settings(); if (!frame()->loader()->client()->allowScriptFromSource(!settings || settings->isScriptEnabled(), url)) { frame()->loader()->client()->didNotAllowScript(); return false; } } break; #if ENABLE(CSS_SHADERS) case CachedResource::ShaderResource: // Since shaders are referenced from CSS Styles use the same rules here. #endif case CachedResource::CSSStyleSheet: if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowStyleFromSource(url)) return false; break; #if ENABLE(SVG) case CachedResource::SVGDocumentResource: #endif case CachedResource::ImageResource: if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowImageFromSource(url)) return false; break; case CachedResource::FontResource: { if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowFontFromSource(url)) return false; break; } case CachedResource::MainResource: case CachedResource::RawResource: #if ENABLE(LINK_PREFETCH) case CachedResource::LinkPrefetch: case CachedResource::LinkSubresource: #endif break; #if ENABLE(VIDEO_TRACK) case CachedResource::TextTrackResource: // Cues aren't called out in the CPS spec yet, but they only work with a media element // so use the media policy. if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowMediaFromSource(url)) return false; break; #endif } // Last of all, check for insecure content. We do this last so that when // folks block insecure content with a CSP policy, they don't get a warning. // They'll still get a warning in the console about CSP blocking the load. // FIXME: Should we consider forPreload here? if (!checkInsecureContent(type, url)) return false; return true; }
auto_ptr<ImageBuffer> SVGMaskElement::drawMaskerContent(const FloatRect& targetRect, FloatRect& maskDestRect) const { // Determine specified mask size float xValue; float yValue; float widthValue; float heightValue; if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { xValue = x().valueAsPercentage() * targetRect.width(); yValue = y().valueAsPercentage() * targetRect.height(); widthValue = width().valueAsPercentage() * targetRect.width(); heightValue = height().valueAsPercentage() * targetRect.height(); } else { xValue = x().value(this); yValue = y().value(this); widthValue = width().value(this); heightValue = height().value(this); } IntSize imageSize(lroundf(widthValue), lroundf(heightValue)); clampImageBufferSizeToViewport(document()->view(), imageSize); if (imageSize.width() < static_cast<int>(widthValue)) widthValue = imageSize.width(); if (imageSize.height() < static_cast<int>(heightValue)) heightValue = imageSize.height(); auto_ptr<ImageBuffer> maskImage = ImageBuffer::create(imageSize, false); if (!maskImage.get()) return maskImage; maskDestRect = FloatRect(xValue, yValue, widthValue, heightValue); if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) maskDestRect.move(targetRect.x(), targetRect.y()); GraphicsContext* maskImageContext = maskImage->context(); ASSERT(maskImageContext); maskImageContext->save(); maskImageContext->translate(-xValue, -yValue); if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { maskImageContext->save(); maskImageContext->scale(FloatSize(targetRect.width(), targetRect.height())); } // Render subtree into ImageBuffer for (Node* n = firstChild(); n; n = n->nextSibling()) { SVGElement* elem = 0; if (n->isSVGElement()) elem = static_cast<SVGElement*>(n); if (!elem || !elem->isStyled()) continue; SVGStyledElement* e = static_cast<SVGStyledElement*>(elem); RenderObject* item = e->renderer(); if (!item) continue; renderSubtreeToImage(maskImage.get(), item); } if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) maskImageContext->restore(); maskImageContext->restore(); return maskImage; }
CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest& request) { KURL url = request.resourceRequest().url(); LOG(ResourceLoading, "CachedResourceLoader::requestResource '%s', charset '%s', priority=%d, forPreload=%u", url.elidedString().latin1().data(), request.charset().latin1().data(), request.priority(), request.forPreload()); // If only the fragment identifiers differ, it is the same resource. url = MemoryCache::removeFragmentIdentifierIfNeeded(url); if (!url.isValid()) return 0; if (!canRequest(type, url, request.forPreload())) return 0; if (Frame* f = frame()) f->loader()->client()->dispatchWillRequestResource(&request); if (memoryCache()->disabled()) { DocumentResourceMap::iterator it = m_documentResources.find(url.string()); if (it != m_documentResources.end()) { it->value->setOwningCachedResourceLoader(0); m_documentResources.remove(it); } } // See if we can use an existing resource from the cache. CachedResourceHandle<CachedResource> resource; #if ENABLE(CACHE_PARTITIONING) if (document()) request.mutableResourceRequest().setCachePartition(document()->topOrigin()->cachePartition()); #endif resource = memoryCache()->resourceForRequest(request.resourceRequest()); const RevalidationPolicy policy = determineRevalidationPolicy(type, request.mutableResourceRequest(), request.forPreload(), resource.get(), request.defer()); switch (policy) { case Reload: memoryCache()->remove(resource.get()); // Fall through case Load: resource = loadResource(type, request, request.charset()); break; case Revalidate: resource = revalidateResource(request, resource.get()); break; case Use: memoryCache()->resourceAccessed(resource.get()); notifyLoadedFromMemoryCache(resource.get()); break; } if (!resource) return 0; if (!request.forPreload() || policy != Use) resource->setLoadPriority(request.priority()); if ((policy != Use || resource->stillNeedsLoad()) && CachedResourceRequest::NoDefer == request.defer()) { resource->load(this, request.options()); // We don't support immediate loads, but we do support immediate failure. if (resource->errorOccurred()) { if (resource->inCache()) memoryCache()->remove(resource.get()); return 0; } } #if PLATFORM(CHROMIUM) // FIXME: Temporarily leave main resource caching disabled for chromium, see https://bugs.webkit.org/show_bug.cgi?id=107962 // Ensure main resources aren't preloaded, and other main resource loads are removed from cache to prevent reuse. if (type == CachedResource::MainResource) { ASSERT(policy != Use); ASSERT(policy != Revalidate); memoryCache()->remove(resource.get()); if (request.forPreload()) return 0; } #endif if (!request.resourceRequest().url().protocolIsData()) m_validatedURLs.add(request.resourceRequest().url()); ASSERT(resource->url() == url.string()); m_documentResources.set(resource->url(), resource); return resource; }
void KateEditWrapLineUndo::undo () { KateDocument *doc = document(); doc->editUnWrapLine (m_line, m_newLine, m_len); }
CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalidationPolicy(CachedResource::Type type, ResourceRequest& request, bool forPreload, CachedResource* existingResource, CachedResourceRequest::DeferOption defer) const { if (!existingResource) return Load; // We already have a preload going for this URL. if (forPreload && existingResource->isPreloaded()) return Use; // If the same URL has been loaded as a different type, we need to reload. if (existingResource->type() != type) { LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to type mismatch."); return Reload; } if (!existingResource->canReuse(request)) return Reload; // Certain requests (e.g., XHRs) might have manually set headers that require revalidation. // FIXME: In theory, this should be a Revalidate case. In practice, the MemoryCache revalidation path assumes a whole bunch // of things about how revalidation works that manual headers violate, so punt to Reload instead. if (request.isConditional()) return Reload; // Do not load from cache if images are not enabled. The load for this image will be blocked // in CachedImage::load. if (CachedResourceRequest::DeferredByClient == defer) return Reload; // Don't reload resources while pasting. if (m_allowStaleResources) return Use; // Alwaus use preloads. if (existingResource->isPreloaded()) return Use; // CachePolicyHistoryBuffer uses the cache no matter what. if (cachePolicy(type) == CachePolicyHistoryBuffer) return Use; // Don't reuse resources with Cache-control: no-store. if (existingResource->response().cacheControlContainsNoStore()) { LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to Cache-control: no-store."); return Reload; } // If credentials were sent with the previous request and won't be // with this one, or vice versa, re-fetch the resource. // // This helps with the case where the server sends back // "Access-Control-Allow-Origin: *" all the time, but some of the // client's requests are made without CORS and some with. if (existingResource->resourceRequest().allowCookies() != request.allowCookies()) { LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to difference in credentials settings."); return Reload; } // During the initial load, avoid loading the same resource multiple times for a single document, even if the cache policies would tell us to. if (document() && !document()->loadEventFinished() && m_validatedURLs.contains(existingResource->url())) return Use; // CachePolicyReload always reloads if (cachePolicy(type) == CachePolicyReload) { LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to CachePolicyReload."); return Reload; } // We'll try to reload the resource if it failed last time. if (existingResource->errorOccurred()) { LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicye reloading due to resource being in the error state"); return Reload; } // For resources that are not yet loaded we ignore the cache policy. if (existingResource->isLoading()) return Use; // Check if the cache headers requires us to revalidate (cache expiration for example). if (existingResource->mustRevalidateDueToCacheHeaders(cachePolicy(type))) { // See if the resource has usable ETag or Last-modified headers. if (existingResource->canUseCacheValidator()) return Revalidate; // No, must reload. LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to missing cache validators."); return Reload; } return Use; }
void KateEditInsertTextUndo::redo () { KateDocument *doc = document(); doc->editInsertText (m_line, m_col, m_text); }
PassRefPtrWillBeRawPtr<Node> ProcessingInstruction::cloneNode(bool /*deep*/) { // FIXME: Is it a problem that this does not copy m_localHref? // What about other data members? return create(document(), m_target, m_data); }
void KateEditWrapLineUndo::redo () { KateDocument *doc = document(); doc->editWrapLine (m_line, m_col, m_newLine); }
SVGDocumentExtensions& SVGElement::accessDocumentSVGExtensions() { // This function is provided for use by SVGAnimatedProperty to avoid // global inclusion of core/dom/Document.h in SVG code. return document().accessSVGExtensions(); }
void KateEditInsertLineUndo::redo () { KateDocument *doc = document(); doc->editInsertLine (m_line, m_text); }
void SVGElement::removedFromDocument() { document()->accessSVGExtensions()->removeAllAnimationElementsFromTarget(this); StyledElement::removedFromDocument(); }
void KateEditInsertTextUndo::undo () { KateDocument *doc = document(); doc->editRemoveText (m_line, m_col, len()); }
void VMdEditor::makeBlockVisible(const QTextBlock &p_block) { if (!p_block.isValid() || !p_block.isVisible()) { return; } QScrollBar *vbar = verticalScrollBar(); if (!vbar || (vbar->minimum() == vbar->maximum())) { // No vertical scrollbar. No need to scroll. return; } int height = rect().height(); QScrollBar *hbar = horizontalScrollBar(); if (hbar && (hbar->minimum() != hbar->maximum())) { height -= hbar->height(); } bool moved = false; QAbstractTextDocumentLayout *layout = document()->documentLayout(); QRectF rect = layout->blockBoundingRect(p_block); int y = GETVISUALOFFSETY; int rectHeight = (int)rect.height(); // Handle the case rectHeight >= height. if (rectHeight >= height) { if (y < 0) { // Need to scroll up. while (y + rectHeight < height && vbar->value() > vbar->minimum()) { moved = true; vbar->setValue(vbar->value() - vbar->singleStep()); rect = layout->blockBoundingRect(p_block); rectHeight = (int)rect.height(); y = GETVISUALOFFSETY; } } else if (y > 0) { // Need to scroll down. while (y > 0 && vbar->value() < vbar->maximum()) { moved = true; vbar->setValue(vbar->value() + vbar->singleStep()); rect = layout->blockBoundingRect(p_block); rectHeight = (int)rect.height(); y = GETVISUALOFFSETY; } if (y < 0) { // One step back. moved = true; vbar->setValue(vbar->value() - vbar->singleStep()); } } if (moved) { qDebug() << "scroll to make huge block visible"; } return; } while (y < 0 && vbar->value() > vbar->minimum()) { moved = true; vbar->setValue(vbar->value() - vbar->singleStep()); rect = layout->blockBoundingRect(p_block); rectHeight = (int)rect.height(); y = GETVISUALOFFSETY; } if (moved) { qDebug() << "scroll page down to make block visible"; return; } while (y + rectHeight > height && vbar->value() < vbar->maximum()) { moved = true; vbar->setValue(vbar->value() + vbar->singleStep()); rect = layout->blockBoundingRect(p_block); rectHeight = (int)rect.height(); y = GETVISUALOFFSETY; } if (moved) { qDebug() << "scroll page up to make block visible"; } }