Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // Many of these functions are based on those found in | 5 // Many of these functions are based on those found in |
| 6 // webkit/port/platform/PasteboardWin.cpp | 6 // webkit/port/platform/PasteboardWin.cpp |
| 7 | 7 |
| 8 #include "ui/base/clipboard/clipboard_win.h" | 8 #include "ui/base/clipboard/clipboard_win.h" |
| 9 | 9 |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 return; | 561 return; |
| 562 | 562 |
| 563 if (start_index < html_start || end_index < start_index) | 563 if (start_index < html_start || end_index < start_index) |
| 564 return; | 564 return; |
| 565 | 565 |
| 566 std::vector<size_t> offsets; | 566 std::vector<size_t> offsets; |
| 567 offsets.push_back(start_index - html_start); | 567 offsets.push_back(start_index - html_start); |
| 568 offsets.push_back(end_index - html_start); | 568 offsets.push_back(end_index - html_start); |
| 569 markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start, | 569 markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start, |
| 570 &offsets)); | 570 &offsets)); |
| 571 *fragment_start = base::checked_cast<uint32_t>(offsets[0]); | 571 // Ensure the Fragment points within the string; see https://crbug.com/607181. |
| 572 *fragment_end = base::checked_cast<uint32_t>(offsets[1]); | 572 size_t markup_end = markup->length(); |
| 573 if (markup_end > 0) | |
| 574 markup_end--; | |
|
dcheng
2017/04/26 00:42:08
Why do we need to adjust this? Microsoft's example
elawrence
2017/04/26 15:11:22
Indeed, testing indicates that the indexes do work
| |
| 575 *fragment_end = | |
| 576 base::checked_cast<uint32_t>(std::min(offsets[1], markup_end)); | |
| 577 *fragment_start = | |
| 578 std::min(*fragment_end, | |
| 579 base::checked_cast<uint32_t>(std::min(offsets[0], markup_end))); | |
| 573 } | 580 } |
| 574 | 581 |
| 575 void ClipboardWin::ReadRTF(ClipboardType type, std::string* result) const { | 582 void ClipboardWin::ReadRTF(ClipboardType type, std::string* result) const { |
| 576 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 583 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
| 577 | 584 |
| 578 ReadData(GetRtfFormatType(), result); | 585 ReadData(GetRtfFormatType(), result); |
| 579 } | 586 } |
| 580 | 587 |
| 581 SkBitmap ClipboardWin::ReadImage(ClipboardType type) const { | 588 SkBitmap ClipboardWin::ReadImage(ClipboardType type) const { |
| 582 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); | 589 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 898 if (!clipboard_owner_) | 905 if (!clipboard_owner_) |
| 899 return NULL; | 906 return NULL; |
| 900 | 907 |
| 901 if (clipboard_owner_->hwnd() == NULL) | 908 if (clipboard_owner_->hwnd() == NULL) |
| 902 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc)); | 909 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc)); |
| 903 | 910 |
| 904 return clipboard_owner_->hwnd(); | 911 return clipboard_owner_->hwnd(); |
| 905 } | 912 } |
| 906 | 913 |
| 907 } // namespace ui | 914 } // namespace ui |
| OLD | NEW |