| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "../platform/WebString.h" | 28 #include "../platform/WebString.h" |
| 29 #include "WebNode.h" | 29 #include "WebNode.h" |
| 30 #include "WebRange.h" | 30 #include "WebRange.h" |
| 31 #include <memory> | 31 #include <memory> |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 class SurroundingText; | 35 class SurroundingText; |
| 36 class WebNode; | 36 class WebNode; |
| 37 class WebRange; | 37 class WebRange; |
| 38 class WebLocalFrame; |
| 38 struct WebPoint; | 39 struct WebPoint; |
| 39 | 40 |
| 40 // WebSurroundingText is a Blink API that gives access to the SurroundingText | 41 // WebSurroundingText is a Blink API that gives access to the SurroundingText |
| 41 // API. It allows caller to know the text surrounding a point or a range. | 42 // API. It allows caller to know the text surrounding a point or a range. |
| 42 class WebSurroundingText { | 43 class WebSurroundingText { |
| 43 public: | 44 public: |
| 44 BLINK_EXPORT WebSurroundingText(); | 45 BLINK_EXPORT WebSurroundingText(); |
| 45 BLINK_EXPORT ~WebSurroundingText(); | 46 BLINK_EXPORT ~WebSurroundingText(); |
| 46 | 47 |
| 47 BLINK_EXPORT bool isNull() const; | 48 BLINK_EXPORT bool isNull() const; |
| 48 | 49 |
| 49 // Initializes the object to get the surrounding text centered in the | 50 // Initializes the object to get the surrounding text centered in the |
| 50 // position relative to a provided node. | 51 // position relative to a provided node. |
| 51 // The maximum length of the contents retrieved is defined by maxLength. | 52 // The maximum length of the contents retrieved is defined by maxLength. |
| 52 BLINK_EXPORT void initialize(const WebNode&, const WebPoint&, size_t maxLeng
th); | 53 BLINK_EXPORT void initialize(const WebNode&, const WebPoint&, size_t maxLeng
th); |
| 53 | 54 // Initializes the object with the current selection in a given frame. |
| 54 // Initializes the object to get the text surrounding a given range. | |
| 55 // The maximum length of the contents retrieved is defined by maxLength. | 55 // The maximum length of the contents retrieved is defined by maxLength. |
| 56 // It does not include the text inside the range. | 56 // It does not include the text inside the range. |
| 57 BLINK_EXPORT void initialize(const WebRange&, size_t maxLength); | 57 BLINK_EXPORT void initializeFromCurrentSelection(WebLocalFrame*, size_t maxL
ength); |
| 58 | 58 |
| 59 // Surrounding text content retrieved. | 59 // Surrounding text content retrieved. |
| 60 BLINK_EXPORT WebString textContent() const; | 60 BLINK_EXPORT WebString textContent() const; |
| 61 | 61 |
| 62 // Offset in the text content of the initial hit position (or provided | 62 // Offset in the text content of the initial hit position (or provided |
| 63 // offset in the node). | 63 // offset in the node). |
| 64 // This should only be called when WebSurroundingText has been initialized | 64 // This should only be called when WebSurroundingText has been initialized |
| 65 // with a WebPoint. | 65 // with a WebPoint. |
| 66 // DEPRECATED: use startOffsetInTextContent() or endOffsetInTextContent(). | 66 // DEPRECATED: use startOffsetInTextContent() or endOffsetInTextContent(). |
| 67 BLINK_EXPORT size_t hitOffsetInTextContent() const; | 67 BLINK_EXPORT size_t hitOffsetInTextContent() const; |
| 68 | 68 |
| 69 // Start offset of the initial text in the text content. | 69 // Start offset of the initial text in the text content. |
| 70 BLINK_EXPORT size_t startOffsetInTextContent() const; | 70 BLINK_EXPORT size_t startOffsetInTextContent() const; |
| 71 | 71 |
| 72 // End offset of the initial text in the text content. | 72 // End offset of the initial text in the text content. |
| 73 BLINK_EXPORT size_t endOffsetInTextContent() const; | 73 BLINK_EXPORT size_t endOffsetInTextContent() const; |
| 74 | 74 |
| 75 protected: | 75 protected: |
| 76 std::unique_ptr<SurroundingText> m_private; | 76 std::unique_ptr<SurroundingText> m_private; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 } // namespace blink | 79 } // namespace blink |
| 80 | 80 |
| 81 #endif | 81 #endif |
| OLD | NEW |