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

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

Issue 177903010: Expose the selection root bounds in WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 scaledAnchor.scale(pageScaleFactor()); 2137 scaledAnchor.scale(pageScaleFactor());
2138 scaledFocus.scale(pageScaleFactor()); 2138 scaledFocus.scale(pageScaleFactor());
2139 anchor = scaledAnchor; 2139 anchor = scaledAnchor;
2140 focus = scaledFocus; 2140 focus = scaledFocus;
2141 2141
2142 if (!selection.selection().isBaseFirst()) 2142 if (!selection.selection().isBaseFirst())
2143 std::swap(anchor, focus); 2143 std::swap(anchor, focus);
2144 return true; 2144 return true;
2145 } 2145 }
2146 2146
2147 bool WebViewImpl::selectionRootBounds(WebRect& bounds) const
2148 {
2149 const LocalFrame* frame = focusedWebCoreFrame();
2150 if (!frame)
2151 return false;
2152
2153 Element* root = frame->selection().rootEditableElementOrDocumentElement();
2154 if (!root)
2155 return false;
2156
2157 // Special casing textarea because of http://crbug.com/348945
2158 if (root->shadowHost()
tkent 2014/03/05 04:48:10 nit: You don't need to wrap this line.
mlamouri (slow - plz ping) 2014/03/05 09:52:45 Done.
2159 && root->shadowHost()->hasTagName(HTMLNames::textareaTag)) {
2160 root = root->shadowHost();
2161 }
2162
2163 IntRect boundingBox = root->pixelSnappedBoundingBox();
2164 boundingBox =
tkent 2014/03/05 04:48:10 nit: You don't need to wrap this line.
mlamouri (slow - plz ping) 2014/03/05 09:52:45 Done.
2165 root->document().frame()->view()->contentsToWindow(boundingBox);
2166 boundingBox.scale(pageScaleFactor());
2167 bounds = boundingBox;
2168
2169 return true;
2170 }
2171
2147 InputMethodContext* WebViewImpl::inputMethodContext() 2172 InputMethodContext* WebViewImpl::inputMethodContext()
2148 { 2173 {
2149 if (!m_imeAcceptEvents) 2174 if (!m_imeAcceptEvents)
2150 return 0; 2175 return 0;
2151 2176
2152 LocalFrame* focusedFrame = focusedWebCoreFrame(); 2177 LocalFrame* focusedFrame = focusedWebCoreFrame();
2153 if (!focusedFrame) 2178 if (!focusedFrame)
2154 return 0; 2179 return 0;
2155 2180
2156 Element* target = focusedFrame->document()->focusedElement(); 2181 Element* target = focusedFrame->document()->focusedElement();
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
3972 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 3997 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
3973 3998
3974 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 3999 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
3975 return false; 4000 return false;
3976 4001
3977 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4002 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
3978 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4003 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
3979 } 4004 }
3980 4005
3981 } // namespace blink 4006 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | public/web/WebWidget.h » ('j') | public/web/WebWidget.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698