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

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: use websurroundingtext 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/WebRange.h » ('j') | public/web/WebRange.h » ('J')
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 const Range* range = webRange.constUnwrap<Range>();
tkent 2014/06/13 01:15:37 nit: You can simplify the code like: if (RefPtrWi
mlamouri (slow - plz ping) 2014/06/13 10:34:03 Done.
54 if (!range)
55 return;
56
57 m_private.reset(new SurroundingText(*range, maxLength));
58 }
59
51 WebString WebSurroundingText::textContent() const 60 WebString WebSurroundingText::textContent() const
52 { 61 {
53 return m_private->content(); 62 return m_private->content();
54 } 63 }
55 64
56 size_t WebSurroundingText::hitOffsetInTextContent() const 65 size_t WebSurroundingText::hitOffsetInTextContent() const
57 { 66 {
58 ASSERT(m_private->startOffsetInContent() == m_private->endOffsetInContent()) ; 67 ASSERT(m_private->startOffsetInContent() == m_private->endOffsetInContent()) ;
59 return m_private->startOffsetInContent(); 68 return m_private->startOffsetInContent();
60 } 69 }
61 70
71 size_t WebSurroundingText::startOffsetInTextContent() const
72 {
73 return m_private->startOffsetInContent();
74 }
75
76 size_t WebSurroundingText::endOffsetInTextContent() const
77 {
78 return m_private->endOffsetInContent();
79 }
80
62 WebRange WebSurroundingText::rangeFromContentOffsets(size_t startOffsetInContent , size_t endOffsetInContent) 81 WebRange WebSurroundingText::rangeFromContentOffsets(size_t startOffsetInContent , size_t endOffsetInContent)
63 { 82 {
64 return m_private->rangeFromContentOffsets(startOffsetInContent, endOffsetInC ontent); 83 return m_private->rangeFromContentOffsets(startOffsetInContent, endOffsetInC ontent);
65 } 84 }
66 85
67 bool WebSurroundingText::isNull() const 86 bool WebSurroundingText::isNull() const
68 { 87 {
69 return !m_private.get(); 88 return !m_private.get();
70 } 89 }
71 90
72 void WebSurroundingText::reset() 91 void WebSurroundingText::reset()
73 { 92 {
74 m_private.reset(0); 93 m_private.reset(0);
75 } 94 }
76 95
77 } // namespace blink 96 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | public/web/WebRange.h » ('j') | public/web/WebRange.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698