<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[208168] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/208168">208168</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2016-10-31 12:15:52 -0700 (Mon, 31 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Do a better job of protecting Frame objects in the context of JavaScript calls
https://bugs.webkit.org/show_bug.cgi?id=164163
&lt;rdar://problem/28955249&gt;

Reviewed by Darin Adler.

Source/WebCore:

* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::respondToUnappliedSpellCorrection): Protected the Frame.
* editing/Editor.cpp:
(WebCore::Editor::setTextAsChildOfElement): Ditto.
* editing/EditorCommand.cpp:
(WebCore::executeSwapWithMark): Ditto.
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::deleteKeyPressed): Ditto.
(WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto.
* editing/mac/EditorMac.mm:
(WebCore::Editor::replaceNodeFromPasteboard): Ditto.
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected): Ditto.
* page/DOMSelection.cpp:
(WebCore::DOMSelection::collapse): Ditto.
(WebCore::DOMSelection::collapseToEnd): Ditto.
(WebCore::DOMSelection::collapseToStart): Ditto.
(WebCore::DOMSelection::setBaseAndExtent): Ditto.
(WebCore::DOMSelection::setPosition): Ditto.
(WebCore::DOMSelection::modify): Ditto.
(WebCore::DOMSelection::extend): Ditto.
(WebCore::DOMSelection::addRange): Ditto.
(WebCore::DOMSelection::deleteFromDocument): Ditto.
* page/DragController.cpp:
(WebCore::setSelectionToDragCaret): Ditto.
(WebCore::DragController::startDrag): Ditto.
* page/Frame.cpp:
(WebCore::Frame::checkOverflowScroll): Ditto.
* page/TextIndicator.cpp:
(WebCore::TextIndicator::createWithRange): Ditto.

Source/WebKit2:

* WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
(WebKit::InjectedBundleRangeHandle::renderedImage): Protected the Frame.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::insertTextAsync): Ditto.
(WebKit::WebPage::setComposition): Ditto.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::insertDictatedTextAsync): Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingAlternativeTextControllercpp">trunk/Source/WebCore/editing/AlternativeTextController.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorcpp">trunk/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorCommandcpp">trunk/Source/WebCore/editing/EditorCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTypingCommandcpp">trunk/Source/WebCore/editing/TypingCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingmacEditorMacmm">trunk/Source/WebCore/editing/mac/EditorMac.mm</a></li>
<li><a href="#trunkSourceWebCorepageContextMenuControllercpp">trunk/Source/WebCore/page/ContextMenuController.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDOMSelectioncpp">trunk/Source/WebCore/page/DOMSelection.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDragControllercpp">trunk/Source/WebCore/page/DragController.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFramecpp">trunk/Source/WebCore/page/Frame.cpp</a></li>
<li><a href="#trunkSourceWebCorepageTextIndicatorcpp">trunk/Source/WebCore/page/TextIndicator.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleDOMInjectedBundleRangeHandlecpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm">trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebCore/ChangeLog        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2016-10-28  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        Do a better job of protecting Frame objects in the context of JavaScript calls
+        https://bugs.webkit.org/show_bug.cgi?id=164163
+        &lt;rdar://problem/28955249&gt;
+
+        Reviewed by Darin Adler.
+
+        * editing/AlternativeTextController.cpp:
+        (WebCore::AlternativeTextController::respondToUnappliedSpellCorrection): Protected the Frame.
+        * editing/Editor.cpp:
+        (WebCore::Editor::setTextAsChildOfElement): Ditto.
+        * editing/EditorCommand.cpp:
+        (WebCore::executeSwapWithMark): Ditto.
+        * editing/TypingCommand.cpp:
+        (WebCore::TypingCommand::deleteKeyPressed): Ditto.
+        (WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto.
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::replaceNodeFromPasteboard): Ditto.
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::contextMenuItemSelected): Ditto.
+        * page/DOMSelection.cpp:
+        (WebCore::DOMSelection::collapse): Ditto.
+        (WebCore::DOMSelection::collapseToEnd): Ditto.
+        (WebCore::DOMSelection::collapseToStart): Ditto.
+        (WebCore::DOMSelection::setBaseAndExtent): Ditto.
+        (WebCore::DOMSelection::setPosition): Ditto.
+        (WebCore::DOMSelection::modify): Ditto.
+        (WebCore::DOMSelection::extend): Ditto.
+        (WebCore::DOMSelection::addRange): Ditto.
+        (WebCore::DOMSelection::deleteFromDocument): Ditto.
+        * page/DragController.cpp:
+        (WebCore::setSelectionToDragCaret): Ditto.
+        (WebCore::DragController::startDrag): Ditto.
+        * page/Frame.cpp:
+        (WebCore::Frame::checkOverflowScroll): Ditto.
+        * page/TextIndicator.cpp:
+        (WebCore::TextIndicator::createWithRange): Ditto.
+
</ins><span class="cx"> 2016-10-31  Dave Hyatt  &lt;hyatt@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Parser] Make sure to fail on :role(a,b) and :dir(a,b)
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingAlternativeTextControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/AlternativeTextController.cpp (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/AlternativeTextController.cpp        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebCore/editing/AlternativeTextController.cpp        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006-2008, 2016 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -317,6 +317,8 @@
</span><span class="cx"> {
</span><span class="cx">     if (AlternativeTextClient* client = alternativeTextClient())
</span><span class="cx">         client-&gt;recordAutocorrectionResponse(AutocorrectionReverted, corrected, correction);
</span><ins>+
+    Ref&lt;Frame&gt; protector(m_frame);
</ins><span class="cx">     m_frame.document()-&gt;updateLayout();
</span><span class="cx">     m_frame.selection().setSelection(selectionOfCorrected, FrameSelection::defaultSetSelectionOptions() | FrameSelection::SpellCorrectionTriggered);
</span><span class="cx">     RefPtr&lt;Range&gt; range = Range::create(*m_frame.document(), m_frame.selection().selection().start(), m_frame.selection().selection().end());
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.cpp (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.cpp        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebCore/editing/Editor.cpp        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008, 2011, 2013-2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006-2008, 2011, 2013-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -1697,6 +1697,8 @@
</span><span class="cx"> 
</span><span class="cx"> void Editor::setComposition(const String&amp; text, const Vector&lt;CompositionUnderline&gt;&amp; underlines, unsigned selectionStart, unsigned selectionEnd)
</span><span class="cx"> {
</span><ins>+    Ref&lt;Frame&gt; protection(m_frame);
+
</ins><span class="cx">     UserTypingGestureIndicator typingGestureIndicator(m_frame);
</span><span class="cx"> 
</span><span class="cx">     setIgnoreCompositionSelectionChange(true);
</span><span class="lines">@@ -1843,6 +1845,8 @@
</span><span class="cx"> 
</span><span class="cx"> void Editor::advanceToNextMisspelling(bool startBeforeSelection)
</span><span class="cx"> {
</span><ins>+    Ref&lt;Frame&gt; protection(m_frame);
+
</ins><span class="cx">     // The basic approach is to search in two phases - from the selection end to the end of the doc, and
</span><span class="cx">     // then we wrap and search from the doc start to (approximately) where we started.
</span><span class="cx">     
</span><span class="lines">@@ -2162,6 +2166,8 @@
</span><span class="cx"> 
</span><span class="cx"> void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &amp;wordStart, const VisibleSelection&amp; selectionAfterTyping, bool doReplacement)
</span><span class="cx"> {
</span><ins>+    Ref&lt;Frame&gt; protection(m_frame);
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     UNUSED_PARAM(selectionAfterTyping);
</span><span class="cx">     UNUSED_PARAM(doReplacement);
</span><span class="lines">@@ -2412,6 +2418,7 @@
</span><span class="cx"> 
</span><span class="cx"> void Editor::markAndReplaceFor(PassRefPtr&lt;SpellCheckRequest&gt; request, const Vector&lt;TextCheckingResult&gt;&amp; results)
</span><span class="cx"> {
</span><ins>+    Ref&lt;Frame&gt; protection(m_frame);
</ins><span class="cx">     ASSERT(request);
</span><span class="cx"> 
</span><span class="cx">     TextCheckingTypeMask textCheckingOptions = request-&gt;data().mask();
</span><span class="lines">@@ -2870,6 +2877,8 @@
</span><span class="cx"> 
</span><span class="cx"> void Editor::changeSelectionAfterCommand(const VisibleSelection&amp; newSelection, FrameSelection::SetSelectionOptions options)
</span><span class="cx"> {
</span><ins>+    Ref&lt;Frame&gt; protection(m_frame);
+
</ins><span class="cx">     // If the new selection is orphaned, then don't update the selection.
</span><span class="cx">     if (newSelection.start().isOrphan() || newSelection.end().isOrphan())
</span><span class="cx">         return;
</span><span class="lines">@@ -3069,6 +3078,8 @@
</span><span class="cx"> 
</span><span class="cx"> bool Editor::findString(const String&amp; target, FindOptions options)
</span><span class="cx"> {
</span><ins>+    Ref&lt;Frame&gt; protection(m_frame);
+
</ins><span class="cx">     VisibleSelection selection = m_frame.selection().selection();
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Range&gt; resultRange = rangeOfString(target, selection.firstRange().get(), options);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/EditorCommand.cpp (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/EditorCommand.cpp        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebCore/editing/EditorCommand.cpp        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008, 2014 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006-2008, 2014, 2016 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
</span><span class="cx">  * Copyright (C) 2009 Igalia S.L.
</span><span class="cx">  *
</span><span class="lines">@@ -1060,6 +1060,7 @@
</span><span class="cx"> 
</span><span class="cx"> static bool executeSwapWithMark(Frame&amp; frame, Event*, EditorCommandSource, const String&amp;)
</span><span class="cx"> {
</span><ins>+    Ref&lt;Frame&gt; protector(frame);
</ins><span class="cx">     const VisibleSelection&amp; mark = frame.editor().mark();
</span><span class="cx">     const VisibleSelection&amp; selection = frame.selection().selection();
</span><span class="cx">     if (mark.isNone() || selection.isNone()) {
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTypingCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TypingCommand.cpp (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TypingCommand.cpp        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebCore/editing/TypingCommand.cpp        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2005-2008, 2016 Apple Inc.  All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -643,6 +643,7 @@
</span><span class="cx"> void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool shouldAddToKillRing)
</span><span class="cx"> {
</span><span class="cx">     Frame&amp; frame = this-&gt;frame();
</span><ins>+    Ref&lt;Frame&gt; protector(frame);
</ins><span class="cx"> 
</span><span class="cx">     frame.editor().updateMarkersForWordsAffectedByEditing(false);
</span><span class="cx"> 
</span><span class="lines">@@ -763,6 +764,7 @@
</span><span class="cx"> void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool shouldAddToKillRing)
</span><span class="cx"> {
</span><span class="cx">     Frame&amp; frame = this-&gt;frame();
</span><ins>+    Ref&lt;Frame&gt; protector(frame);
</ins><span class="cx"> 
</span><span class="cx">     frame.editor().updateMarkersForWordsAffectedByEditing(false);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmacEditorMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/mac/EditorMac.mm        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -259,6 +259,7 @@
</span><span class="cx">     if (&amp;node-&gt;document() != m_frame.document())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protector(m_frame);
</ins><span class="cx">     RefPtr&lt;Range&gt; range = Range::create(node-&gt;document(), Position(node, Position::PositionIsBeforeAnchor), Position(node, Position::PositionIsAfterAnchor));
</span><span class="cx">     m_frame.selection().setSelection(VisibleSelection(*range), FrameSelection::DoNotSetFocus);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageContextMenuControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ContextMenuController.cpp        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006-2007, 2016 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2010 Igalia S.L
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -223,6 +223,8 @@
</span><span class="cx">     if (!frame)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protector(*frame);
+
</ins><span class="cx">     switch (action) {
</span><span class="cx">     case ContextMenuItemTagOpenLinkInNewWindow:
</span><span class="cx">         openNewWindow(m_context.hitTestResult().absoluteLinkURL(), frame, ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes);
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMSelectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMSelection.cpp (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMSelection.cpp        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebCore/page/DOMSelection.cpp        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007, 2009, 2016 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -169,6 +169,8 @@
</span><span class="cx"> {
</span><span class="cx">     if (!isValidForPosition(node))
</span><span class="cx">         return;
</span><ins>+
+    Ref&lt;Frame&gt; protector(*m_frame);
</ins><span class="cx">     m_frame-&gt;selection().moveTo(createLegacyEditingPosition(node, offset), DOWNSTREAM);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -179,6 +181,8 @@
</span><span class="cx">     auto&amp; selection = m_frame-&gt;selection();
</span><span class="cx">     if (selection.isNone())
</span><span class="cx">         return Exception { INVALID_STATE_ERR };
</span><ins>+
+    Ref&lt;Frame&gt; protector(*m_frame);
</ins><span class="cx">     selection.moveTo(selection.selection().end(), DOWNSTREAM);
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="lines">@@ -190,6 +194,8 @@
</span><span class="cx">     auto&amp; selection = m_frame-&gt;selection();
</span><span class="cx">     if (selection.isNone())
</span><span class="cx">         return Exception { INVALID_STATE_ERR };
</span><ins>+
+    Ref&lt;Frame&gt; protector(*m_frame);
</ins><span class="cx">     selection.moveTo(selection.selection().start(), DOWNSTREAM);
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="lines">@@ -205,6 +211,8 @@
</span><span class="cx"> {
</span><span class="cx">     if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode))
</span><span class="cx">         return;
</span><ins>+
+    Ref&lt;Frame&gt; protector(*m_frame);
</ins><span class="cx">     m_frame-&gt;selection().moveTo(createLegacyEditingPosition(baseNode, baseOffset), createLegacyEditingPosition(extentNode, extentOffset), DOWNSTREAM);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -212,6 +220,8 @@
</span><span class="cx"> {
</span><span class="cx">     if (!isValidForPosition(node))
</span><span class="cx">         return;
</span><ins>+
+    Ref&lt;Frame&gt; protector(*m_frame);
</ins><span class="cx">     m_frame-&gt;selection().moveTo(createLegacyEditingPosition(node, offset), DOWNSTREAM);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -262,6 +272,7 @@
</span><span class="cx">     else
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protector(*m_frame);
</ins><span class="cx">     m_frame-&gt;selection().modify(alter, direction, granularity);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -273,6 +284,8 @@
</span><span class="cx">         return Exception { INDEX_SIZE_ERR };
</span><span class="cx">     if (!isValidForPosition(&amp;node))
</span><span class="cx">         return { };
</span><ins>+
+    Ref&lt;Frame&gt; protector(*m_frame);
</ins><span class="cx">     m_frame-&gt;selection().setExtent(createLegacyEditingPosition(&amp;node, offset), DOWNSTREAM);
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="lines">@@ -306,6 +319,8 @@
</span><span class="cx">     if (!m_frame)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protector(*m_frame);
+
</ins><span class="cx">     auto&amp; selection = m_frame-&gt;selection();
</span><span class="cx">     if (selection.isNone()) {
</span><span class="cx">         selection.moveTo(&amp;range);
</span><span class="lines">@@ -355,6 +370,7 @@
</span><span class="cx">     if (!selectedRange)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protector(*m_frame);
</ins><span class="cx">     selectedRange-&gt;deleteContents(ASSERT_NO_EXCEPTION);
</span><span class="cx">     setBaseAndExtent(&amp;selectedRange-&gt;startContainer(), selectedRange-&gt;startOffset(), &amp;selectedRange-&gt;startContainer(), selectedRange-&gt;startOffset());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorepageDragControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DragController.cpp (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DragController.cpp        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebCore/page/DragController.cpp        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2007, 2009, 2010, 2013, 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2007, 2009-2010, 2013, 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -433,6 +433,7 @@
</span><span class="cx"> 
</span><span class="cx"> static bool setSelectionToDragCaret(Frame* frame, VisibleSelection&amp; dragCaret, RefPtr&lt;Range&gt;&amp; range, const IntPoint&amp; point)
</span><span class="cx"> {
</span><ins>+    Ref&lt;Frame&gt; protector(*frame);
</ins><span class="cx">     frame-&gt;selection().setSelection(dragCaret);
</span><span class="cx">     if (frame-&gt;selection().selection().isNone()) {
</span><span class="cx">         dragCaret = frame-&gt;visiblePositionForPoint(point);
</span><span class="lines">@@ -753,6 +754,7 @@
</span><span class="cx">     if (!src.view() || !src.contentRenderer() || !state.source)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protector(src);
</ins><span class="cx">     HitTestResult hitTestResult = src.eventHandler().hitTestResultAtPoint(dragOrigin, HitTestRequest::ReadOnly | HitTestRequest::Active);
</span><span class="cx"> 
</span><span class="cx">     // FIXME(136836): Investigate whether all elements should use the containsIncludingShadowDOM() path here.
</span></span></pre></div>
<a id="trunkSourceWebCorepageFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Frame.cpp (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Frame.cpp        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebCore/page/Frame.cpp        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -604,6 +604,8 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protectedThis(*this);
+
</ins><span class="cx">     if (action == PerformOverflowScroll &amp;&amp; (deltaX || deltaY)) {
</span><span class="cx">         layer-&gt;scrollToOffset(layer-&gt;scrollOffset() + IntSize(deltaX, deltaY));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageTextIndicatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/TextIndicator.cpp (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/TextIndicator.cpp        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebCore/page/TextIndicator.cpp        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010, 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010, 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -69,6 +69,8 @@
</span><span class="cx">     if (!frame)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protector(*frame);
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     frame-&gt;editor().setIgnoreCompositionSelectionChange(true);
</span><span class="cx">     frame-&gt;selection().setUpdateAppearanceEnabled(true);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebKit2/ChangeLog        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-10-28  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        Do a better job of protecting Frame objects in the context of JavaScript calls
+        https://bugs.webkit.org/show_bug.cgi?id=164163
+        &lt;rdar://problem/28955249&gt;
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
+        (WebKit::InjectedBundleRangeHandle::renderedImage): Protected the Frame.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::insertTextAsync): Ditto.
+        (WebKit::WebPage::setComposition): Ditto.
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::insertDictatedTextAsync): Ditto.
+
</ins><span class="cx"> 2016-10-31  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         NetworkSession: Network process crash when converting main resource to download
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleDOMInjectedBundleRangeHandlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010, 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010, 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -114,6 +114,8 @@
</span><span class="cx">     if (!frameView)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protector(*frame);
+
</ins><span class="cx">     VisibleSelection oldSelection = frame-&gt;selection().selection();
</span><span class="cx">     frame-&gt;selection().setSelection(VisibleSelection(*m_range));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -4625,6 +4625,8 @@
</span><span class="cx"> {
</span><span class="cx">     Frame&amp; frame = m_page-&gt;focusController().focusedOrMainFrame();
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protector(frame);
+
</ins><span class="cx">     bool replacesText = false;
</span><span class="cx">     if (replacementEditingRange.location != notFound) {
</span><span class="cx">         RefPtr&lt;Range&gt; replacementRange = rangeFromEditingRange(frame, replacementEditingRange, static_cast&lt;EditingRangeIsRelativeTo&gt;(editingRangeIsRelativeTo));
</span><span class="lines">@@ -4791,6 +4793,8 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protector(*targetFrame);
+
</ins><span class="cx">     if (replacementLength &gt; 0) {
</span><span class="cx">         // The layout needs to be uptodate before setting a selection
</span><span class="cx">         targetFrame-&gt;document()-&gt;updateLayout();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (208167 => 208168)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2016-10-31 19:13:37 UTC (rev 208167)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2016-10-31 19:15:52 UTC (rev 208168)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010, 2011, 2012, 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010-2012, 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -328,6 +328,8 @@
</span><span class="cx"> {
</span><span class="cx">     Frame&amp; frame = m_page-&gt;focusController().focusedOrMainFrame();
</span><span class="cx"> 
</span><ins>+    Ref&lt;Frame&gt; protector(frame);
+
</ins><span class="cx">     if (replacementEditingRange.location != notFound) {
</span><span class="cx">         RefPtr&lt;Range&gt; replacementRange = rangeFromEditingRange(frame, replacementEditingRange);
</span><span class="cx">         if (replacementRange)
</span></span></pre>
</div>
</div>

</body>
</html>