This source file includes following definitions.
- initialize
- textContent
- hitOffsetInTextContent
- rangeFromContentOffsets
- isNull
- reset
#include "config.h"
#include "WebSurroundingText.h"
#include "WebHitTestResult.h"
#include "core/dom/Element.h"
#include "core/dom/Node.h"
#include "core/dom/Range.h"
#include "core/dom/Text.h"
#include "core/editing/SurroundingText.h"
#include "core/editing/VisiblePosition.h"
#include "core/rendering/RenderObject.h"
#include "public/platform/WebPoint.h"
using namespace WebCore;
namespace blink {
void WebSurroundingText::initialize(const WebNode& webNode, const WebPoint& nodePoint, size_t maxLength)
{
const Node* node = webNode.constUnwrap<Node>();
if (!node || !node->renderer())
return;
m_private.reset(new SurroundingText(VisiblePosition(node->renderer()->positionForPoint(static_cast<IntPoint>(nodePoint))), maxLength));
}
WebString WebSurroundingText::textContent() const
{
return m_private->content();
}
size_t WebSurroundingText::hitOffsetInTextContent() const
{
return m_private->positionOffsetInContent();
}
WebRange WebSurroundingText::rangeFromContentOffsets(size_t startOffsetInContent, size_t endOffsetInContent)
{
return m_private->rangeFromContentOffsets(startOffsetInContent, endOffsetInContent);
}
bool WebSurroundingText::isNull() const
{
return !m_private.get();
}
void WebSurroundingText::reset()
{
m_private.reset(0);
}
}