| Index: Source/core/editing/VisibleSelection.cpp
|
| diff --git a/Source/core/editing/VisibleSelection.cpp b/Source/core/editing/VisibleSelection.cpp
|
| index 02861aa623b198a65822b208a86936e18f8011d5..753da69b7a295ef9f428906cba7d331ca9ab5aee 100644
|
| --- a/Source/core/editing/VisibleSelection.cpp
|
| +++ b/Source/core/editing/VisibleSelection.cpp
|
| @@ -771,6 +771,28 @@ void VisibleSelection::trace(Visitor* visitor)
|
| visitor->trace(m_changeObserver);
|
| }
|
|
|
| +static bool isValidPosition(const Position& position)
|
| +{
|
| + if (!position.inDocument())
|
| + return false;
|
| +
|
| + if (position.anchorType() != Position::PositionIsOffsetInAnchor)
|
| + return true;
|
| +
|
| + if (position.offsetInContainerNode() < 0)
|
| + return false;
|
| +
|
| + const unsigned offset = static_cast<unsigned>(position.offsetInContainerNode());
|
| + const unsigned nodeLength = position.anchorNode()->lengthOfContents();
|
| + return offset <= nodeLength;
|
| +}
|
| +
|
| +void VisibleSelection::validatePositionsIfNeeded()
|
| +{
|
| + if (!isValidPosition(m_base) || !isValidPosition(m_extent) || !isValidPosition(m_start) || !isValidPosition(m_end))
|
| + validate();
|
| +}
|
| +
|
| #ifndef NDEBUG
|
|
|
| void VisibleSelection::debugPosition() const
|
|
|