This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 972
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #10936 Test Plan: 1. go to about:bookmarks, try dragging and dropping some bookmarks. it should work. 2. drag a tab to change its position. it should work.
- Loading branch information
1 parent
0cb884d
commit 10f2ebf
Showing
3 changed files
with
48 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
function hasBraveDragData (dataTransfer) { | ||
if (!dataTransfer || !dataTransfer.types) { | ||
return false | ||
} | ||
for (let i = 0; i < dataTransfer.types.length; i++) { | ||
let type = dataTransfer.types[i] | ||
if (type && type.startsWith('application/x-brave-')) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
function blockDndData (e) { | ||
if (hasBraveDragData(e.dataTransfer)) { | ||
// Block drag data from the Brave UI | ||
try { | ||
e.dataTransfer.dropEffect = 'none' | ||
} catch (e) {} | ||
e.preventDefault() | ||
e.stopPropagation() | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
window.addEventListener('dragover', blockDndData, true) | ||
window.addEventListener('dragenter', blockDndData, true) | ||
window.addEventListener('dragleave', blockDndData, true) | ||
window.addEventListener('drop', blockDndData, true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters