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

Side by Side Diff: base/win/enum_variant.cc

Issue 8588036: Improve support for multiselect list box accessibility on Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/win/enum_variant.h"
6
7 #include "base/logging.h"
8
9 namespace base {
10 namespace win {
11
12 EnumVariant::EnumVariant(unsigned long count)
13 : count_(count) {
14 items_.reset(new VARIANT[count_]);
M-A Ruel 2011/11/29 20:28:32 Why not do it in the member constructor?
dmazzoni 2011/11/29 21:55:00 You're right, done.
15 current_index_ = 0;
16 }
17
18 EnumVariant::~EnumVariant() {
19 }
20
21 VARIANT* EnumVariant::ItemAt(unsigned long index) {
22 DCHECK(index < count_);
23 return &items_[index];
24 }
25
26 ULONG STDMETHODCALLTYPE EnumVariant::AddRef() {
27 return IUnknownImpl::AddRef();
28 }
29
30 ULONG STDMETHODCALLTYPE EnumVariant::Release() {
31 return IUnknownImpl::Release();
32 }
33
34 STDMETHODIMP EnumVariant::QueryInterface(REFIID riid, void** ppv) {
35 if (riid == IID_IEnumVARIANT) {
36 *ppv = this;
M-A Ruel 2011/11/29 20:28:32 In theory, you need to static_cast<IEnumVariant*>(
dmazzoni 2011/11/29 21:55:00 Done.
37 AddRef();
38 return S_OK;
39 }
40
41 return IUnknownImpl::QueryInterface(riid, ppv);
42 }
43
44 STDMETHODIMP EnumVariant::Next(ULONG requested_count,
45 VARIANT* out_elements,
46 ULONG* out_elements_received) {
47 unsigned long count = requested_count;
M-A Ruel 2011/11/29 20:28:32 unsigned long count = min(requested_count, count_
dmazzoni 2011/11/29 21:55:00 Done.
48 if (current_index_ + count > count_)
49 count = count_ - current_index_;
50
51 for (unsigned long i = 0; i < count; ++i)
52 out_elements[i] = items_[current_index_ + i];
53 current_index_ += count;
54 *out_elements_received = count;
55
56 return (count == requested_count ? S_OK : S_FALSE);
57 }
58
59 STDMETHODIMP EnumVariant::Skip(ULONG skip_count) {
60 unsigned long count = skip_count;
61 if (current_index_ + count > count_)
62 count = count_ - current_index_;
63
64 current_index_ += count;
65 return (count == skip_count ? S_OK : S_FALSE);
66 }
67
68 STDMETHODIMP EnumVariant::Reset() {
69 current_index_ = 0;
70 return S_OK;
71 }
72
73 STDMETHODIMP EnumVariant::Clone(IEnumVARIANT** out_cloned_object) {
74 EnumVariant* other = new EnumVariant(count_);
75 for (unsigned long i = 0; i < count_; ++i)
76 *other->ItemAt(i) = items_[i];
M-A Ruel 2011/11/29 20:28:32 Why is this better than a memcpy or just implement
dmazzoni 2011/11/29 21:55:00 Switched to memcpy.
77 other->Skip(current_index_);
78 *out_cloned_object = other;
79 return S_OK;
80 }
81
82 } // namespace win
83 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698