| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
| 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
| 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #ifndef WebSurroundingText_h | 25 #ifndef WebSurroundingText_h |
| 26 #define WebSurroundingText_h | 26 #define WebSurroundingText_h |
| 27 | 27 |
| 28 #include "../platform/WebPrivateOwnPtr.h" | |
| 29 #include "../platform/WebString.h" | 28 #include "../platform/WebString.h" |
| 30 #include "WebNode.h" | 29 #include "WebNode.h" |
| 31 #include "WebRange.h" | 30 #include "WebRange.h" |
| 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 struct WebPoint; | 38 struct WebPoint; |
| 39 | 39 |
| 40 // WebSurroundingText is a Blink API that gives access to the SurroundingText | 40 // 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. | 41 // API. It allows caller to know the text surrounding a point or a range. |
| 42 class WebSurroundingText { | 42 class WebSurroundingText { |
| 43 public: | 43 public: |
| 44 WebSurroundingText() { } | 44 BLINK_EXPORT WebSurroundingText(); |
| 45 ~WebSurroundingText() { reset(); } | 45 BLINK_EXPORT ~WebSurroundingText(); |
| 46 | 46 |
| 47 BLINK_EXPORT bool isNull() const; | 47 BLINK_EXPORT bool isNull() const; |
| 48 BLINK_EXPORT void reset(); | |
| 49 | 48 |
| 50 // Initializes the object to get the surrounding text centered in the | 49 // Initializes the object to get the surrounding text centered in the |
| 51 // position relative to a provided node. | 50 // position relative to a provided node. |
| 52 // The maximum length of the contents retrieved is defined by maxLength. | 51 // The maximum length of the contents retrieved is defined by maxLength. |
| 53 BLINK_EXPORT void initialize(const WebNode&, const WebPoint&, size_t maxLeng
th); | 52 BLINK_EXPORT void initialize(const WebNode&, const WebPoint&, size_t maxLeng
th); |
| 54 | 53 |
| 55 // Initializes the object to get the text surrounding a given range. | 54 // Initializes the object to get the text surrounding a given range. |
| 56 // The maximum length of the contents retrieved is defined by maxLength. | 55 // The maximum length of the contents retrieved is defined by maxLength. |
| 57 // It does not include the text inside the range. | 56 // It does not include the text inside the range. |
| 58 BLINK_EXPORT void initialize(const WebRange&, size_t maxLength); | 57 BLINK_EXPORT void initialize(const WebRange&, size_t maxLength); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 71 BLINK_EXPORT size_t startOffsetInTextContent() const; | 70 BLINK_EXPORT size_t startOffsetInTextContent() const; |
| 72 | 71 |
| 73 // End offset of the initial text in the text content. | 72 // End offset of the initial text in the text content. |
| 74 BLINK_EXPORT size_t endOffsetInTextContent() const; | 73 BLINK_EXPORT size_t endOffsetInTextContent() const; |
| 75 | 74 |
| 76 // Convert start/end positions in the content text string into a WebKit text | 75 // Convert start/end positions in the content text string into a WebKit text |
| 77 // range. | 76 // range. |
| 78 BLINK_EXPORT WebRange rangeFromContentOffsets(size_t startOffsetInContent, s
ize_t endOffsetInContent); | 77 BLINK_EXPORT WebRange rangeFromContentOffsets(size_t startOffsetInContent, s
ize_t endOffsetInContent); |
| 79 | 78 |
| 80 protected: | 79 protected: |
| 81 WebPrivateOwnPtr<SurroundingText> m_private; | 80 std::unique_ptr<SurroundingText> m_private; |
| 82 }; | 81 }; |
| 83 | 82 |
| 84 } // namespace blink | 83 } // namespace blink |
| 85 | 84 |
| 86 #endif | 85 #endif |
| OLD | NEW |