String WebPageSerializerImpl::postActionAfterSerializeOpenTag( const Element* element, SerializeDomParam* param) { StringBuilder result; param->haveAddedContentsBeforeEnd = false; if (!param->isHTMLDocument) return result.toString(); // Check after processing the open tag of HEAD element if (!param->haveAddedCharsetDeclaration && isHTMLHeadElement(*element)) { param->haveAddedCharsetDeclaration = true; // Check meta element. WebKit only pre-parse the first 512 bytes // of the document. If the whole <HEAD> is larger and meta is the // end of head part, then this kind of pages aren't decoded correctly // because of this issue. So when we serialize the DOM, we need to // make sure the meta will in first child of head tag. // See http://bugs.webkit.org/show_bug.cgi?id=16621. // First we generate new content for writing correct META element. result.append(WebPageSerializer::generateMetaCharsetDeclaration( String(param->textEncoding.name()))); param->haveAddedContentsBeforeEnd = true; // Will search each META which has charset declaration, and skip them all // in PreActionBeforeSerializeOpenTag. } else if (isHTMLScriptElement(*element) || isHTMLScriptElement(*element)) { param->isInScriptOrStyleTag = true; } return result.toString(); }
ScriptElement* toScriptElementIfPossible(Element* element) { if (isHTMLScriptElement(element)) return toHTMLScriptElement(element); if (isSVGScriptElement(element)) return toSVGScriptElement(element); return 0; }
String WebPageSerializerImpl::preActionBeforeSerializeEndTag( const Element* element, SerializeDomParam* param, bool* needSkip) { String result; *needSkip = false; if (!param->isHTMLDocument) return result; // Skip the end tag of original META tag which declare charset. // Need not to check whether it's META tag since we guarantee // skipMetaElement is definitely META tag if it's not 0. if (param->skipMetaElement == element) { *needSkip = true; } else if (isHTMLScriptElement(*element) || isHTMLScriptElement(*element)) { ASSERT(param->isInScriptOrStyleTag); param->isInScriptOrStyleTag = false; } return result; }
ScriptElement* toScriptElementIfPossible(Element* element) { if (isHTMLScriptElement(element)) return toHTMLScriptElement(element); #if ENABLE(SVG) if (isSVGScriptElement(element)) return toSVGScriptElement(element); #endif return 0; }
TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) const { if (isHTMLInputElement(*this)) { HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLElement*>(this)); bool hasStrongDirectionality; TextDirection textDirection = determineDirectionality(inputElement->value(), &hasStrongDirectionality); if (strongDirectionalityTextNode) *strongDirectionalityTextNode = hasStrongDirectionality ? inputElement : 0; return textDirection; } Node* node = ComposedTreeTraversal::firstChild(*this); while (node) { // Skip bdi, script, style and text form controls. if (equalIgnoringCase(node->nodeName(), "bdi") || isHTMLScriptElement(*node) || isHTMLStyleElement(*node) || (node->isElementNode() && toElement(node)->isTextFormControl())) { node = ComposedTreeTraversal::nextSkippingChildren(*node, this); continue; } // Skip elements with valid dir attribute if (node->isElementNode()) { AtomicString dirAttributeValue = toElement(node)->fastGetAttribute(dirAttr); if (isValidDirAttribute(dirAttributeValue)) { node = ComposedTreeTraversal::nextSkippingChildren(*node, this); continue; } } if (node->isTextNode()) { bool hasStrongDirectionality; TextDirection textDirection = determineDirectionality(node->textContent(true), &hasStrongDirectionality); if (hasStrongDirectionality) { if (strongDirectionalityTextNode) *strongDirectionalityTextNode = node; return textDirection; } } node = ComposedTreeTraversal::next(*node, this); } if (strongDirectionalityTextNode) *strongDirectionalityTextNode = 0; return LTR; }
bool isHTMLScriptLoader(Element* element) { ASSERT(element); return isHTMLScriptElement(*element); }
bool isHTMLScriptLoader(Element* element) { DCHECK(element); return isHTMLScriptElement(*element); }
static bool shouldUseLengthLimit(const ContainerNode& node) { return !isHTMLScriptElement(node) && !isHTMLStyleElement(node); }