void SelectionMarkerController::updateInternal()
{
    if(m_inController)
        return;
    
    m_inController = true;
    FrameSelection* selection = m_frame->selection();
    ASSERT(selection);

    IntRect selectionBounds = enclosingIntRect(selection->bounds());
    if(selectionBounds.isEmpty()) {
        hideMarkers();
        m_inController = false;
        return;
    }
   
    attachMarkers();

    IntPoint start(selectionBounds.x(), selectionBounds.y());
    IntPoint end(selectionBounds.x() + selectionBounds.width(), selectionBounds.y() + selectionBounds.height());

    IntRect bounds = offsetForPosition(selection->start());
    if(!bounds.isEmpty()) {
        start = bounds.location();
    }
    
    bounds = offsetForPosition(selection->end());
    if(!bounds.isEmpty()) {
        end.setX(bounds.maxX());
        end.setY(bounds.maxY());
    }
    
    showMarkers(start, end);
    m_inController = false;
}
Exemplo n.º 2
0
void DataTransfer::writeSelection(const FrameSelection& selection)
{
    if (!m_dataObject)
        return;

    if (!enclosingTextFormControl(selection.start())) {
        m_dataObject->setHTMLAndBaseURL(selection.selectedHTMLForClipboard(), selection.frame()->document()->url());
    }

    String str = selection.selectedTextForClipboard();
#if OS(WIN)
    replaceNewlinesWithWindowsStyleNewlines(str);
#endif
    replaceNBSPWithSpace(str);
    m_dataObject->setData(mimeTypeTextPlain, str);
}