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

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 224113002: Oilpan: move Range object to the oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use STACK_ALLOCATED() + incorporate ager's overview of macros in this area. 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 // We should use this |editor| object only to complete the ongoing 1936 // We should use this |editor| object only to complete the ongoing
1937 // composition. 1937 // composition.
1938 InputMethodController& inputMethodController = focused->inputMethodControlle r(); 1938 InputMethodController& inputMethodController = focused->inputMethodControlle r();
1939 if (!focused->editor().canEdit() && !inputMethodController.hasComposition()) 1939 if (!focused->editor().canEdit() && !inputMethodController.hasComposition())
1940 return false; 1940 return false;
1941 1941
1942 // We should verify the parent node of this IME composition node are 1942 // We should verify the parent node of this IME composition node are
1943 // editable because JavaScript may delete a parent node of the composition 1943 // editable because JavaScript may delete a parent node of the composition
1944 // node. In this case, WebKit crashes while deleting texts from the parent 1944 // node. In this case, WebKit crashes while deleting texts from the parent
1945 // node, which doesn't exist any longer. 1945 // node, which doesn't exist any longer.
1946 RefPtr<Range> range = inputMethodController.compositionRange(); 1946 RefPtrWillBeRawPtr<Range> range = inputMethodController.compositionRange();
1947 if (range) { 1947 if (range) {
1948 Node* node = range->startContainer(); 1948 Node* node = range->startContainer();
1949 if (!node || !node->isContentEditable()) 1949 if (!node || !node->isContentEditable())
1950 return false; 1950 return false;
1951 } 1951 }
1952 1952
1953 // If we're not going to fire a keypress event, then the keydown event was 1953 // If we're not going to fire a keypress event, then the keydown event was
1954 // canceled. In that case, cancel any existing composition. 1954 // canceled. In that case, cancel any existing composition.
1955 if (text.isEmpty() || m_suppressNextKeypressEvent) { 1955 if (text.isEmpty() || m_suppressNextKeypressEvent) {
1956 // A browser process sent an IPC message which does not contain a valid 1956 // A browser process sent an IPC message which does not contain a valid
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 2000
2001 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection); 2001 return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp utMethodController::DoNotKeepSelection);
2002 } 2002 }
2003 2003
2004 bool WebViewImpl::compositionRange(size_t* location, size_t* length) 2004 bool WebViewImpl::compositionRange(size_t* location, size_t* length)
2005 { 2005 {
2006 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); 2006 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame());
2007 if (!focused || !m_imeAcceptEvents) 2007 if (!focused || !m_imeAcceptEvents)
2008 return false; 2008 return false;
2009 2009
2010 RefPtr<Range> range = focused->inputMethodController().compositionRange(); 2010 RefPtrWillBeRawPtr<Range> range = focused->inputMethodController().compositi onRange();
2011 if (!range) 2011 if (!range)
2012 return false; 2012 return false;
2013 2013
2014 Element* editable = focused->selection().rootEditableElementOrDocumentElemen t(); 2014 Element* editable = focused->selection().rootEditableElementOrDocumentElemen t();
2015 ASSERT(editable); 2015 ASSERT(editable);
2016 PlainTextRange plainTextRange(PlainTextRange::create(*editable, *range.get() )); 2016 PlainTextRange plainTextRange(PlainTextRange::create(*editable, *range.get() ));
2017 if (plainTextRange.isNull()) 2017 if (plainTextRange.isNull())
2018 return false; 2018 return false;
2019 *location = plainTextRange.start(); 2019 *location = plainTextRange.start();
2020 *length = plainTextRange.length(); 2020 *length = plainTextRange.length();
(...skipping 20 matching lines...) Expand all
2041 return info; 2041 return info;
2042 2042
2043 if (!focused->editor().canEdit()) 2043 if (!focused->editor().canEdit())
2044 return info; 2044 return info;
2045 2045
2046 info.value = plainText(rangeOfContents(node).get()); 2046 info.value = plainText(rangeOfContents(node).get());
2047 2047
2048 if (info.value.isEmpty()) 2048 if (info.value.isEmpty())
2049 return info; 2049 return info;
2050 2050
2051 if (RefPtr<Range> range = selection.selection().firstRange()) { 2051 if (RefPtrWillBeRawPtr<Range> range = selection.selection().firstRange()) {
2052 PlainTextRange plainTextRange(PlainTextRange::create(*node, *range.get() )); 2052 PlainTextRange plainTextRange(PlainTextRange::create(*node, *range.get() ));
2053 if (plainTextRange.isNotNull()) { 2053 if (plainTextRange.isNotNull()) {
2054 info.selectionStart = plainTextRange.start(); 2054 info.selectionStart = plainTextRange.start();
2055 info.selectionEnd = plainTextRange.end(); 2055 info.selectionEnd = plainTextRange.end();
2056 } 2056 }
2057 } 2057 }
2058 2058
2059 if (RefPtr<Range> range = focused->inputMethodController().compositionRange( )) { 2059 if (RefPtrWillBeRawPtr<Range> range = focused->inputMethodController().compo sitionRange()) {
2060 PlainTextRange plainTextRange(PlainTextRange::create(*node, *range.get() )); 2060 PlainTextRange plainTextRange(PlainTextRange::create(*node, *range.get() ));
2061 if (plainTextRange.isNotNull()) { 2061 if (plainTextRange.isNotNull()) {
2062 info.compositionStart = plainTextRange.start(); 2062 info.compositionStart = plainTextRange.start();
2063 info.compositionEnd = plainTextRange.end(); 2063 info.compositionEnd = plainTextRange.end();
2064 } 2064 }
2065 } 2065 }
2066 2066
2067 return info; 2067 return info;
2068 } 2068 }
2069 2069
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2152 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const 2152 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const
2153 { 2153 {
2154 const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); 2154 const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame());
2155 if (!frame) 2155 if (!frame)
2156 return false; 2156 return false;
2157 FrameSelection& selection = frame->selection(); 2157 FrameSelection& selection = frame->selection();
2158 2158
2159 if (selection.isCaret()) { 2159 if (selection.isCaret()) {
2160 anchor = focus = selection.absoluteCaretBounds(); 2160 anchor = focus = selection.absoluteCaretBounds();
2161 } else { 2161 } else {
2162 RefPtr<Range> selectedRange = selection.toNormalizedRange(); 2162 RefPtrWillBeRawPtr<Range> selectedRange = selection.toNormalizedRange();
2163 if (!selectedRange) 2163 if (!selectedRange)
2164 return false; 2164 return false;
2165 2165
2166 RefPtr<Range> range(Range::create(selectedRange->startContainer()->docum ent(), 2166 RefPtrWillBeRawPtr<Range> range(Range::create(selectedRange->startContai ner()->document(),
2167 selectedRange->startContainer(), 2167 selectedRange->startContainer(),
2168 selectedRange->startOffset(), 2168 selectedRange->startOffset(),
2169 selectedRange->startContainer(), 2169 selectedRange->startContainer(),
2170 selectedRange->startOffset())); 2170 selectedRange->startOffset()));
2171 anchor = frame->editor().firstRectForRange(range.get()); 2171 anchor = frame->editor().firstRectForRange(range.get());
2172 2172
2173 range = Range::create(selectedRange->endContainer()->document(), 2173 range = Range::create(selectedRange->endContainer()->document(),
2174 selectedRange->endContainer(), 2174 selectedRange->endContainer(),
2175 selectedRange->endOffset(), 2175 selectedRange->endOffset(),
2176 selectedRange->endContainer(), 2176 selectedRange->endContainer(),
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after
3975 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 3975 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
3976 3976
3977 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 3977 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
3978 return false; 3978 return false;
3979 3979
3980 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 3980 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
3981 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 3981 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
3982 } 3982 }
3983 3983
3984 } // namespace blink 3984 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698