RawPtr<EditingStyle> StyledMarkupTraverser<Strategy>::createInlineStyleIfNeeded(Node& node) { if (!m_accumulator) return nullptr; if (!node.isElementNode()) return nullptr; RawPtr<EditingStyle> inlineStyle = createInlineStyle(toElement(node)); if (convertBlocksToInlines() && isEnclosingBlock(&node)) inlineStyle->forceInline(); return inlineStyle; }
void StyledMarkupTraverser<Strategy>::appendStartMarkup(Node& node) { if (!m_accumulator) return; switch (node.getNodeType()) { case Node::TEXT_NODE: { Text& text = toText(node); if (text.parentElement() && isHTMLTextAreaElement(text.parentElement())) { m_accumulator->appendText(text); break; } RawPtr<EditingStyle> inlineStyle = nullptr; if (shouldApplyWrappingStyle(text)) { inlineStyle = m_wrappingStyle->copy(); // FIXME: <rdar://problem/5371536> Style rules that match pasted content can change it's appearance // Make sure spans are inline style in paste side e.g. span { display: block }. inlineStyle->forceInline(); // FIXME: Should this be included in forceInline? inlineStyle->style()->setProperty(CSSPropertyFloat, CSSValueNone); } m_accumulator->appendTextWithInlineStyle(text, inlineStyle); break; } case Node::ELEMENT_NODE: { Element& element = toElement(node); if ((element.isHTMLElement() && shouldAnnotate()) || shouldApplyWrappingStyle(element)) { RawPtr<EditingStyle> inlineStyle = createInlineStyle(element); m_accumulator->appendElementWithInlineStyle(element, inlineStyle); break; } m_accumulator->appendElement(element); break; } default: m_accumulator->appendStartMarkup(node); break; } }