Bug 732733 - Resize drag image relative to the available screensize. r=jimm

This commit is contained in:
Moritz Brunner
2016-05-13 06:48:00 -04:00
parent faec00bb2f
commit 356b295e65
3 changed files with 74 additions and 19 deletions

View File

@@ -595,7 +595,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode,
if (mSelection) {
nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y);
*aSurface = presShell->RenderSelection(mSelection, pnt, aScreenDragRect,
mImage ? 0 : nsIPresShell::RENDER_AUTO_SCALE);
mImage ? 0 : nsIPresShell::RENDER_AUTO_SCALE);
return NS_OK;
}
@@ -631,14 +631,40 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode,
if (!mDragPopup) {
// otherwise, just draw the node
nsIntRegion clipRegion;
uint32_t renderFlags = mImage ? 0 : nsIPresShell::RENDER_AUTO_SCALE;
if (aRegion) {
aRegion->GetRegion(&clipRegion);
}
if (renderFlags) {
nsCOMPtr<nsIDOMNode> child;
nsCOMPtr<nsIDOMNodeList> childList;
uint32_t length;
uint32_t count = 0;
nsAutoString childNodeName;
if (NS_SUCCEEDED(dragNode->GetChildNodes(getter_AddRefs(childList))) &&
NS_SUCCEEDED(childList->GetLength(&length))) {
// check every childnode for being a img-tag
while (count < length) {
if (NS_FAILED(childList->Item(count, getter_AddRefs(child))) ||
NS_FAILED(child->GetNodeName(childNodeName))) {
break;
}
// here the node is checked for being a img-tag
if (childNodeName.LowerCaseEqualsLiteral("img")) {
// if the dragnnode contains a image, set RENDER_IS_IMAGE flag
renderFlags = renderFlags | nsIPresShell::RENDER_IS_IMAGE;
break;
}
count++;
}
}
}
nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y);
*aSurface = presShell->RenderNode(dragNode, aRegion ? &clipRegion : nullptr,
pnt, aScreenDragRect,
mImage ? 0 : nsIPresShell::RENDER_AUTO_SCALE);
pnt, aScreenDragRect,
renderFlags);
}
// if an image was specified, reposition the drag rectangle to