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

Unified Diff: Source/web/WebSurroundingText.cpp

Issue 294073005: Extend WebSurroundingText to accept a WebRange. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use websurroundingtext Created 6 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 | « no previous file | public/web/WebRange.h » ('j') | public/web/WebRange.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebSurroundingText.cpp
diff --git a/Source/web/WebSurroundingText.cpp b/Source/web/WebSurroundingText.cpp
index 58383dcdf89ddcb3c6455ad813fe0d1384c26c1e..95ebf743d9e53d369205f684d4c786893f727f9f 100644
--- a/Source/web/WebSurroundingText.cpp
+++ b/Source/web/WebSurroundingText.cpp
@@ -48,6 +48,15 @@ void WebSurroundingText::initialize(const WebNode& webNode, const WebPoint& node
m_private.reset(new SurroundingText(VisiblePosition(node->renderer()->positionForPoint(static_cast<IntPoint>(nodePoint))).deepEquivalent().parentAnchoredEquivalent(), maxLength));
}
+void WebSurroundingText::initialize(const WebRange& webRange, size_t maxLength)
+{
+ const Range* range = webRange.constUnwrap<Range>();
tkent 2014/06/13 01:15:37 nit: You can simplify the code like: if (RefPtrWi
mlamouri (slow - plz ping) 2014/06/13 10:34:03 Done.
+ if (!range)
+ return;
+
+ m_private.reset(new SurroundingText(*range, maxLength));
+}
+
WebString WebSurroundingText::textContent() const
{
return m_private->content();
@@ -59,6 +68,16 @@ size_t WebSurroundingText::hitOffsetInTextContent() const
return m_private->startOffsetInContent();
}
+size_t WebSurroundingText::startOffsetInTextContent() const
+{
+ return m_private->startOffsetInContent();
+}
+
+size_t WebSurroundingText::endOffsetInTextContent() const
+{
+ return m_private->endOffsetInContent();
+}
+
WebRange WebSurroundingText::rangeFromContentOffsets(size_t startOffsetInContent, size_t endOffsetInContent)
{
return m_private->rangeFromContentOffsets(startOffsetInContent, endOffsetInContent);
« no previous file with comments | « no previous file | public/web/WebRange.h » ('j') | public/web/WebRange.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698