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

Unified Diff: public/web/WebSurroundingText.h

Issue 294073005: Extend WebSurroundingText to accept a WebRange. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review comments 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 | « Source/web/WebSurroundingText.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: public/web/WebSurroundingText.h
diff --git a/public/web/WebSurroundingText.h b/public/web/WebSurroundingText.h
index aa6e268faa55b6a637c2972d5f3bd50b081054b1..b5abbc834620bc1be8f93886c81edfee707e1a2b 100644
--- a/public/web/WebSurroundingText.h
+++ b/public/web/WebSurroundingText.h
@@ -38,8 +38,11 @@ namespace blink {
class WebHitTestResult;
class WebNode;
+class WebRange;
struct WebPoint;
+// WebSurroundingText is a Blink API that gives access to the SurroundingText
+// API. It allows caller to know the text surrounding a point or a range.
class WebSurroundingText {
public:
WebSurroundingText() { }
@@ -48,17 +51,34 @@ public:
BLINK_EXPORT bool isNull() const;
BLINK_EXPORT void reset();
- // Initializes the object to get the surrounding text centered in the position relative to a provided node.
+ // Initializes the object to get the surrounding text centered in the
+ // position relative to a provided node.
// The maximum length of the contents retrieved is defined by maxLength.
BLINK_EXPORT void initialize(const WebNode&, const WebPoint&, size_t maxLength);
+ // Initializes the object to get the text surrounding a given range.
+ // The maximum length of the contents retrieved is defined by maxLength.
+ // It does not include the text inside the range.
+ BLINK_EXPORT void initialize(const WebRange&, size_t maxLength);
+
// Surrounding text content retrieved.
BLINK_EXPORT WebString textContent() const;
- // Offset in the text content of the initial hit position (or provided offset in the node).
+ // Offset in the text content of the initial hit position (or provided
+ // offset in the node).
+ // This should only be called when WebSurroundingText has been initialized
+ // with a WebPoint.
+ // DEPRECATED: use startOffsetInTextContent() or endOffsetInTextContent().
BLINK_EXPORT size_t hitOffsetInTextContent() const;
- // Convert start/end positions in the content text string into a WebKit text range.
+ // Start offset of the initial text in the text content.
+ BLINK_EXPORT size_t startOffsetInTextContent() const;
+
+ // End offset of the initial text in the text content.
+ BLINK_EXPORT size_t endOffsetInTextContent() const;
+
+ // Convert start/end positions in the content text string into a WebKit text
+ // range.
BLINK_EXPORT WebRange rangeFromContentOffsets(size_t startOffsetInContent, size_t endOffsetInContent);
protected:
« no previous file with comments | « Source/web/WebSurroundingText.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698