Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(797)

Unified Diff: Source/core/editing/markup.cpp

Issue 1187273003: Introduce createMarkup function takes two positions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-06-18T09:58:34 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/markup.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/markup.cpp
diff --git a/Source/core/editing/markup.cpp b/Source/core/editing/markup.cpp
index 505ecad6725a34c1cf7738181d4dbce1b3888e99..9ef7d6b635a91d1502fe5be4377f510decbd9aad 100644
--- a/Source/core/editing/markup.cpp
+++ b/Source/core/editing/markup.cpp
@@ -184,9 +184,10 @@ template<typename PositionType>
static bool areSameRanges(Node* node, const PositionType& startPosition, const PositionType& endPosition)
{
ASSERT(node);
- Position otherStartPosition;
- Position otherEndPosition;
- VisibleSelection::selectionFromContentsOfNode(node).toNormalizedPositions(otherStartPosition, otherEndPosition);
+
+ PositionType otherStartPosition;
+ PositionType otherEndPosition;
+ VisibleSelection::normalizePositions(PositionType::firstPositionInNode(node), PositionType::lastPositionInNode(node), &otherStartPosition, &otherEndPosition);
return startPosition == otherStartPosition && endPosition == otherEndPosition;
}
@@ -239,6 +240,14 @@ static HTMLElement* highestAncestorToWrapMarkup(const typename Strategy::Positio
return specialCommonAncestor;
}
+template <typename Strategy>
+class CreateMarkupAlgorithm {
+public:
+ using PositionType = typename Strategy::PositionType;
+
+ static String createMarkup(const PositionType& startPosition, const PositionType& endPosition, EAnnotateForInterchange shouldAnnotate = DoNotAnnotateForInterchange, ConvertBlocksToInlines = ConvertBlocksToInlines::NotConvert, EAbsoluteURLs shouldResolveURLs = DoNotResolveURLs, Node* constrainingAncestor = nullptr);
+};
+
// FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForInterchange?
// FIXME: At least, annotation and style info should probably not be included in range.markupString()
template <typename Strategy>
@@ -272,6 +281,12 @@ String createMarkup(const Range* range, EAnnotateForInterchange shouldAnnotate,
return CreateMarkupAlgorithm<EditingStrategy>::createMarkup(range->startPosition(), range->endPosition(), shouldAnnotate, convertBlocksToInlines, shouldResolveURLs, constrainingAncestor);
}
+String createMarkup(const Position& startPosition, const Position& endPosition, EAnnotateForInterchange shouldAnnotate, ConvertBlocksToInlines convertBlocksToInlines, EAbsoluteURLs shouldResolveURLs, Node* constrainingAncestor)
+{
+ ASSERT(startPosition.compareTo(endPosition) <= 0);
+ return CreateMarkupAlgorithm<EditingStrategy>::createMarkup(startPosition, endPosition, shouldAnnotate, convertBlocksToInlines, shouldResolveURLs, constrainingAncestor);
+}
+
PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkup(Document& document, const String& markup, const String& baseURL, ParserContentPolicy parserContentPolicy)
{
// We use a fake body element here to trick the HTML parser to using the InBody insertion mode.
« no previous file with comments | « Source/core/editing/markup.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698