String WebFrameSerializerImpl::preActionBeforeSerializeOpenTag( const Element* element, SerializeDomParam* param, bool* needSkip) { StringBuilder result; *needSkip = false; if (param->isHTMLDocument) { // Skip the open tag of original META tag which declare charset since we // have overrided the META which have correct charset declaration after // serializing open tag of HEAD element. DCHECK(element); if (isHTMLMetaElement(element) && toHTMLMetaElement(element)->computeEncoding().isValid()) { // Found META tag declared charset, we need to skip it when // serializing DOM. param->skipMetaElement = element; *needSkip = true; } else if (isHTMLHtmlElement(*element)) { // Check something before processing the open tag of HEAD element. // First we add doc type declaration if original document has it. if (!param->haveSeenDocType) { param->haveSeenDocType = true; result.append(createMarkup(param->document->doctype())); } // Add MOTW declaration before html tag. // See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx. result.append(WebFrameSerializer::generateMarkOfTheWebDeclaration(param->url)); } else if (isHTMLBaseElement(*element)) { // Comment the BASE tag when serializing dom. result.appendLiteral("<!--"); } } else { // Write XML declaration. if (!param->haveAddedXMLProcessingDirective) { param->haveAddedXMLProcessingDirective = true; // Get encoding info. String xmlEncoding = param->document->xmlEncoding(); if (xmlEncoding.isEmpty()) xmlEncoding = param->document->encodingName(); if (xmlEncoding.isEmpty()) xmlEncoding = UTF8Encoding().name(); result.appendLiteral("<?xml version=\""); result.append(param->document->xmlVersion()); result.appendLiteral("\" encoding=\""); result.append(xmlEncoding); if (param->document->xmlStandalone()) result.appendLiteral("\" standalone=\"yes"); result.appendLiteral("\"?>\n"); } // Add doc type declaration if original document has it. if (!param->haveSeenDocType) { param->haveSeenDocType = true; result.append(createMarkup(param->document->doctype())); } } return result.toString(); }
bool hasOpenGraphArticle(const Element& head) { DEFINE_STATIC_LOCAL(AtomicString, ogType, ("og:type")); DEFINE_STATIC_LOCAL(AtomicString, propertyAttr, ("property")); for (const Element* child = ElementTraversal::firstChild(head); child; child = ElementTraversal::nextSibling(*child)) { if (!isHTMLMetaElement(*child)) continue; const HTMLMetaElement& meta = toHTMLMetaElement(*child); if (meta.name() == ogType || meta.getAttribute(propertyAttr) == ogType) { if (equalIgnoringCase(meta.content(), "article")) { return true; } } } return false; }