Diff
Modified: trunk/Source/WebCore/ChangeLog (236582 => 236583)
--- trunk/Source/WebCore/ChangeLog 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/ChangeLog 2018-09-28 04:22:50 UTC (rev 236583)
@@ -1,3 +1,89 @@
+2018-09-26 Ryosuke Niwa <[email protected]>
+
+ Use enum class in createMarkup arguments
+ https://bugs.webkit.org/show_bug.cgi?id=190028
+
+ Reviewed by Wenson Hsieh.
+
+ Replaced enums used by createMarkup with equivalent enum classes: EChildrenOnly with SerializedNodes,
+ EAbsoluteURLs with ResolveURLs, and EFragmentSerialization with SerializationSyntax.
+
+ Also replaced the boolean convertBlocksToInlines with an enum class of the same name.
+
+ Finally, renamed the createMarkup variant which doesn't serialize style and used for innerHTML and XMLSerializer
+ to serializeFragment.
+
+ * dom/Element.cpp:
+ (WebCore::Element::innerHTML const):
+ (WebCore::Element::outerHTML const):
+ * dom/ShadowRoot.cpp:
+ (WebCore::ShadowRoot::innerHTML const):
+ * editing/CompositeEditCommand.cpp:
+ (WebCore::CompositeEditCommand::moveParagraphs):
+ * editing/HTMLInterchange.h:
+ (WebCore::AnnotateForInterchange): Renamed from EAnnotateForInterchange.
+ * editing/MarkupAccumulator.cpp:
+ (WebCore::MarkupAccumulator::MarkupAccumulator):
+ (WebCore::MarkupAccumulator::serializeNodes):
+ (WebCore::MarkupAccumulator::serializeNodesWithNamespaces):
+ (WebCore::MarkupAccumulator::resolveURLIfNeeded const):
+ * editing/MarkupAccumulator.h:
+ (WebCore::MarkupAccumulator::inXMLFragmentSerialization const):
+ * editing/ReplaceRangeWithTextCommand.cpp:
+ (WebCore::ReplaceRangeWithTextCommand::inputEventDataTransfer const):
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::willApplyCommand):
+ * editing/SpellingCorrectionCommand.cpp:
+ (WebCore::SpellingCorrectionCommand::inputEventDataTransfer const):
+ * editing/cocoa/EditorCocoa.mm:
+ (WebCore::Editor::selectionInHTMLFormat):
+ * editing/cocoa/WebContentReaderCocoa.mm:
+ (WebCore::WebContentMarkupReader::readRTFD):
+ (WebCore::WebContentMarkupReader::readRTF):
+ * editing/gtk/EditorGtk.cpp:
+ (WebCore::Editor::writeImageToPasteboard):
+ (WebCore::Editor::writeSelectionToPasteboard):
+ * editing/markup.cpp:
+ (WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator):
+ (WebCore::StyledMarkupAccumulator::serializeNodes):
+ (WebCore::StyledMarkupAccumulator::traverseNodesForSerialization):
+ (WebCore::highestAncestorToWrapMarkup):
+ (WebCore::createMarkupInternal):
+ (WebCore::createMarkup):
+ (WebCore::sanitizedMarkupForFragmentInDocument):
+ (WebCore::serializeFragment): Renamed from createMarkup. This is used for innerHTML and XMLSerializer,
+ which faithfully serializes the fragment without any computed style as inline styles.
+ (WebCore::documentTypeString):
+ (WebCore::createFullMarkup): Deleted two varinats used in WebKitLegacy.
+ * editing/markup.h:
+ (WebCore::ResolveURLs): Renamed from EAbsoluteURLs.
+ (WebCore::ConvertBlocksToInlines): Added.
+ (WebCore::SerializedNodes): Renamed from EChildrenOnly.
+ (WebCore::SerializationSyntax): Renamed from EFragmentSerialization.
+ * editing/wpe/EditorWPE.cpp:
+ (WebCore::Editor::writeSelectionToPasteboard):
+ * inspector/DOMEditor.cpp:
+ * inspector/agents/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::getOuterHTML):
+ * loader/archive/cf/LegacyWebArchive.cpp:
+ (WebCore::LegacyWebArchive::create):
+ (WebCore::LegacyWebArchive::createFromSelection):
+ * page/PageSerializer.cpp:
+ (WebCore::PageSerializer::SerializerMarkupAccumulator::SerializerMarkupAccumulator):
+ (WebCore::PageSerializer::serializeFrame):
+ * page/win/DragControllerWin.cpp:
+ (WebCore::DragController::declareAndWriteDragImage):
+ * Source/WebCore/platform/win/PasteboardWin.cpp:
+ (WebCore::Pasteboard::writeRangeToDataObject):
+ (WebCore::Pasteboard::writeSelection):
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::send):
+ * xml/XMLSerializer.cpp:
+ (WebCore::XMLSerializer::serializeToString):
+ * xml/XSLTProcessorLibxslt.cpp:
+ (WebCore::xsltStylesheetPointer):
+ (WebCore::xmlDocPtrFromNode):
+
2018-09-27 John Wilander <[email protected]>
Resource Load Statistics: Non-redirected top frame navigation should not get captured in statistics
Modified: trunk/Source/WebCore/dom/Element.cpp (236582 => 236583)
--- trunk/Source/WebCore/dom/Element.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/dom/Element.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -2777,12 +2777,12 @@
String Element::innerHTML() const
{
- return createMarkup(*this, ChildrenOnly);
+ return serializeFragment(*this, SerializedNodes::SubtreesOfChildren);
}
String Element::outerHTML() const
{
- return createMarkup(*this);
+ return serializeFragment(*this, SerializedNodes::SubtreeIncludingNode);
}
ExceptionOr<void> Element::setOuterHTML(const String& html)
Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (236582 => 236583)
--- trunk/Source/WebCore/dom/ShadowRoot.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -153,7 +153,7 @@
String ShadowRoot::innerHTML() const
{
- return createMarkup(*this, ChildrenOnly);
+ return serializeFragment(*this, SerializedNodes::SubtreesOfChildren);
}
ExceptionOr<void> ShadowRoot::setInnerHTML(const String& markup)
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (236582 => 236583)
--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -1444,7 +1444,7 @@
RefPtr<DocumentFragment> fragment;
// This used to use a ternary for initialization, but that confused some versions of GCC, see bug 37912
if (startOfParagraphToMove != endOfParagraphToMove)
- fragment = createFragmentFromMarkup(document(), createMarkup(*range, 0, DoNotAnnotateForInterchange, true), emptyString());
+ fragment = createFragmentFromMarkup(document(), createMarkup(*range, nullptr, AnnotateForInterchange::No, ConvertBlocksToInlines::Yes), emptyString());
// A non-empty paragraph's style is moved when we copy and move it. We don't move
// anything if we're given an empty paragraph, but an empty paragraph can have style
Modified: trunk/Source/WebCore/editing/HTMLInterchange.h (236582 => 236583)
--- trunk/Source/WebCore/editing/HTMLInterchange.h 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/HTMLInterchange.h 2018-09-28 04:22:50 UTC (rev 236583)
@@ -38,7 +38,10 @@
#define AppleTabSpanClass "Apple-tab-span"
#define WebKitMSOListQuirksStyle "WebKit-mso-list-quirks-style"
-enum EAnnotateForInterchange { DoNotAnnotateForInterchange, AnnotateForInterchange };
+// Controls whether a special BR which is removed upon paste in ReplaceSelectionCommand needs to be inserted
+// and making sequence of spaces not collapsible by inserting non-breaking spaces.
+// See https://trac.webkit.org/r8087 and https://trac.webkit.org/r8096.
+enum class AnnotateForInterchange : uint8_t { No, Yes };
String convertHTMLTextToInterchangeFormat(const String&, const Text*);
Modified: trunk/Source/WebCore/editing/MarkupAccumulator.cpp (236582 => 236583)
--- trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -116,11 +116,11 @@
appendCharactersReplacingEntitiesInternal<UChar>(result, source, offset, length, entityMask);
}
-MarkupAccumulator::MarkupAccumulator(Vector<Node*>* nodes, EAbsoluteURLs resolveUrlsMethod, const Range* range, EFragmentSerialization fragmentSerialization)
+MarkupAccumulator::MarkupAccumulator(Vector<Node*>* nodes, ResolveURLs resolveURLs, const Range* range, SerializationSyntax serializationSyntax)
: m_nodes(nodes)
, m_range(range)
- , m_resolveURLsMethod(resolveUrlsMethod)
- , m_fragmentSerialization(fragmentSerialization)
+ , m_resolveURLs(resolveURLs)
+ , m_serializationSyntax(serializationSyntax)
, m_prefixLevel(0)
{
}
@@ -127,13 +127,13 @@
MarkupAccumulator::~MarkupAccumulator() = default;
-String MarkupAccumulator::serializeNodes(Node& targetNode, EChildrenOnly childrenOnly, Vector<QualifiedName>* tagNamesToSkip)
+String MarkupAccumulator::serializeNodes(Node& targetNode, SerializedNodes root, Vector<QualifiedName>* tagNamesToSkip)
{
- serializeNodesWithNamespaces(targetNode, childrenOnly, 0, tagNamesToSkip);
+ serializeNodesWithNamespaces(targetNode, root, 0, tagNamesToSkip);
return m_markup.toString();
}
-void MarkupAccumulator::serializeNodesWithNamespaces(Node& targetNode, EChildrenOnly childrenOnly, const Namespaces* namespaces, Vector<QualifiedName>* tagNamesToSkip)
+void MarkupAccumulator::serializeNodesWithNamespaces(Node& targetNode, SerializedNodes root, const Namespaces* namespaces, Vector<QualifiedName>* tagNamesToSkip)
{
if (tagNamesToSkip && is<Element>(targetNode)) {
for (auto& name : *tagNamesToSkip) {
@@ -151,7 +151,7 @@
namespaceHash.set(XMLNames::xmlNamespaceURI->impl(), xmlAtom().impl());
}
- if (!childrenOnly)
+ if (root == SerializedNodes::SubtreeIncludingNode)
appendStartTag(targetNode, &namespaceHash);
if (targetNode.document().isHTMLDocument() && elementCannotHaveEndTag(targetNode))
@@ -159,24 +159,24 @@
Node* current = targetNode.hasTagName(templateTag) ? downcast<HTMLTemplateElement>(targetNode).content().firstChild() : targetNode.firstChild();
for ( ; current; current = current->nextSibling())
- serializeNodesWithNamespaces(*current, IncludeNode, &namespaceHash, tagNamesToSkip);
+ serializeNodesWithNamespaces(*current, SerializedNodes::SubtreeIncludingNode, &namespaceHash, tagNamesToSkip);
- if (!childrenOnly)
+ if (root == SerializedNodes::SubtreeIncludingNode)
appendEndTag(targetNode);
}
String MarkupAccumulator::resolveURLIfNeeded(const Element& element, const String& urlString) const
{
- switch (m_resolveURLsMethod) {
- case ResolveAllURLs:
+ switch (m_resolveURLs) {
+ case ResolveURLs::Yes:
return element.document().completeURL(urlString).string();
- case ResolveNonLocalURLs:
+ case ResolveURLs::YesExcludingLocalFileURLsForPrivacy:
if (!element.document().url().isLocalFile())
return element.document().completeURL(urlString).string();
break;
- case DoNotResolveURLs:
+ case ResolveURLs::No:
break;
}
return urlString;
Modified: trunk/Source/WebCore/editing/MarkupAccumulator.h (236582 => 236583)
--- trunk/Source/WebCore/editing/MarkupAccumulator.h 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.h 2018-09-28 04:22:50 UTC (rev 236583)
@@ -59,10 +59,10 @@
// FIXME: Noncopyable?
class MarkupAccumulator {
public:
- MarkupAccumulator(Vector<Node*>*, EAbsoluteURLs, const Range* = nullptr, EFragmentSerialization = HTMLFragmentSerialization);
+ MarkupAccumulator(Vector<Node*>*, ResolveURLs, const Range* = nullptr, SerializationSyntax = SerializationSyntax::HTML);
virtual ~MarkupAccumulator();
- String serializeNodes(Node& targetNode, EChildrenOnly, Vector<QualifiedName>* tagNamesToSkip = nullptr);
+ String serializeNodes(Node& targetNode, SerializedNodes, Vector<QualifiedName>* tagNamesToSkip = nullptr);
static void appendCharactersReplacingEntities(StringBuilder&, const String&, unsigned, unsigned, EntityMask);
@@ -114,13 +114,13 @@
private:
String resolveURLIfNeeded(const Element&, const String&) const;
void appendQuotedURLAttributeValue(StringBuilder&, const Element&, const Attribute&);
- void serializeNodesWithNamespaces(Node& targetNode, EChildrenOnly, const Namespaces*, Vector<QualifiedName>* tagNamesToSkip);
- bool inXMLFragmentSerialization() const { return m_fragmentSerialization == XMLFragmentSerialization; }
+ void serializeNodesWithNamespaces(Node& targetNode, SerializedNodes, const Namespaces*, Vector<QualifiedName>* tagNamesToSkip);
+ bool inXMLFragmentSerialization() const { return m_serializationSyntax == SerializationSyntax::XML; }
void generateUniquePrefix(QualifiedName&, const Namespaces&);
StringBuilder m_markup;
- const EAbsoluteURLs m_resolveURLsMethod;
- EFragmentSerialization m_fragmentSerialization;
+ const ResolveURLs m_resolveURLs;
+ SerializationSyntax m_serializationSyntax;
unsigned m_prefixLevel;
};
Modified: trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp (236582 => 236583)
--- trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -82,7 +82,7 @@
RefPtr<DataTransfer> ReplaceRangeWithTextCommand::inputEventDataTransfer() const
{
if (!isEditingTextAreaOrTextInput())
- return DataTransfer::createForInputEvent(m_text, createMarkup(*m_textFragment));
+ return DataTransfer::createForInputEvent(m_text, serializeFragment(*m_textFragment, SerializedNodes::SubtreeIncludingNode));
return CompositeEditCommand::inputEventDataTransfer();
}
Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (236582 => 236583)
--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -921,7 +921,7 @@
{
ensureReplacementFragment();
m_documentFragmentPlainText = m_documentFragment->textContent();
- m_documentFragmentHTMLMarkup = createMarkup(*m_documentFragment);
+ m_documentFragmentHTMLMarkup = serializeFragment(*m_documentFragment, SerializedNodes::SubtreeIncludingNode);
return CompositeEditCommand::willApplyCommand();
}
Modified: trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp (236582 => 236583)
--- trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -131,7 +131,7 @@
RefPtr<DataTransfer> SpellingCorrectionCommand::inputEventDataTransfer() const
{
if (!isEditingTextAreaOrTextInput())
- return DataTransfer::createForInputEvent(m_correction, createMarkup(*m_correctionFragment));
+ return DataTransfer::createForInputEvent(m_correction, serializeFragment(*m_correctionFragment, SerializedNodes::SubtreeIncludingNode));
return CompositeEditCommand::inputEventDataTransfer();
}
Modified: trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm (236582 => 236583)
--- trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm 2018-09-28 04:22:50 UTC (rev 236583)
@@ -76,7 +76,7 @@
String Editor::selectionInHTMLFormat()
{
if (auto range = selectedRange())
- return createMarkup(*range, nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
+ return createMarkup(*range, nullptr, AnnotateForInterchange::Yes, ConvertBlocksToInlines::No, ResolveURLs::YesExcludingLocalFileURLsForPrivacy);
return { };
}
Modified: trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (236582 => 236583)
--- trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2018-09-28 04:22:50 UTC (rev 236583)
@@ -629,7 +629,7 @@
if (!fragment)
return false;
- markup = createMarkup(*fragment);
+ markup = serializeFragment(*fragment, SerializedNodes::SubtreeIncludingNode);
return true;
}
@@ -655,7 +655,7 @@
auto fragment = createFragmentAndAddResources(frame, string.get());
if (!fragment)
return false;
- markup = createMarkup(*fragment);
+ markup = serializeFragment(*fragment, SerializedNodes::SubtreeIncludingNode);
return true;
}
Modified: trunk/Source/WebCore/editing/gtk/EditorGtk.cpp (236582 => 236583)
--- trunk/Source/WebCore/editing/gtk/EditorGtk.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/gtk/EditorGtk.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -137,7 +137,7 @@
pasteboardImage.url.url = ""
pasteboardImage.url.title = title;
- pasteboardImage.url.markup = createMarkup(imageElement, IncludeNode, nullptr, ResolveAllURLs);
+ pasteboardImage.url.markup = serializeFragment(imageElement, SerializedNodes::SubtreeIncludingNode, nullptr, ResolveURLs::Yes);
pasteboard.write(pasteboardImage);
}
@@ -146,7 +146,7 @@
PasteboardWebContent pasteboardContent;
pasteboardContent.canSmartCopyOrDelete = canSmartCopyOrDelete();
pasteboardContent.text = selectedTextForDataTransfer();
- pasteboardContent.markup = createMarkup(*selectedRange(), nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
+ pasteboardContent.markup = createMarkup(*selectedRange(), nullptr, AnnotateForInterchange::Yes, ConvertBlocksToInlines::No, ResolveURLs::YesExcludingLocalFileURLsForPrivacy);
pasteboard.write(pasteboardContent);
}
Modified: trunk/Source/WebCore/editing/markup.cpp (236582 => 236583)
--- trunk/Source/WebCore/editing/markup.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/markup.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -219,7 +219,7 @@
public:
enum RangeFullySelectsNode { DoesFullySelectNode, DoesNotFullySelectNode };
- StyledMarkupAccumulator(Vector<Node*>* nodes, EAbsoluteURLs, EAnnotateForInterchange, MSOListMode, const Range*, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized = nullptr);
+ StyledMarkupAccumulator(Vector<Node*>* nodes, ResolveURLs, AnnotateForInterchange, MSOListMode, const Range*, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized = nullptr);
Node* serializeNodes(Node* startNode, Node* pastEnd);
void wrapWithNode(Node&, bool convertBlocksToInlines = false, RangeFullySelectsNode = DoesFullySelectNode);
@@ -249,7 +249,7 @@
appendElement(out, element, false, DoesFullySelectNode);
}
- enum NodeTraversalMode { EmitString, DoNotEmitString };
+ enum class NodeTraversalMode { EmitString, DoNotEmitString };
Node* traverseNodesForSerialization(Node* startNode, Node* pastEnd, NodeTraversalMode);
bool appendNodeToPreserveMSOList(Node&);
@@ -256,7 +256,7 @@
bool shouldAnnotate()
{
- return m_shouldAnnotate == AnnotateForInterchange;
+ return m_annotate == AnnotateForInterchange::Yes;
}
bool shouldApplyWrappingStyle(const Node& node) const
@@ -265,7 +265,7 @@
}
Vector<String> m_reversedPrecedingMarkup;
- const EAnnotateForInterchange m_shouldAnnotate;
+ const AnnotateForInterchange m_annotate;
Node* m_highestNodeToBeSerialized;
RefPtr<EditingStyle> m_wrappingStyle;
bool m_needRelativeStyleWrapper;
@@ -275,9 +275,9 @@
bool m_inMSOList { false };
};
-inline StyledMarkupAccumulator::StyledMarkupAccumulator(Vector<Node*>* nodes, EAbsoluteURLs shouldResolveURLs, EAnnotateForInterchange shouldAnnotate, MSOListMode msoListMode, const Range* range, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized)
- : MarkupAccumulator(nodes, shouldResolveURLs, range)
- , m_shouldAnnotate(shouldAnnotate)
+inline StyledMarkupAccumulator::StyledMarkupAccumulator(Vector<Node*>* nodes, ResolveURLs urlsToResolve, AnnotateForInterchange annotate, MSOListMode msoListMode, const Range* range, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized)
+ : MarkupAccumulator(nodes, urlsToResolve, range)
+ , m_annotate(annotate)
, m_highestNodeToBeSerialized(highestNodeToBeSerialized)
, m_needRelativeStyleWrapper(false)
, m_needsPositionStyleConversion(needsPositionStyleConversion)
@@ -505,7 +505,7 @@
Node* StyledMarkupAccumulator::serializeNodes(Node* startNode, Node* pastEnd)
{
if (!m_highestNodeToBeSerialized) {
- Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, DoNotEmitString);
+ Node* lastClosed = traverseNodesForSerialization(startNode, pastEnd, NodeTraversalMode::DoNotEmitString);
m_highestNodeToBeSerialized = lastClosed;
}
@@ -512,12 +512,12 @@
if (m_highestNodeToBeSerialized && m_highestNodeToBeSerialized->parentNode())
m_wrappingStyle = EditingStyle::wrappingStyleForSerialization(*m_highestNodeToBeSerialized->parentNode(), shouldAnnotate());
- return traverseNodesForSerialization(startNode, pastEnd, EmitString);
+ return traverseNodesForSerialization(startNode, pastEnd, NodeTraversalMode::EmitString);
}
Node* StyledMarkupAccumulator::traverseNodesForSerialization(Node* startNode, Node* pastEnd, NodeTraversalMode traversalMode)
{
- const bool shouldEmit = traversalMode == EmitString;
+ const bool shouldEmit = traversalMode == NodeTraversalMode::EmitString;
Vector<Node*> ancestorsToClose;
Node* next;
Node* lastClosed = nullptr;
@@ -530,7 +530,7 @@
ASSERT(n);
if (!n)
break;
-
+
next = NodeTraversal::next(*n);
bool openedTag = false;
@@ -703,12 +703,12 @@
|| node->hasTagName(iTag) || node->hasTagName(emTag) || node->hasTagName(bTag) || node->hasTagName(strongTag);
}
-static Node* highestAncestorToWrapMarkup(const Range* range, EAnnotateForInterchange shouldAnnotate)
+static Node* highestAncestorToWrapMarkup(const Range* range, AnnotateForInterchange annotate)
{
auto* commonAncestor = range->commonAncestorContainer();
ASSERT(commonAncestor);
Node* specialCommonAncestor = nullptr;
- if (shouldAnnotate == AnnotateForInterchange) {
+ if (annotate == AnnotateForInterchange::Yes) {
// Include ancestors that aren't completely inside the range but are required to retain
// the structure and appearance of the copied markup.
specialCommonAncestor = ancestorToRetainStructureAndAppearance(commonAncestor);
@@ -748,10 +748,10 @@
return specialCommonAncestor;
}
-// FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForInterchange?
+// FIXME: Shouldn't we omit style info when annotate == AnnotateForInterchange::No?
// FIXME: At least, annotation and style info should probably not be included in range.markupString()
static String createMarkupInternal(Document& document, const Range& range, Vector<Node*>* nodes,
- EAnnotateForInterchange shouldAnnotate, bool convertBlocksToInlines, EAbsoluteURLs shouldResolveURLs, MSOListMode msoListMode)
+ AnnotateForInterchange annotate, ConvertBlocksToInlines convertBlocksToInlines, ResolveURLs urlsToResolve, MSOListMode msoListMode)
{
static NeverDestroyed<const String> interchangeNewlineString(MAKE_STATIC_STRING_IMPL("<br class=\"" AppleInterchangeNewline "\">"));
@@ -770,17 +770,17 @@
if (body && VisiblePosition(firstPositionInNode(body)) == VisiblePosition(range.startPosition())
&& VisiblePosition(lastPositionInNode(body)) == VisiblePosition(range.endPosition()))
fullySelectedRoot = body;
- Node* specialCommonAncestor = highestAncestorToWrapMarkup(&range, shouldAnnotate);
+ Node* specialCommonAncestor = highestAncestorToWrapMarkup(&range, annotate);
bool needsPositionStyleConversion = body && fullySelectedRoot == body
&& document.settings().shouldConvertPositionStyleOnCopy();
- StyledMarkupAccumulator accumulator(nodes, shouldResolveURLs, shouldAnnotate, msoListMode, &range, needsPositionStyleConversion, specialCommonAncestor);
+ StyledMarkupAccumulator accumulator(nodes, urlsToResolve, annotate, msoListMode, &range, needsPositionStyleConversion, specialCommonAncestor);
Node* pastEnd = range.pastLastNode();
Node* startNode = range.firstNode();
VisiblePosition visibleStart(range.startPosition(), VP_DEFAULT_AFFINITY);
VisiblePosition visibleEnd(range.endPosition(), VP_DEFAULT_AFFINITY);
- if (shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfter(visibleStart)) {
+ if (annotate == AnnotateForInterchange::Yes && needInterchangeNewlineAfter(visibleStart)) {
if (visibleStart == visibleEnd.previous())
return interchangeNewlineString;
@@ -796,7 +796,7 @@
if (specialCommonAncestor && lastClosed) {
// Also include all of the ancestors of lastClosed up to this special ancestor.
for (ContainerNode* ancestor = lastClosed->parentNode(); ancestor; ancestor = ancestor->parentNode()) {
- if (ancestor == fullySelectedRoot && !convertBlocksToInlines) {
+ if (ancestor == fullySelectedRoot && convertBlocksToInlines == ConvertBlocksToInlines::No) {
RefPtr<EditingStyle> fullySelectedRootStyle = styleFromMatchedRulesAndInlineDecl(*fullySelectedRoot);
// Bring the background attribute over, but not as an attribute because a background attribute on a div
@@ -818,7 +818,7 @@
} else {
// Since this node and all the other ancestors are not in the selection we want to set RangeFullySelectsNode to DoesNotFullySelectNode
// so that styles that affect the exterior of the node are not included.
- accumulator.wrapWithNode(*ancestor, convertBlocksToInlines, StyledMarkupAccumulator::DoesNotFullySelectNode);
+ accumulator.wrapWithNode(*ancestor, convertBlocksToInlines == ConvertBlocksToInlines::Yes, StyledMarkupAccumulator::DoesNotFullySelectNode);
}
if (nodes)
nodes->append(ancestor);
@@ -837,15 +837,15 @@
}
// FIXME: The interchange newline should be placed in the block that it's in, not after all of the content, unconditionally.
- if (shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfter(visibleEnd.previous()))
+ if (annotate == AnnotateForInterchange::Yes && needInterchangeNewlineAfter(visibleEnd.previous()))
accumulator.appendString(interchangeNewlineString);
return accumulator.takeResults();
}
-String createMarkup(const Range& range, Vector<Node*>* nodes, EAnnotateForInterchange shouldAnnotate, bool convertBlocksToInlines, EAbsoluteURLs shouldResolveURLs)
+String createMarkup(const Range& range, Vector<Node*>* nodes, AnnotateForInterchange annotate, ConvertBlocksToInlines convertBlocksToInlines, ResolveURLs urlsToReslve)
{
- return createMarkupInternal(range.ownerDocument(), range, nodes, shouldAnnotate, convertBlocksToInlines, shouldResolveURLs, MSOListMode::DoNotPreserve);
+ return createMarkupInternal(range.ownerDocument(), range, nodes, annotate, convertBlocksToInlines, urlsToReslve, MSOListMode::DoNotPreserve);
}
static bool shouldPreserveMSOLists(const String& markup)
@@ -871,7 +871,7 @@
auto range = Range::create(document);
range->selectNodeContents(*bodyElement);
- auto result = createMarkupInternal(document, range.get(), nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs, msoListMode);
+ auto result = createMarkupInternal(document, range.get(), nullptr, AnnotateForInterchange::Yes, ConvertBlocksToInlines::No, ResolveURLs::YesExcludingLocalFileURLsForPrivacy, msoListMode);
if (msoListMode == MSOListMode::Preserve) {
StringBuilder builder;
@@ -947,10 +947,10 @@
return fragment;
}
-String createMarkup(const Node& node, EChildrenOnly childrenOnly, Vector<Node*>* nodes, EAbsoluteURLs shouldResolveURLs, Vector<QualifiedName>* tagNamesToSkip, EFragmentSerialization fragmentSerialization)
+String serializeFragment(const Node& node, SerializedNodes root, Vector<Node*>* nodes, ResolveURLs urlsToResolve, Vector<QualifiedName>* tagNamesToSkip, SerializationSyntax serializationSyntax)
{
- MarkupAccumulator accumulator(nodes, shouldResolveURLs, 0, fragmentSerialization);
- return accumulator.serializeNodes(const_cast<Node&>(node), childrenOnly, tagNamesToSkip);
+ MarkupAccumulator accumulator(nodes, urlsToResolve, nullptr, serializationSyntax);
+ return accumulator.serializeNodes(const_cast<Node&>(node), root, tagNamesToSkip);
}
static void fillContainerFromString(ContainerNode& paragraph, const String& string)
@@ -1094,27 +1094,9 @@
DocumentType* documentType = document.doctype();
if (!documentType)
return emptyString();
- return createMarkup(*documentType);
+ return serializeFragment(*documentType, SerializedNodes::SubtreeIncludingNode);
}
-String createFullMarkup(const Node& node)
-{
- // FIXME: This is never "for interchange". Is that right?
- String markupString = createMarkup(node, IncludeNode, 0);
-
- Node::NodeType nodeType = node.nodeType();
- if (nodeType != Node::DOCUMENT_NODE && nodeType != Node::DOCUMENT_TYPE_NODE)
- markupString = documentTypeString(node.document()) + markupString;
-
- return markupString;
-}
-
-String createFullMarkup(const Range& range)
-{
- // FIXME: This is always "for interchange". Is that right?
- return documentTypeString(range.startContainer().document()) + createMarkup(range, 0, AnnotateForInterchange);
-}
-
String urlToMarkup(const URL& url, const String& title)
{
StringBuilder markup;
Modified: trunk/Source/WebCore/editing/markup.h (236582 => 236583)
--- trunk/Source/WebCore/editing/markup.h 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/markup.h 2018-09-28 04:22:50 UTC (rev 236583)
@@ -55,10 +55,6 @@
String sanitizeMarkup(const String&, MSOListQuirks = MSOListQuirks::Disabled, std::optional<WTF::Function<void(DocumentFragment&)>> fragmentSanitizer = std::nullopt);
String sanitizedMarkupForFragmentInDocument(Ref<DocumentFragment>&&, Document&, MSOListQuirks, const String& originalMarkup);
-enum EChildrenOnly { IncludeNode, ChildrenOnly };
-enum EAbsoluteURLs { DoNotResolveURLs, ResolveAllURLs, ResolveNonLocalURLs };
-enum EFragmentSerialization { HTMLFragmentSerialization, XMLFragmentSerialization };
-
WEBCORE_EXPORT Ref<DocumentFragment> createFragmentFromText(Range& context, const String& text);
WEBCORE_EXPORT Ref<DocumentFragment> createFragmentFromMarkup(Document&, const String& markup, const String& baseURL, ParserContentPolicy = AllowScriptingContent);
ExceptionOr<Ref<DocumentFragment>> createFragmentForInnerOuterHTML(Element&, const String& markup, ParserContentPolicy);
@@ -71,14 +67,17 @@
// These methods are used by HTMLElement & ShadowRoot to replace the children with respected fragment/text.
ExceptionOr<void> replaceChildrenWithFragment(ContainerNode&, Ref<DocumentFragment>&&);
-String createMarkup(const Range&, Vector<Node*>* = nullptr, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false, EAbsoluteURLs = DoNotResolveURLs);
-String createMarkup(const Node&, EChildrenOnly = IncludeNode, Vector<Node*>* = nullptr, EAbsoluteURLs = DoNotResolveURLs, Vector<QualifiedName>* tagNamesToSkip = nullptr, EFragmentSerialization = HTMLFragmentSerialization);
+enum class ResolveURLs : uint8_t { No, Yes, YesExcludingLocalFileURLsForPrivacy };
+enum class ConvertBlocksToInlines : uint8_t { No, Yes };
+WEBCORE_EXPORT String createMarkup(const Range&, Vector<Node*>* = nullptr, AnnotateForInterchange = AnnotateForInterchange::No, ConvertBlocksToInlines = ConvertBlocksToInlines::No, ResolveURLs = ResolveURLs::No);
-WEBCORE_EXPORT String createFullMarkup(const Node&);
-WEBCORE_EXPORT String createFullMarkup(const Range&);
+enum class SerializedNodes : uint8_t { SubtreeIncludingNode, SubtreesOfChildren };
+enum class SerializationSyntax : uint8_t { HTML, XML };
+WEBCORE_EXPORT String serializeFragment(const Node&, SerializedNodes, Vector<Node*>* = nullptr, ResolveURLs = ResolveURLs::No, Vector<QualifiedName>* tagNamesToSkip = nullptr, SerializationSyntax = SerializationSyntax::HTML);
+WEBCORE_EXPORT String serializeFragmentWithDocType(const Node&);
String urlToMarkup(const URL&, const String& title);
-String documentTypeString(const Document&);
+WEBCORE_EXPORT String documentTypeString(const Document&);
}
Modified: trunk/Source/WebCore/editing/wpe/EditorWPE.cpp (236582 => 236583)
--- trunk/Source/WebCore/editing/wpe/EditorWPE.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/editing/wpe/EditorWPE.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -64,7 +64,7 @@
{
PasteboardWebContent pasteboardContent;
pasteboardContent.text = selectedTextForDataTransfer();
- pasteboardContent.markup = createMarkup(*selectedRange(), nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
+ pasteboardContent.markup = createMarkup(*selectedRange(), nullptr, AnnotateForInterchange::Yes, ConvertBlocksToInlines::No, ResolveURLs::YesExcludingLocalFileURLsForPrivacy);
pasteboard.write(pasteboardContent);
}
Modified: trunk/Source/WebCore/inspector/DOMEditor.cpp (236582 => 236583)
--- trunk/Source/WebCore/inspector/DOMEditor.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/inspector/DOMEditor.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -212,7 +212,7 @@
private:
ExceptionOr<void> perform() final
{
- m_oldHTML = createMarkup(m_node.get());
+ m_oldHTML = serializeFragment(m_node.get(), SerializedNodes::SubtreeIncludingNode);
auto result = DOMPatchSupport { m_domEditor, m_node->document() }.patchNode(m_node, m_html);
if (result.hasException())
return result.releaseException();
Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp (236582 => 236583)
--- trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -766,7 +766,7 @@
if (!node)
return;
- *outerHTML = createMarkup(*node);
+ *outerHTML = serializeFragment(*node, SerializedNodes::SubtreeIncludingNode);
}
void InspectorDOMAgent::setOuterHTML(ErrorString& errorString, int nodeId, const String& outerHTML)
Modified: trunk/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp (236582 => 236583)
--- trunk/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -421,7 +421,7 @@
}
Vector<Node*> nodeList;
- String markupString = createMarkup(node, IncludeNode, &nodeList, DoNotResolveURLs, tagNamesToFilter.get());
+ String markupString = serializeFragment(node, SerializedNodes::SubtreeIncludingNode, &nodeList, ResolveURLs::No, tagNamesToFilter.get());
auto nodeType = node.nodeType();
if (nodeType != Node::DOCUMENT_NODE && nodeType != Node::DOCUMENT_TYPE_NODE)
markupString = documentTypeString(node.document()) + markupString;
@@ -460,7 +460,7 @@
// FIXME: This is always "for interchange". Is that right?
Vector<Node*> nodeList;
- String markupString = documentTypeString(document) + createMarkup(*range, &nodeList, AnnotateForInterchange);
+ String markupString = documentTypeString(document) + createMarkup(*range, &nodeList, AnnotateForInterchange::Yes);
return create(markupString, *frame, nodeList, nullptr);
}
@@ -555,7 +555,7 @@
Vector<Node*> nodeList;
if (auto selectionRange = frame->selection().toNormalizedRange())
- builder.append(createMarkup(*selectionRange, &nodeList, AnnotateForInterchange));
+ builder.append(createMarkup(*selectionRange, &nodeList, AnnotateForInterchange::Yes));
auto archive = create(builder.toString(), *frame, nodeList, nullptr);
Modified: trunk/Source/WebCore/page/PageSerializer.cpp (236582 => 236583)
--- trunk/Source/WebCore/page/PageSerializer.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/page/PageSerializer.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -109,7 +109,7 @@
};
PageSerializer::SerializerMarkupAccumulator::SerializerMarkupAccumulator(PageSerializer& serializer, Document& document, Vector<Node*>* nodes)
- : MarkupAccumulator(nodes, ResolveAllURLs)
+ : MarkupAccumulator(nodes, ResolveURLs::Yes)
, m_serializer(serializer)
, m_document(document)
{
@@ -198,7 +198,7 @@
// FIXME: iframes used as images trigger this. We should deal with them correctly.
return;
}
- String text = accumulator.serializeNodes(*document->documentElement(), IncludeNode);
+ String text = accumulator.serializeNodes(*document->documentElement(), SerializedNodes::SubtreeIncludingNode);
m_resources.append({ url, document->suggestedMIMEType(), SharedBuffer::create(textEncoding.encode(text, UnencodableHandling::Entities)) });
m_resourceURLs.add(url);
Modified: trunk/Source/WebCore/page/win/DragControllerWin.cpp (236582 => 236583)
--- trunk/Source/WebCore/page/win/DragControllerWin.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/page/win/DragControllerWin.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -78,7 +78,7 @@
// Order is important here for Explorer's sake
pasteboard.writeURLToWritableDataObject(url, label);
pasteboard.writeImageToDataObject(element, url);
- pasteboard.writeMarkup(createMarkup(element, IncludeNode, 0, ResolveAllURLs));
+ pasteboard.writeMarkup(serializeFragment(element, SerializedNodes::SubtreeIncludingNode, nullptr, ResolveURLs::Yes));
}
}
Modified: trunk/Source/WebCore/platform/win/PasteboardWin.cpp (236582 => 236583)
--- trunk/Source/WebCore/platform/win/PasteboardWin.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/platform/win/PasteboardWin.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -444,7 +444,7 @@
medium.tymed = TYMED_HGLOBAL;
Vector<char> data;
- markupToCFHTML(createMarkup(selectedRange, 0, AnnotateForInterchange),
+ markupToCFHTML(createMarkup(selectedRange, nullptr, AnnotateForInterchange::Yes),
selectedRange.startContainer().document().url().string(), data);
medium.hGlobal = createGlobalData(data);
if (medium.hGlobal && FAILED(m_writableDataObject->SetData(htmlFormat(), &medium, TRUE)))
@@ -469,7 +469,7 @@
// Put CF_HTML format on the pasteboard
if (::OpenClipboard(m_owner)) {
Vector<char> data;
- markupToCFHTML(createMarkup(selectedRange, 0, AnnotateForInterchange),
+ markupToCFHTML(createMarkup(selectedRange, nullptr, AnnotateForInterchange::Yes),
selectedRange.startContainer().document().url().string(), data);
HGLOBAL cbData = createGlobalData(data);
if (!::SetClipboardData(HTMLClipboardFormat, cbData))
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (236582 => 236583)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -469,7 +469,7 @@
// FIXME: According to XMLHttpRequest Level 2, this should use the Document.innerHTML algorithm
// from the HTML5 specification to serialize the document.
- m_requestEntityBody = FormData::create(UTF8Encoding().encode(createMarkup(document), UnencodableHandling::Entities));
+ m_requestEntityBody = FormData::create(UTF8Encoding().encode(serializeFragment(document, SerializedNodes::SubtreeIncludingNode), UnencodableHandling::Entities));
if (m_upload)
m_requestEntityBody->setAlwaysStream(true);
}
Modified: trunk/Source/WebCore/xml/XMLSerializer.cpp (236582 => 236583)
--- trunk/Source/WebCore/xml/XMLSerializer.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/xml/XMLSerializer.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -26,7 +26,7 @@
String XMLSerializer::serializeToString(Node& node)
{
- return createMarkup(node, IncludeNode, nullptr, DoNotResolveURLs, nullptr, XMLFragmentSerialization);
+ return serializeFragment(node, SerializedNodes::SubtreeIncludingNode, nullptr, ResolveURLs::No, nullptr, SerializationSyntax::XML);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/xml/XSLTProcessorLibxslt.cpp (236582 => 236583)
--- trunk/Source/WebCore/xml/XSLTProcessorLibxslt.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebCore/xml/XSLTProcessorLibxslt.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -244,7 +244,7 @@
// According to Mozilla documentation, the node must be a Document node, an xsl:stylesheet or xsl:transform element.
// But we just use text content regardless of node type.
- cachedStylesheet->parseString(createMarkup(*stylesheetRootNode));
+ cachedStylesheet->parseString(serializeFragment(*stylesheetRootNode, SerializedNodes::SubtreeIncludingNode));
}
if (!cachedStylesheet || !cachedStylesheet->document())
@@ -262,7 +262,7 @@
if (sourceIsDocument && ownerDocument->transformSource())
sourceDoc = ownerDocument->transformSource()->platformSource();
if (!sourceDoc) {
- sourceDoc = xmlDocPtrForString(ownerDocument->cachedResourceLoader(), createMarkup(sourceNode),
+ sourceDoc = xmlDocPtrForString(ownerDocument->cachedResourceLoader(), serializeFragment(sourceNode, SerializedNodes::SubtreeIncludingNode),
sourceIsDocument ? ownerDocument->url().string() : String());
shouldDelete = sourceDoc;
}
Modified: trunk/Source/WebKit/ChangeLog (236582 => 236583)
--- trunk/Source/WebKit/ChangeLog 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebKit/ChangeLog 2018-09-28 04:22:50 UTC (rev 236583)
@@ -1,3 +1,13 @@
+2018-09-26 Ryosuke Niwa <[email protected]>
+
+ Use enum class in createMarkup arguments
+ https://bugs.webkit.org/show_bug.cgi?id=190028
+
+ Reviewed by Wenson Hsieh.
+
+ * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
+ (WebKit::WebEditorClient::updateGlobalSelection):
+
2018-09-27 John Wilander <[email protected]>
Resource Load Statistics: Non-redirected top frame navigation should not get captured in statistics
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp (236582 => 236583)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp 2018-09-28 04:22:50 UTC (rev 236583)
@@ -126,7 +126,7 @@
PasteboardWebContent pasteboardContent;
pasteboardContent.canSmartCopyOrDelete = false;
pasteboardContent.text = range->text();
- pasteboardContent.markup = createMarkup(*range, nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
+ pasteboardContent.markup = createMarkup(*range, nullptr, AnnotateForInterchange::Yes, ConvertBlocksToInlines::No, ResolveURLs::YesExcludingLocalFileURLsForPrivacy);
Pasteboard::createForGlobalSelection()->write(pasteboardContent);
}
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (236582 => 236583)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2018-09-28 04:22:50 UTC (rev 236583)
@@ -1,3 +1,14 @@
+2018-09-26 Ryosuke Niwa <[email protected]>
+
+ Use enum class in createMarkup arguments
+ https://bugs.webkit.org/show_bug.cgi?id=190028
+
+ Reviewed by Wenson Hsieh.
+
+ * DOM/WebDOMOperations.mm:
+ (-[DOMNode markupString]): Moved the code from WebCore/editing/markup.cpp
+ (-[DOMRange markupString]): Ditto.
+
2018-09-27 Antoine Quint <[email protected]>
[Web Animations] Turn Web Animations with CSS integration on
Modified: trunk/Source/WebKitLegacy/mac/DOM/WebDOMOperations.mm (236582 => 236583)
--- trunk/Source/WebKitLegacy/mac/DOM/WebDOMOperations.mm 2018-09-28 03:22:04 UTC (rev 236582)
+++ trunk/Source/WebKitLegacy/mac/DOM/WebDOMOperations.mm 2018-09-28 04:22:50 UTC (rev 236583)
@@ -137,7 +137,14 @@
- (NSString *)markupString
{
- return createFullMarkup(*core(self));
+ auto& node = *core(self);
+
+ String markupString = serializeFragment(node, SerializedNodes::SubtreeIncludingNode);
+ Node::NodeType nodeType = node.nodeType();
+ if (nodeType != Node::DOCUMENT_NODE && nodeType != Node::DOCUMENT_TYPE_NODE)
+ markupString = documentTypeString(node.document()) + markupString;
+
+ return markupString;
}
- (NSRect)_renderRect:(bool *)isReplaced
@@ -187,7 +194,8 @@
- (NSString *)markupString
{
- return createFullMarkup(*core(self));
+ auto& range = *core(self);
+ return String { documentTypeString(range.startContainer().document()) + createMarkup(range, nullptr, AnnotateForInterchange::Yes) };
}
@end