Changeset 144400 in webkit


Ignore:
Timestamp:
Feb 28, 2013 5:24:47 PM (11 years ago)
Author:
leviw@chromium.org
Message:

Stale FrameSelection in removed iframe causes crash
https://bugs.webkit.org/show_bug.cgi?id=108696

Reviewed by Ryosuke Niwa.

Source/WebCore:

Catching a specific issue where selectFrameElementInParentIfFullySelected in a nested
iFrame that is removed can leave the outer frame's selection referencing stale nodes.
Instead, in this case, we keep the frame alive long enough to check for this condition
and clear our selection if we hit it.

Test: editing/selection/selection-in-iframe-removed-crash.html

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::setSelection):

LayoutTests:

  • editing/selection/selection-in-iframe-removed-crash-expected.txt: Added.
  • editing/selection/selection-in-iframe-removed-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r144396 r144400  
     12013-02-28  Levi Weintraub  <leviw@chromium.org>
     2
     3        Stale FrameSelection in removed iframe causes crash
     4        https://bugs.webkit.org/show_bug.cgi?id=108696
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * editing/selection/selection-in-iframe-removed-crash-expected.txt: Added.
     9        * editing/selection/selection-in-iframe-removed-crash.html: Added.
     10
    1112013-02-28  Stephen Chenney  <schenney@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r144399 r144400  
     12013-02-28  Levi Weintraub  <leviw@chromium.org>
     2
     3        Stale FrameSelection in removed iframe causes crash
     4        https://bugs.webkit.org/show_bug.cgi?id=108696
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Catching a specific issue where selectFrameElementInParentIfFullySelected in a nested
     9        iFrame that is removed can leave the outer frame's selection referencing stale nodes.
     10        Instead, in this case, we keep the frame alive long enough to check for this condition
     11        and clear our selection if we hit it.
     12
     13        Test: editing/selection/selection-in-iframe-removed-crash.html
     14
     15        * editing/FrameSelection.cpp:
     16        (WebCore::FrameSelection::setSelection):
     17
    1182013-02-28  Conrad Shultz  <conrad_shultz@apple.com>
    219
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r143926 r144400  
    281281        Document* document = s.base().anchorNode()->document();
    282282        if (document && document->frame() && document->frame() != m_frame && document != m_frame->document()) {
     283            RefPtr<Frame> guard = document->frame();
    283284            document->frame()->selection()->setSelection(s, options, align, granularity);
     285            // It's possible that during the above set selection, this FrameSelection has been modified by
     286            // selectFrameElementInParentIfFullySelected, but that the selection is no longer valid since
     287            // the frame is about to be destroyed. If this is the case, clear our selection.
     288            if (guard->hasOneRef() && !m_selection.isNonOrphanedCaretOrRange())
     289                clear();
    284290            return;
    285291        }
Note: See TracChangeset for help on using the changeset viewer.