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

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

Issue 103863007: Let WebViewImpl::textInputInfo() query the focused element when selection is empty (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: added unit test Created 7 years 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
« no previous file with comments | « no previous file | Source/web/tests/WebViewTest.cpp » ('j') | 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) 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 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2158 } 2158 }
2159 2159
2160 WebTextInputInfo WebViewImpl::textInputInfo() 2160 WebTextInputInfo WebViewImpl::textInputInfo()
2161 { 2161 {
2162 WebTextInputInfo info; 2162 WebTextInputInfo info;
2163 2163
2164 Frame* focused = focusedWebCoreFrame(); 2164 Frame* focused = focusedWebCoreFrame();
2165 if (!focused) 2165 if (!focused)
2166 return info; 2166 return info;
2167 2167
2168 FrameSelection& selection = focused->selection();
2169 Node* node = selection.selection().rootEditableElement();
2170 if (!node)
2171 return info;
2172
2173 info.inputMode = inputModeOfFocusedElement(); 2168 info.inputMode = inputModeOfFocusedElement();
2174 2169
2175 info.type = textInputType(); 2170 info.type = textInputType();
2176 if (info.type == WebTextInputTypeNone) 2171 if (info.type == WebTextInputTypeNone)
2177 return info; 2172 return info;
2178 2173
2174 FrameSelection& selection = focused->selection();
2175 Node* node = selection.selection().rootEditableElement();
2176 if (!node)
2177 return info;
2178
2179 if (!focused->editor().canEdit()) 2179 if (!focused->editor().canEdit())
2180 return info; 2180 return info;
2181 2181
2182 info.value = plainText(rangeOfContents(node).get()); 2182 info.value = plainText(rangeOfContents(node).get());
2183 2183
2184 if (info.value.isEmpty()) 2184 if (info.value.isEmpty())
2185 return info; 2185 return info;
2186 2186
2187 if (RefPtr<Range> range = selection.selection().firstRange()) { 2187 if (RefPtr<Range> range = selection.selection().firstRange()) {
2188 PlainTextRange plainTextRange(PlainTextRange::create(*node, *range.get() )); 2188 PlainTextRange plainTextRange(PlainTextRange::create(*node, *range.get() ));
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
4192 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4192 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4193 4193
4194 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4194 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4195 return false; 4195 return false;
4196 4196
4197 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4197 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4198 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4198 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4199 } 4199 }
4200 4200
4201 } // namespace blink 4201 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698