#include "config.h"
#include "DOMSelection.h"
#include "Frame.h"
#include "Node.h"
#include "PlatformString.h"
#include "Range.h"
#include "SelectionController.h"
namespace WebCore {
DOMSelection::DOMSelection(Frame* frame)
: m_frame(frame)
{
}
Frame* DOMSelection::frame() const
{
return m_frame;
}
void DOMSelection::disconnectFrame()
{
m_frame = 0;
}
Node* DOMSelection::anchorNode() const
{
if (!m_frame)
return 0;
return m_frame->selectionController()->anchorNode();
}
Node* DOMSelection::baseNode() const
{
if (!m_frame)
return 0;
return m_frame->selectionController()->baseNode();
}
int DOMSelection::anchorOffset() const
{
if (!m_frame)
return 0;
return m_frame->selectionController()->anchorOffset();
}
int DOMSelection::baseOffset() const
{
if (!m_frame)
return 0;
return m_frame->selectionController()->baseOffset();
}
Node* DOMSelection::focusNode() const
{
if (!m_frame)
return 0;
return m_frame->selectionController()->focusNode();
}
Node* DOMSelection::extentNode() const
{
if (!m_frame)
return 0;
return m_frame->selectionController()->extentNode();
}
int DOMSelection::focusOffset() const
{
if (!m_frame)
return 0;
return m_frame->selectionController()->focusOffset();
}
int DOMSelection::extentOffset() const
{
if (!m_frame)
return 0;
return m_frame->selectionController()->extentOffset();
}
bool DOMSelection::isCollapsed() const
{
if (!m_frame)
return false;
return m_frame->selectionController()->isCollapsed();
}
String DOMSelection::type() const
{
if (!m_frame)
return String();
return m_frame->selectionController()->type();
}
int DOMSelection::rangeCount() const
{
if (!m_frame)
return 0;
return m_frame->selectionController()->rangeCount();
}
void DOMSelection::collapse(Node* node, int offset, ExceptionCode& ec)
{
if (!m_frame)
return;
m_frame->selectionController()->collapse(node, offset, ec);
}
void DOMSelection::collapseToEnd()
{
if (!m_frame)
return;
m_frame->selectionController()->collapseToEnd();
}
void DOMSelection::collapseToStart()
{
if (!m_frame)
return;
m_frame->selectionController()->collapseToStart();
}
void DOMSelection::empty()
{
if (!m_frame)
return;
m_frame->selectionController()->empty();
}
void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extentNode, int extentOffset, ExceptionCode& ec)
{
if (!m_frame)
return;
m_frame->selectionController()->setBaseAndExtent(baseNode, baseOffset, extentNode, extentOffset, ec);
}
void DOMSelection::setPosition(Node* node, int offset, ExceptionCode& ec)
{
if (!m_frame)
return;
m_frame->selectionController()->setPosition(node, offset, ec);
}
void DOMSelection::setPosition(Node* node, ExceptionCode& ec)
{
if (!m_frame)
return;
m_frame->selectionController()->setPosition(node, 0, ec);
}
void DOMSelection::modify(const String& alter, const String& direction, const String& granularity)
{
if (!m_frame)
return;
m_frame->selectionController()->modify(alter, direction, granularity);
}
PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionCode& ec)
{
if (!m_frame)
return 0;
return m_frame->selectionController()->getRangeAt(index, ec);
}
void DOMSelection::removeAllRanges()
{
if (!m_frame)
return;
m_frame->selectionController()->removeAllRanges();
}
void DOMSelection::addRange(Range* range)
{
if (!m_frame)
return;
m_frame->selectionController()->addRange(range);
}
String DOMSelection::toString()
{
if (!m_frame)
return String();
return m_frame->selectionController()->toString();
}
}