Nullptr crash in InlineTextBox::selectionState via TextIndicator::createWithRange
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2019 02:01:07 +0000 (02:01 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2019 02:01:07 +0000 (02:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196579

Reviewed by Simon Fraser.

Avoid crashing accessing the unengated optional's value in relese builds for now.

Unfortunately, fixing the underlying cause of the selection states of RenderView & RenderObject
getting out out of sync would require a significant re-architecturing of the whole selection
repainting / state managing mechanism.

* rendering/SelectionRangeData.h:
(WebCore::SelectionRangeData::startPosition const):
(WebCore::SelectionRangeData::endPosition const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243844 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/SelectionRangeData.h

index d5fd0a2..1dccc9e 100644 (file)
@@ -1,3 +1,20 @@
+2019-04-03  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Nullptr crash in InlineTextBox::selectionState via TextIndicator::createWithRange
+        https://bugs.webkit.org/show_bug.cgi?id=196579
+
+        Reviewed by Simon Fraser.
+
+        Avoid crashing accessing the unengated optional's value in relese builds for now.
+
+        Unfortunately, fixing the underlying cause of the selection states of RenderView & RenderObject
+        getting out out of sync would require a significant re-architecturing of the whole selection
+        repainting / state managing mechanism.
+
+        * rendering/SelectionRangeData.h:
+        (WebCore::SelectionRangeData::startPosition const):
+        (WebCore::SelectionRangeData::endPosition const):
+
 2019-04-03  Myles C. Maxfield  <mmaxfield@apple.com>
 
         -apple-trailing-word is needed for browser detection
index 7cdefe9..89aebe7 100644 (file)
@@ -78,8 +78,9 @@ public:
 
     RenderObject* start() const { return m_selectionContext.start(); }
     RenderObject* end() const { return m_selectionContext.end(); }
-    unsigned startPosition() const { ASSERT(m_selectionContext.startPosition()); return m_selectionContext.startPosition().value(); }
-    unsigned endPosition() const { ASSERT(m_selectionContext.endPosition()); return m_selectionContext.endPosition().value(); }
+
+    unsigned startPosition() const { ASSERT(m_selectionContext.startPosition()); return m_selectionContext.startPosition().valueOr(0); }
+    unsigned endPosition() const { ASSERT(m_selectionContext.endPosition()); return m_selectionContext.endPosition().valueOr(0); }
 
     void clear();
     IntRect bounds() const { return collectBounds(ClipToVisibleContent::No); }