void CSSStyleSheet::setMediaQueries(PassRefPtr<MediaQuerySet> mediaQueries) { m_mediaQueries = mediaQueries; // Add warning message to inspector whenever dpi/dpcm values are used for "screen" media. reportMediaQueryWarningIfNeeded(ownerDocument(), m_mediaQueries.get()); }
Attr* Element::setAttributeNodeNS(Attr* newAttr) { poco_check_ptr (newAttr); if (newAttr->ownerDocument() != ownerDocument()) throw DOMException(DOMException::WRONG_DOCUMENT_ERR); if (newAttr->ownerElement()) throw DOMException(DOMException::INUSE_ATTRIBUTE_ERR); Attr* oldAttr = getAttributeNodeNS(newAttr->namespaceURI(), newAttr->localName()); if (oldAttr) removeAttributeNode(oldAttr); Attr* pCur = _pFirstAttr; if (pCur) { while (pCur->_pNext) pCur = static_cast<Attr*>(pCur->_pNext); pCur->_pNext = newAttr; } else _pFirstAttr = newAttr; newAttr->_pParent = this; newAttr->duplicate(); if (_pOwner->events()) dispatchAttrModified(newAttr, MutationEvent::ADDITION, EMPTY_STRING, newAttr->getValue()); return oldAttr; }
CachedResourceLoader* XSLStyleSheet::cachedResourceLoader() { Document* document = ownerDocument(); if (!document) return 0; return document->cachedResourceLoader(); }
void CSSStyleSheet::didMutate() { Document* owner = ownerDocument(); if (!owner) return; owner->styleResolverChanged(DeferRecalcStyle); }
void CSSStyleSheet::setMediaQueries(Ref<MediaQuerySet>&& mediaQueries) { m_mediaQueries = WTFMove(mediaQueries); if (m_mediaCSSOMWrapper && m_mediaQueries) m_mediaCSSOMWrapper->reattach(m_mediaQueries.get()); reportMediaQueryWarningIfNeeded(ownerDocument(), m_mediaQueries.get()); }
void SVGPolyElement::notifyAttributeChange() const { if (m_ignoreAttributeChanges || ownerDocument()->parsing()) return; m_ignoreAttributeChanges = true; rebuildRenderer(); ExceptionCode ec = 0; // Spec: Additionally, the 'points' attribute on the original element // accessed via the XML DOM (e.g., using the getAttribute() method call) // will reflect any changes made to points. String _points; int len = points()->numberOfItems(); for (int i = 0; i < len; ++i) { FloatPoint p = points()->getItem(i, ec); _points += String::format("%.6lg %.6lg ", p.x(), p.y()); } RefPtr<Attr> attr = const_cast<SVGPolyElement*>(this)->getAttributeNode(SVGNames::pointsAttr.localName()); if (attr) { ExceptionCode ec = 0; attr->setValue(_points, ec); } m_ignoreAttributeChanges = false; SVGStyledElement::notifyAttributeChange(); }
bool InspectorStyleSheet::resourceStyleSheetText(String* result) const { if (!m_pageStyleSheet) return false; return InspectorResourceAgent::resourceContent(ownerDocument()->frame(), m_pageStyleSheet->finalURL(), result); }
ExceptionOr<unsigned> CSSStyleSheet::deprecatedInsertRule(const String& ruleString) { if (auto* document = ownerDocument()) document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, ASCIILiteral("Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0).")); return insertRule(ruleString, 0); }
void SVGPathElement::notifyAttributeChange() const { if (!ownerDocument()->parsing()) rebuildRenderer(); SVGStyledElement::notifyAttributeChange(); }
void SVGStyleElement::childrenChanged() { SVGElement::childrenChanged(); if(m_sheet) m_sheet = 0; m_loading = false; MediaQueryEvaluator screenEval("screen", true); MediaQueryEvaluator printEval("print", true); RefPtr<MediaList> mediaList = new MediaList((CSSStyleSheet*)0, media()); if ((type().isEmpty() || type() == "text/css") && (screenEval.eval(mediaList.get()) || printEval.eval(mediaList.get()))) { ownerDocument()->addPendingSheet(); m_loading = true; m_sheet = new CSSStyleSheet(this); m_sheet->parseString(textContent()); // SVG css is always parsed in strict mode m_sheet->setMedia(mediaList.get()); m_loading = false; } if(!isLoading() && m_sheet) document()->stylesheetLoaded(); }
PassRefPtr<DocumentFragment> TextTrackCue::getCueAsHTML() { createWebVTTNodeTree(); RefPtr<DocumentFragment> clonedFragment = DocumentFragment::create(ownerDocument()); copyWebVTTNodeToDOMTree(m_webVTTNodeTree.get(), clonedFragment.get()); return clonedFragment.release(); }
ResourceFetcher* XSLStyleSheet::fetcher() { Document* document = ownerDocument(); if (!document) return 0; return document->fetcher(); }
PassRefPtr<DocumentFragment> TextTrackCue::createCueRenderingTree() { RefPtr<DocumentFragment> clonedFragment; createWebVTTNodeTree(); clonedFragment = DocumentFragment::create(ownerDocument()); m_webVTTNodeTree->cloneChildNodes(clonedFragment.get()); return clonedFragment.release(); }
void SVGFEImageElement::requestImageResource() { if (m_cachedImage) { m_cachedImage->removeClient(this); m_cachedImage = 0; } Element* hrefElement = SVGURIReference::targetElementFromIRIString(href(), document()); if (hrefElement && hrefElement->isSVGElement() && hrefElement->renderer()) return; ResourceRequest request(ownerDocument()->completeURL(href())); m_cachedImage = ownerDocument()->cachedResourceLoader()->requestImage(request); if (m_cachedImage) m_cachedImage->addClient(this); }
void SVGFEImageElement::requestImageResource() { ResourceRequest request(ownerDocument()->completeURL(href())); m_cachedImage = document()->cachedResourceLoader()->requestImage(request); if (m_cachedImage) m_cachedImage->addClient(this); }
void CSSStyleSheet::clearOwnerNode() { Document* owner = ownerDocument(); m_ownerNode = 0; if (!owner) return; owner->styleResolverChanged(DeferRecalcStyleIfNeeded); }
LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties() const { LinearGradientAttributes attributes; HashSet<const SVGGradientElement*> processedGradients; bool isLinear = true; const SVGGradientElement* current = this; while (current) { if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spreadMethodAttr)) attributes.setSpreadMethod((GradientSpreadMethod) current->spreadMethod()); if (!attributes.hasBoundingBoxMode() && current->hasAttribute(SVGNames::gradientUnitsAttr)) attributes.setBoundingBoxMode(current->gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames::gradientTransformAttr)) attributes.setGradientTransform(current->gradientTransform()->consolidate().matrix()); if (!attributes.hasStops()) { const Vector<SVGGradientStop>& stops(current->buildStops()); if (!stops.isEmpty()) attributes.setStops(stops); } if (isLinear) { const SVGLinearGradientElement* linear = static_cast<const SVGLinearGradientElement*>(current); if (!attributes.hasX1() && current->hasAttribute(SVGNames::x1Attr)) attributes.setX1(linear->x1()); if (!attributes.hasY1() && current->hasAttribute(SVGNames::y1Attr)) attributes.setY1(linear->y1()); if (!attributes.hasX2() && current->hasAttribute(SVGNames::x2Attr)) attributes.setX2(linear->x2()); if (!attributes.hasY2() && current->hasAttribute(SVGNames::y2Attr)) attributes.setY2(linear->y2()); } processedGradients.add(current); // Respect xlink:href, take attributes from referenced element Node* refNode = ownerDocument()->getElementById(SVGURIReference::getTarget(current->href())); if (refNode && (refNode->hasTagName(SVGNames::linearGradientTag) || refNode->hasTagName(SVGNames::radialGradientTag))) { current = static_cast<const SVGGradientElement*>(const_cast<const Node*>(refNode)); // Cycle detection if (processedGradients.contains(current)) return LinearGradientAttributes(); isLinear = current->gradientType() == LinearGradientPaintServer; } else current = 0; } return attributes; }
void SVGTRefElement::updateReferencedText() { Element* targetElement = ownerDocument()->getElementById(SVGURIReference::getTarget(href())); SVGElement* target = svg_dynamic_cast(targetElement); if (target) { ExceptionCode ignore = 0; setTextContent(target->textContent(), ignore); } }
PassRefPtr<HTMLDivElement> TextTrackRegion::getDisplayTree() { if (!m_regionDisplayTree) { m_regionDisplayTree = HTMLDivElement::create(ownerDocument()); prepareRegionDisplayTree(); } return m_regionDisplayTree; }
HTMLDivElement& VTTRegion::getDisplayTree() { if (!m_regionDisplayTree) { m_regionDisplayTree = HTMLDivElement::create(*ownerDocument()); prepareRegionDisplayTree(); } return *m_regionDisplayTree; }
Node DocumentImpl::constructNode(NodeImpl* object) { if (object) { Node domObject(object); domObject->_setSelf(domObject); domObject->_setOwnerDocument(ownerDocument()); return domObject; } return Node(); }
bool XSLStyleSheet::parseString(const String& string) { // Parse in a single chunk into an xmlDocPtr const UChar BOM = 0xFEFF; const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM); if (!m_stylesheetDocTaken) xmlFreeDoc(m_stylesheetDoc); m_stylesheetDocTaken = false; Console* console = 0; if (ownerDocument()->frame()) console = ownerDocument()->domWindow()->console(); XMLDocumentParserScope scope(cachedResourceLoader(), XSLTProcessor::genericErrorFunc, XSLTProcessor::parseErrorFunc, console); const char* buffer = reinterpret_cast<const char*>(string.characters()); int size = string.length() * sizeof(UChar); xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt(buffer, size); if (!ctxt) return 0; if (m_parentStyleSheet) { // The XSL transform may leave the newly-transformed document // with references to the symbol dictionaries of the style sheet // and any of its children. XML document disposal can corrupt memory // if a document uses more than one symbol dictionary, so we // ensure that all child stylesheets use the same dictionaries as their // parents. xmlDictFree(ctxt->dict); ctxt->dict = m_parentStyleSheet->m_stylesheetDoc->dict; xmlDictReference(ctxt->dict); } m_stylesheetDoc = xmlCtxtReadMemory(ctxt, buffer, size, finalURL().string().utf8().data(), BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE", XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_NOWARNING | XML_PARSE_NOCDATA); xmlFreeParserCtxt(ctxt); loadChildSheets(); return m_stylesheetDoc; }
DocumentInit::DocumentInit(const KURL& url, Frame* frame, WeakPtr<Document> contextDocument, HTMLImport* import) : m_url(url) , m_frame(frame) , m_parent(parentDocument(frame)) , m_owner(ownerDocument(frame)) , m_contextDocument(contextDocument) , m_import(import) , m_createNewRegistrationContext(false) { }
void DocumentXML::ajouterSommet(Sommet* sommet, QString id){ //Création de l'élément dans le document Dom QDomElement qElmt=ownerDocument().createElement("Sommet"); XMLElementSommet *elmt=new XMLElementSommet(sommet,qElmt,graphe); QDomElement listeDomSommets = documentElement().firstChildElement("Sommets"); listeDomSommets.appendChild(*elmt); //On fixe la valeur affichée elmt->setAttribute(QString("id"),id); }
Text* CDATASection::splitText(unsigned long offset) { Node* pParent = parentNode(); if (!pParent) throw DOMException(DOMException::HIERARCHY_REQUEST_ERR); int n = length() - offset; Text* pNew = ownerDocument()->createCDATASection(substringData(offset, n)); deleteData(offset, n); pParent->insertBefore(pNew, nextSibling())->release(); return pNew; }
void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const { HashSet<const SVGPatternElement*> processedPatterns; const SVGPatternElement* current = this; while (current) { if (!attributes.hasX() && current->hasAttribute(SVGNames::xAttr)) attributes.setX(current->x()); if (!attributes.hasY() && current->hasAttribute(SVGNames::yAttr)) attributes.setY(current->y()); if (!attributes.hasWidth() && current->hasAttribute(SVGNames::widthAttr)) attributes.setWidth(current->width()); if (!attributes.hasHeight() && current->hasAttribute(SVGNames::heightAttr)) attributes.setHeight(current->height()); if (!attributes.hasViewBox() && current->hasAttribute(SVGNames::viewBoxAttr)) attributes.setViewBox(current->viewBox()); if (!attributes.hasPreserveAspectRatio() && current->hasAttribute(SVGNames::preserveAspectRatioAttr)) attributes.setPreserveAspectRatio(current->preserveAspectRatio()); if (!attributes.hasBoundingBoxMode() && current->hasAttribute(SVGNames::patternUnitsAttr)) attributes.setBoundingBoxMode(current->patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); if (!attributes.hasBoundingBoxModeContent() && current->hasAttribute(SVGNames::patternContentUnitsAttr)) attributes.setBoundingBoxModeContent(current->patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); if (!attributes.hasPatternTransform() && current->hasAttribute(SVGNames::patternTransformAttr)) { AffineTransform transform; current->patternTransform().concatenate(transform); attributes.setPatternTransform(transform); } if (!attributes.hasPatternContentElement() && current->hasChildNodes()) attributes.setPatternContentElement(current); processedPatterns.add(current); // Respect xlink:href, take attributes from referenced element Node* refNode = ownerDocument()->getElementById(SVGURIReference::getTarget(current->href())); if (refNode && refNode->hasTagName(SVGNames::patternTag)) { current = static_cast<const SVGPatternElement*>(const_cast<const Node*>(refNode)); // Cycle detection if (processedPatterns.contains(current)) { current = 0; break; } } else current = 0; } }
void CSSStyleSheet::setMediaQueries(PassRefPtr<MediaQuerySet> mediaQueries) { m_mediaQueries = mediaQueries; if (m_mediaCSSOMWrapper && m_mediaQueries) m_mediaCSSOMWrapper->reattach(m_mediaQueries.get()); #if ENABLE(RESOLUTION_MEDIA_QUERY) // Add warning message to inspector whenever dpi/dpcm values are used for "screen" media. reportMediaQueryWarningIfNeeded(ownerDocument(), m_mediaQueries.get()); #endif }
void SVGTextPathElement::insertedIntoDocument() { SVGElement::insertedIntoDocument(); String id = SVGURIReference::getTarget(href()); Element* targetElement = ownerDocument()->getElementById(id); if (!targetElement) { document()->accessSVGExtensions()->addPendingResource(id, this); return; } }
void CSSStyleSheet::didMutate(StyleSheetUpdateType updateType) { Document* owner = ownerDocument(); if (!owner) return; // Need FullStyleUpdate when insertRule or deleteRule, // because StyleSheetCollection::analyzeStyleSheetChange cannot detect partial rule update. StyleResolverUpdateMode updateMode = updateType != PartialRuleUpdate ? AnalyzedStyleUpdate : FullStyleUpdate; owner->modifiedStyleSheet(this, updateMode); }
DocumentInit::DocumentInit(const KURL& url, LocalFrame* frame, WeakPtrWillBeRawPtr<Document> contextDocument, HTMLImportsController* importsController) : m_url(url) , m_frame(frame) , m_parent(parentDocument(frame)) , m_owner(ownerDocument(frame)) , m_contextDocument(contextDocument) , m_importsController(importsController) , m_createNewRegistrationContext(false) , m_shouldReuseDefaultView(frame && frame->shouldReuseDefaultView(url)) { }