Node* DOMSelection::focusNode() const { if (!m_frame) return 0; if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) return shadowAncestor->parentNode(); return focusPosition(visibleSelection()).node(); }
int DOMSelection::focusOffset() const { if (!m_frame) return 0; if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) return shadowAncestor->nodeIndex(); return focusPosition(visibleSelection()).deprecatedEditingOffset(); }
Node* DOMSelection::anchorNode() const { if (!m_frame) return 0; if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) return shadowAncestor->parentNodeGuaranteedHostFree(); return anchorPosition(visibleSelection()).containerNode(); }
int DOMSelection::extentOffset() const { if (!m_frame) return 0; if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) return shadowAncestor->nodeIndex(); return extentPosition(visibleSelection()).offsetInContainerNode(); }
RefPtr<Range> DOMSelection::getRangeAt(unsigned index, ExceptionCode& ec) { if (!m_frame) return nullptr; if (index >= rangeCount()) { ec = INDEX_SIZE_ERR; return nullptr; } // If you're hitting this, you've added broken multi-range selection support ASSERT(rangeCount() == 1); if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { ContainerNode* container = shadowAncestor->parentNodeGuaranteedHostFree(); unsigned offset = shadowAncestor->computeNodeIndex(); return Range::create(shadowAncestor->document(), container, offset, container, offset); } return m_frame->selection().selection().firstRange(); }
PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionCode& ec) { if (!m_frame) return 0; if (index < 0 || index >= rangeCount()) { ec = INDEX_SIZE_ERR; return 0; } // If you're hitting this, you've added broken multi-range selection support ASSERT(rangeCount() == 1); if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { Node* container = shadowAncestor->parentNode(); int offset = shadowAncestor->nodeIndex(); return Range::create(shadowAncestor->document(), container, offset, container, offset); } const VisibleSelection& selection = m_frame->selection()->selection(); return selection.firstRange(); }
PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) { if (!m_frame) return nullptr; if (index < 0 || index >= rangeCount()) { exceptionState.throwDOMException(IndexSizeError, String::number(index) + " is not a valid index."); return nullptr; } // If you're hitting this, you've added broken multi-range selection support ASSERT(rangeCount() == 1); if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { ASSERT(!shadowAncestor->isShadowRoot()); ContainerNode* container = shadowAncestor->parentOrShadowHostNode(); int offset = shadowAncestor->nodeIndex(); return Range::create(shadowAncestor->document(), container, offset, container, offset); } return m_frame->selection().firstRange(); }
PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) { if (!m_frame) return 0; if (index < 0 || index >= rangeCount()) { exceptionState.throwDOMException(IndexSizeError, String::number(index) + " is not a valid index."); return 0; } // If you're hitting this, you've added broken multi-range selection support ASSERT(rangeCount() == 1); if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { ContainerNode* container = shadowAncestor->parentNodeGuaranteedHostFree(); int offset = shadowAncestor->nodeIndex(); return Range::create(shadowAncestor->document(), container, offset, container, offset); } const VisibleSelection& selection = m_frame->selection().selection(); return selection.firstRange(); }
bool DOMSelection::isCollapsed() const { if (!isAvailable() || selectionShadowAncestor(frame())) return true; return !frame()->selection().isRange(); }
bool DOMSelection::isCollapsed() const { if (!m_frame || selectionShadowAncestor(m_frame)) return true; return !m_frame->selection()->isRange(); }