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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 void WebSurroundingText::initialize(const WebNode& webNode, const WebPoint& node
Point, size_t maxLength) | 42 void WebSurroundingText::initialize(const WebNode& webNode, const WebPoint& node
Point, size_t maxLength) |
43 { | 43 { |
44 const Node* node = webNode.constUnwrap<Node>(); | 44 const Node* node = webNode.constUnwrap<Node>(); |
45 if (!node || !node->renderer()) | 45 if (!node || !node->renderer()) |
46 return; | 46 return; |
47 | 47 |
48 m_private.reset(new SurroundingText(VisiblePosition(node->renderer()->positi
onForPoint(static_cast<IntPoint>(nodePoint))).deepEquivalent().parentAnchoredEqu
ivalent(), maxLength)); | 48 m_private.reset(new SurroundingText(VisiblePosition(node->renderer()->positi
onForPoint(static_cast<IntPoint>(nodePoint))).deepEquivalent().parentAnchoredEqu
ivalent(), maxLength)); |
49 } | 49 } |
50 | 50 |
| 51 void WebSurroundingText::initialize(const WebRange& webRange, size_t maxLength) |
| 52 { |
| 53 if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Ran
ge> >(webRange)) |
| 54 m_private.reset(new SurroundingText(*range, maxLength)); |
| 55 } |
| 56 |
51 WebString WebSurroundingText::textContent() const | 57 WebString WebSurroundingText::textContent() const |
52 { | 58 { |
53 return m_private->content(); | 59 return m_private->content(); |
54 } | 60 } |
55 | 61 |
56 size_t WebSurroundingText::hitOffsetInTextContent() const | 62 size_t WebSurroundingText::hitOffsetInTextContent() const |
57 { | 63 { |
58 ASSERT(m_private->startOffsetInContent() == m_private->endOffsetInContent())
; | 64 ASSERT(m_private->startOffsetInContent() == m_private->endOffsetInContent())
; |
59 return m_private->startOffsetInContent(); | 65 return m_private->startOffsetInContent(); |
60 } | 66 } |
61 | 67 |
| 68 size_t WebSurroundingText::startOffsetInTextContent() const |
| 69 { |
| 70 return m_private->startOffsetInContent(); |
| 71 } |
| 72 |
| 73 size_t WebSurroundingText::endOffsetInTextContent() const |
| 74 { |
| 75 return m_private->endOffsetInContent(); |
| 76 } |
| 77 |
62 WebRange WebSurroundingText::rangeFromContentOffsets(size_t startOffsetInContent
, size_t endOffsetInContent) | 78 WebRange WebSurroundingText::rangeFromContentOffsets(size_t startOffsetInContent
, size_t endOffsetInContent) |
63 { | 79 { |
64 return m_private->rangeFromContentOffsets(startOffsetInContent, endOffsetInC
ontent); | 80 return m_private->rangeFromContentOffsets(startOffsetInContent, endOffsetInC
ontent); |
65 } | 81 } |
66 | 82 |
67 bool WebSurroundingText::isNull() const | 83 bool WebSurroundingText::isNull() const |
68 { | 84 { |
69 return !m_private.get(); | 85 return !m_private.get(); |
70 } | 86 } |
71 | 87 |
72 void WebSurroundingText::reset() | 88 void WebSurroundingText::reset() |
73 { | 89 { |
74 m_private.reset(0); | 90 m_private.reset(0); |
75 } | 91 } |
76 | 92 |
77 } // namespace blink | 93 } // namespace blink |
OLD | NEW |