Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1021)

Side by Side Diff: Source/web/WebSurroundingText.cpp

Issue 294073005: Extend WebSurroundingText to accept a WebRange. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | public/web/WebSurroundingText.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | public/web/WebSurroundingText.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698