| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebRange_h | 31 #ifndef WebRange_h |
| 32 #define WebRange_h | 32 #define WebRange_h |
| 33 | 33 |
| 34 #include "WebFrame.h" | |
| 35 #include "public/platform/WebCommon.h" | 34 #include "public/platform/WebCommon.h" |
| 36 #include "public/platform/WebPrivatePtr.h" | |
| 37 #include "public/platform/WebVector.h" | |
| 38 | 35 |
| 39 namespace blink { | 36 namespace blink { |
| 40 | 37 |
| 41 class Range; | 38 class Range; |
| 42 class WebString; | 39 class WebString; |
| 40 class LocalFrame; |
| 43 | 41 |
| 44 // Provides readonly access to some properties of a DOM range. | 42 class WebRange final { |
| 45 class WebRange { | |
| 46 public: | 43 public: |
| 47 ~WebRange() { reset(); } | 44 BLINK_EXPORT WebRange(int start, int length); |
| 48 | 45 |
| 49 WebRange() { } | 46 int startOffset() const { return m_start; } |
| 50 WebRange(const WebRange& r) { assign(r); } | 47 int endOffset() const { return m_end; } |
| 51 WebRange& operator=(const WebRange& r) | 48 int length() const { return m_end - m_start; } |
| 52 { | |
| 53 assign(r); | |
| 54 return *this; | |
| 55 } | |
| 56 | 49 |
| 57 BLINK_EXPORT void reset(); | 50 bool isNull() const { return m_start == -1 && m_end == -1; } |
| 58 BLINK_EXPORT void assign(const WebRange&); | |
| 59 | |
| 60 bool isNull() const { return m_private.isNull(); } | |
| 61 | |
| 62 BLINK_EXPORT int startOffset() const; | |
| 63 BLINK_EXPORT int endOffset() const; | |
| 64 BLINK_EXPORT WebString toPlainText() const; | |
| 65 | |
| 66 BLINK_EXPORT static WebRange fromDocumentRange(WebLocalFrame*, int start, in
t length); | |
| 67 | 51 |
| 68 #if BLINK_IMPLEMENTATION | 52 #if BLINK_IMPLEMENTATION |
| 69 WebRange(Range*); | 53 WebRange(Range*); |
| 70 operator Range*() const; | 54 |
| 55 Range* createRange(LocalFrame*) const; |
| 71 #endif | 56 #endif |
| 72 | 57 |
| 73 private: | 58 private: |
| 74 WebPrivatePtr<Range> m_private; | 59 int m_start = -1; |
| 60 int m_end = -1; |
| 75 }; | 61 }; |
| 76 | 62 |
| 77 } // namespace blink | 63 } // namespace blink |
| 78 | 64 |
| 79 #endif | 65 #endif |
| OLD | NEW |