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

Side by Side Diff: ui/base/clipboard/clipboard_win.cc

Issue 8429022: Adjust fragment indices appropriately when pasting HTML on Windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month 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 | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 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 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.h" 8 #include "ui/base/clipboard/clipboard.h"
9 9
10 #include <shlobj.h> 10 #include <shlobj.h>
11 #include <shellapi.h> 11 #include <shellapi.h>
12 12
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/shared_memory.h" 16 #include "base/shared_memory.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/string_number_conversions.h" 19 #include "base/string_number_conversions.h"
20 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
21 #include "base/utf_offset_string_conversions.h"
tony 2011/10/31 22:09:22 Nit: alphabetize
dcheng 2011/10/31 23:41:44 Done.
21 #include "base/win/scoped_gdi_object.h" 22 #include "base/win/scoped_gdi_object.h"
22 #include "base/win/scoped_hdc.h" 23 #include "base/win/scoped_hdc.h"
23 #include "base/win/wrapped_window_proc.h" 24 #include "base/win/wrapped_window_proc.h"
24 #include "third_party/skia/include/core/SkBitmap.h" 25 #include "third_party/skia/include/core/SkBitmap.h"
25 #include "ui/base/clipboard/clipboard_util_win.h" 26 #include "ui/base/clipboard/clipboard_util_win.h"
26 #include "ui/gfx/canvas_skia.h" 27 #include "ui/gfx/canvas_skia.h"
27 #include "ui/gfx/size.h" 28 #include "ui/gfx/size.h"
28 29
29 namespace ui { 30 namespace ui {
30 31
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (start_index == std::string::npos || 460 if (start_index == std::string::npos ||
460 end_index == std::string::npos || 461 end_index == std::string::npos ||
461 html_start == std::string::npos) 462 html_start == std::string::npos)
462 return; 463 return;
463 464
464 DCHECK(start_index - html_start >= 0); 465 DCHECK(start_index - html_start >= 0);
465 DCHECK(end_index - html_start >= 0); 466 DCHECK(end_index - html_start >= 0);
466 DCHECK((start_index - html_start) <= kuint32max); 467 DCHECK((start_index - html_start) <= kuint32max);
467 DCHECK((end_index - html_start) <= kuint32max); 468 DCHECK((end_index - html_start) <= kuint32max);
468 469
469 markup->assign(UTF8ToWide(cf_html.data() + html_start)); 470 std::vector<size_t> offsets;
470 *fragment_start = static_cast<uint32>(start_index - html_start); 471 offsets.push_back(start_index - html_start);
471 *fragment_end = static_cast<uint32>(end_index - html_start); 472 offsets.push_back(end_index - html_start);
473 markup->assign(UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start,
474 &offsets));
475 *fragment_start = static_cast<uint32>(offsets[0]);
476 *fragment_end = static_cast<uint32>(offsets[1]);
472 } 477 }
473 478
474 SkBitmap Clipboard::ReadImage(Buffer buffer) const { 479 SkBitmap Clipboard::ReadImage(Buffer buffer) const {
475 DCHECK_EQ(buffer, BUFFER_STANDARD); 480 DCHECK_EQ(buffer, BUFFER_STANDARD);
476 481
477 // Acquire the clipboard. 482 // Acquire the clipboard.
478 ScopedClipboard clipboard; 483 ScopedClipboard clipboard;
479 if (!clipboard.Acquire(GetClipboardWindow())) 484 if (!clipboard.Acquire(GetClipboardWindow()))
480 return SkBitmap(); 485 return SkBitmap();
481 486
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass", 741 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass",
737 L"ClipboardOwnerWindow", 742 L"ClipboardOwnerWindow",
738 0, 0, 0, 0, 0, 743 0, 0, 0, 0, 0,
739 HWND_MESSAGE, 744 HWND_MESSAGE,
740 0, 0, 0); 745 0, 0, 0);
741 } 746 }
742 return clipboard_owner_; 747 return clipboard_owner_;
743 } 748 }
744 749
745 } // namespace ui 750 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698