| 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 10 matching lines...) Expand all Loading... |
| 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 #include "public/web/WebSurroundingText.h" | 25 #include "public/web/WebSurroundingText.h" |
| 26 | 26 |
| 27 #include "core/dom/Element.h" | 27 #include "core/dom/Element.h" |
| 28 #include "core/dom/Node.h" | 28 #include "core/dom/Node.h" |
| 29 #include "core/dom/Range.h" | 29 #include "core/dom/Range.h" |
| 30 #include "core/dom/Text.h" | 30 #include "core/dom/Text.h" |
| 31 #include "core/editing/FrameSelection.h" |
| 31 #include "core/editing/SurroundingText.h" | 32 #include "core/editing/SurroundingText.h" |
| 32 #include "core/editing/VisiblePosition.h" | 33 #include "core/editing/VisiblePosition.h" |
| 33 #include "core/layout/LayoutObject.h" | 34 #include "core/layout/LayoutObject.h" |
| 34 #include "public/platform/WebPoint.h" | 35 #include "public/platform/WebPoint.h" |
| 35 #include "public/web/WebHitTestResult.h" | 36 #include "public/web/WebHitTestResult.h" |
| 37 #include "web/WebLocalFrameImpl.h" |
| 36 | 38 |
| 37 namespace blink { | 39 namespace blink { |
| 38 | 40 |
| 39 WebSurroundingText::WebSurroundingText() | 41 WebSurroundingText::WebSurroundingText() |
| 40 { | 42 { |
| 41 } | 43 } |
| 42 | 44 |
| 43 WebSurroundingText::~WebSurroundingText() | 45 WebSurroundingText::~WebSurroundingText() |
| 44 { | 46 { |
| 45 } | 47 } |
| 46 | 48 |
| 47 void WebSurroundingText::initialize(const WebNode& webNode, const WebPoint& node
Point, size_t maxLength) | 49 void WebSurroundingText::initialize(const WebNode& webNode, const WebPoint& node
Point, size_t maxLength) |
| 48 { | 50 { |
| 49 const Node* node = webNode.constUnwrap<Node>(); | 51 const Node* node = webNode.constUnwrap<Node>(); |
| 50 if (!node || !node->layoutObject()) | 52 if (!node || !node->layoutObject()) |
| 51 return; | 53 return; |
| 52 | 54 |
| 53 m_private.reset(new SurroundingText(createVisiblePosition(node->layoutObject
()->positionForPoint(static_cast<IntPoint>(nodePoint))).deepEquivalent().parentA
nchoredEquivalent(), maxLength)); | 55 m_private.reset(new SurroundingText(createVisiblePosition(node->layoutObject
()->positionForPoint(static_cast<IntPoint>(nodePoint))).deepEquivalent().parentA
nchoredEquivalent(), maxLength)); |
| 54 } | 56 } |
| 55 | 57 |
| 56 void WebSurroundingText::initialize(const WebRange& webRange, size_t maxLength) | 58 void WebSurroundingText::initializeFromCurrentSelection(WebLocalFrame* frame, si
ze_t maxLength) |
| 57 { | 59 { |
| 58 if (Range* range = static_cast<Range*>(webRange)) | 60 LocalFrame* webFrame = toWebLocalFrameImpl(frame)->frame(); |
| 61 if (Range* range = createRange(webFrame->selection().selection().toNormalize
dEphemeralRange())) |
| 59 m_private.reset(new SurroundingText(*range, maxLength)); | 62 m_private.reset(new SurroundingText(*range, maxLength)); |
| 60 } | 63 } |
| 61 | 64 |
| 62 WebString WebSurroundingText::textContent() const | 65 WebString WebSurroundingText::textContent() const |
| 63 { | 66 { |
| 64 return m_private->content(); | 67 return m_private->content(); |
| 65 } | 68 } |
| 66 | 69 |
| 67 size_t WebSurroundingText::hitOffsetInTextContent() const | 70 size_t WebSurroundingText::hitOffsetInTextContent() const |
| 68 { | 71 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 79 { | 82 { |
| 80 return m_private->endOffsetInContent(); | 83 return m_private->endOffsetInContent(); |
| 81 } | 84 } |
| 82 | 85 |
| 83 bool WebSurroundingText::isNull() const | 86 bool WebSurroundingText::isNull() const |
| 84 { | 87 { |
| 85 return !m_private.get(); | 88 return !m_private.get(); |
| 86 } | 89 } |
| 87 | 90 |
| 88 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |