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

Side by Side Diff: ui/base/x/x11_util.cc

Issue 2930573005: Use ContainsValue() instead of std::find() in ui/android, ui/base and ui/views (Closed)
Patch Set: Changed EXPECT_FALSE to EXPECT_TRUE Created 3 years, 6 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
« no previous file with comments | « ui/base/x/selection_utils.cc ('k') | ui/views/layout/grid_layout.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file defines utility functions for X11 (Linux only). This code has been 5 // This file defines utility functions for X11 (Linux only). This code has been
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
7 // remains woefully incomplete. 7 // remains woefully incomplete.
8 8
9 #include "ui/base/x/x11_util.h" 9 #include "ui/base/x/x11_util.h"
10 10
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 bool IsX11WindowFullScreen(XID window) { 1196 bool IsX11WindowFullScreen(XID window) {
1197 // If _NET_WM_STATE_FULLSCREEN is in _NET_SUPPORTED, use the presence or 1197 // If _NET_WM_STATE_FULLSCREEN is in _NET_SUPPORTED, use the presence or
1198 // absence of _NET_WM_STATE_FULLSCREEN in _NET_WM_STATE to determine 1198 // absence of _NET_WM_STATE_FULLSCREEN in _NET_WM_STATE to determine
1199 // whether we're fullscreen. 1199 // whether we're fullscreen.
1200 XAtom fullscreen_atom = GetAtom("_NET_WM_STATE_FULLSCREEN"); 1200 XAtom fullscreen_atom = GetAtom("_NET_WM_STATE_FULLSCREEN");
1201 if (WmSupportsHint(fullscreen_atom)) { 1201 if (WmSupportsHint(fullscreen_atom)) {
1202 std::vector<XAtom> atom_properties; 1202 std::vector<XAtom> atom_properties;
1203 if (GetAtomArrayProperty(window, 1203 if (GetAtomArrayProperty(window,
1204 "_NET_WM_STATE", 1204 "_NET_WM_STATE",
1205 &atom_properties)) { 1205 &atom_properties)) {
1206 return std::find(atom_properties.begin(), 1206 return base::ContainsValue(atom_properties, fullscreen_atom);
1207 atom_properties.end(),
1208 fullscreen_atom) !=
1209 atom_properties.end();
1210 } 1207 }
1211 } 1208 }
1212 1209
1213 gfx::Rect window_rect; 1210 gfx::Rect window_rect;
1214 if (!ui::GetOuterWindowBounds(window, &window_rect)) 1211 if (!ui::GetOuterWindowBounds(window, &window_rect))
1215 return false; 1212 return false;
1216 1213
1217 // We can't use display::Screen here because we don't have an aura::Window. So 1214 // We can't use display::Screen here because we don't have an aura::Window. So
1218 // instead just look at the size of the default display. 1215 // instead just look at the size of the default display.
1219 // 1216 //
(...skipping 10 matching lines...) Expand all
1230 if (!SupportsEWMH()) 1227 if (!SupportsEWMH())
1231 return false; 1228 return false;
1232 1229
1233 std::vector<XAtom> supported_atoms; 1230 std::vector<XAtom> supported_atoms;
1234 if (!GetAtomArrayProperty(GetX11RootWindow(), 1231 if (!GetAtomArrayProperty(GetX11RootWindow(),
1235 "_NET_SUPPORTED", 1232 "_NET_SUPPORTED",
1236 &supported_atoms)) { 1233 &supported_atoms)) {
1237 return false; 1234 return false;
1238 } 1235 }
1239 1236
1240 return std::find(supported_atoms.begin(), supported_atoms.end(), atom) != 1237 return base::ContainsValue(supported_atoms, atom);
1241 supported_atoms.end();
1242 } 1238 }
1243 1239
1244 XRefcountedMemory::XRefcountedMemory(unsigned char* x11_data, size_t length) 1240 XRefcountedMemory::XRefcountedMemory(unsigned char* x11_data, size_t length)
1245 : x11_data_(length ? x11_data : nullptr), length_(length) { 1241 : x11_data_(length ? x11_data : nullptr), length_(length) {
1246 } 1242 }
1247 1243
1248 const unsigned char* XRefcountedMemory::front() const { 1244 const unsigned char* XRefcountedMemory::front() const {
1249 return x11_data_.get(); 1245 return x11_data_.get();
1250 } 1246 }
1251 1247
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 visual_info.visual, AllocNone); 1477 visual_info.visual, AllocNone);
1482 } 1478 }
1483 return colormap_; 1479 return colormap_;
1484 } 1480 }
1485 1481
1486 // ---------------------------------------------------------------------------- 1482 // ----------------------------------------------------------------------------
1487 // End of x11_util_internal.h 1483 // End of x11_util_internal.h
1488 1484
1489 1485
1490 } // namespace ui 1486 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/x/selection_utils.cc ('k') | ui/views/layout/grid_layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698