Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: Source/core/dom/Element.cpp

Issue 225163004: Element::focus() should acquire the reference of LocalFrame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use focusout event. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/editing/selection/focus-iframe-removal-crash-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 return; 2147 return;
2148 } 2148 }
2149 2149
2150 cancelFocusAppearanceUpdate(); 2150 cancelFocusAppearanceUpdate();
2151 updateFocusAppearance(restorePreviousSelection); 2151 updateFocusAppearance(restorePreviousSelection);
2152 } 2152 }
2153 2153
2154 void Element::updateFocusAppearance(bool /*restorePreviousSelection*/) 2154 void Element::updateFocusAppearance(bool /*restorePreviousSelection*/)
2155 { 2155 {
2156 if (isRootEditableElement()) { 2156 if (isRootEditableElement()) {
2157 LocalFrame* frame = document().frame(); 2157 // Taking the ownership since setSelection() may release the last refere nce to |frame|.
2158 RefPtr<LocalFrame> frame(document().frame());
2158 if (!frame) 2159 if (!frame)
2159 return; 2160 return;
2160 2161
2161 // When focusing an editable element in an iframe, don't reset the selec tion if it already contains a selection. 2162 // When focusing an editable element in an iframe, don't reset the selec tion if it already contains a selection.
2162 if (this == frame->selection().rootEditableElement()) 2163 if (this == frame->selection().rootEditableElement())
2163 return; 2164 return;
2164 2165
2165 // FIXME: We should restore the previous selection if there is one. 2166 // FIXME: We should restore the previous selection if there is one.
2166 VisibleSelection newSelection = VisibleSelection(firstPositionInOrBefore Node(this), DOWNSTREAM); 2167 VisibleSelection newSelection = VisibleSelection(firstPositionInOrBefore Node(this), DOWNSTREAM);
2167 frame->selection().setSelection(newSelection); 2168 frame->selection().setSelection(newSelection);
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
3342 || isHTMLObjectElement(*this) 3343 || isHTMLObjectElement(*this)
3343 || isHTMLAppletElement(*this) 3344 || isHTMLAppletElement(*this)
3344 || isHTMLCanvasElement(*this)) 3345 || isHTMLCanvasElement(*this))
3345 return false; 3346 return false;
3346 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3347 if (FullscreenElementStack::isActiveFullScreenElement(this))
3347 return false; 3348 return false;
3348 return true; 3349 return true;
3349 } 3350 }
3350 3351
3351 } // namespace WebCore 3352 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/editing/selection/focus-iframe-removal-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698