void SelectionAdjuster::adjustSelectionToAvoidCrossingShadowBoundaries( VisibleSelection* selection) { // Note: |m_selectionType| isn't computed yet. DCHECK(selection->base().isNotNull()); DCHECK(selection->extent().isNotNull()); DCHECK(selection->start().isNotNull()); DCHECK(selection->end().isNotNull()); // TODO(hajimehoshi): Checking treeScope is wrong when a node is // distributed, but we leave it as it is for backward compatibility. if (selection->start().anchorNode()->treeScope() == selection->end().anchorNode()->treeScope()) return; if (selection->isBaseFirst()) { const Position& newEnd = adjustPositionForEnd( selection->end(), selection->start().computeContainerNode()); selection->m_extent = newEnd; selection->m_end = newEnd; return; } const Position& newStart = adjustPositionForStart( selection->start(), selection->end().computeContainerNode()); selection->m_extent = newStart; selection->m_start = newStart; }
void VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries() { if (m_base.isNull() || m_start.isNull() || m_end.isNull()) return; if (&m_start.anchorNode()->treeScope() == &m_end.anchorNode()->treeScope()) return; if (m_baseIsFirst) { m_extent = adjustPositionForEnd(m_end, m_start.containerNode()); m_end = m_extent; } else { m_extent = adjustPositionForStart(m_start, m_end.containerNode()); m_start = m_extent; } ASSERT(&m_start.anchorNode()->treeScope() == &m_end.anchorNode()->treeScope()); }