Upload upstream chromium 73.0.3683.0
[platform/framework/web/chromium-efl.git] / printing / page_range.cc
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 "printing/page_range.h"
6
7 #include <stddef.h>
8
9 #include <set>
10
11 namespace printing {
12
13 // static
14 std::vector<int> PageRange::GetPages(const PageRanges& ranges) {
15   // TODO(vitalybuka): crbug.com/95548 Remove this method as part fix.
16   std::set<int> pages;
17   for (const PageRange& range : ranges) {
18     // Ranges are inclusive.
19     for (int i = range.from; i <= range.to; ++i) {
20       static constexpr size_t kMaxNumberOfPages = 100000;
21       pages.insert(i);
22       if (pages.size() >= kMaxNumberOfPages)
23         return std::vector<int>(pages.begin(), pages.end());
24     }
25   }
26   return std::vector<int>(pages.begin(), pages.end());
27 }
28
29 }  // namespace printing