Closed Bug 452787 Opened 16 years ago Closed 16 years ago

Couldn't drag elements which contain text or it is difficult for empty elements

Categories

(Core :: DOM: Copy & Paste and Drag & Drop, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: laurent, Assigned: enndeakin)

References

(Regressed 1 open bug)

Details

Attachments

(2 files, 1 obsolete file)

With the new HTML5 drag and drop API, I found an issue: 

- if a div is draggable, the drag cannot start if it contains text.
- If it is empty, we should first click on it (by pushing and releasing the mouse button), and then we can begin a drag.
- If the div have the -moz-user-select:none;, all works as expected.

Look at the given html page to see this behaviors.
Flags: blocking1.9.1?
This patch checks the draggable attribute within the mouse down for selection handling.
Attachment #336138 - Flags: superreview?(roc)
Attachment #336138 - Flags: review?(Olli.Pettay)
Comment on attachment 336138 [details] [diff] [review]
allow dragging within a selection

> // static
> PRBool
>+nsContentUtils::ContentIsDraggable(nsIContent* aContent)
>+{
>+  nsCOMPtr<nsIDOMNSHTMLElement> htmlElement = do_QueryInterface(aContent);
>+  if (htmlElement) {
>+    PRBool draggable = PR_FALSE;
>+    htmlElement->GetDraggable(&draggable);
>+    if (draggable)
>+      return PR_TRUE;
>+  }
>+
>+  // special handling for content area image and link dragging
>+  return IsDraggableImage(aContent) || IsDraggableLink(aContent);
>+}
What if image or link has dragable="false", should this return PR_FALSE in that case?
nsHTMLImageElement and nsHTMLAnchorElement have their own implementation for ::GetDraggable.
> What if image or link has dragable="false", should this return PR_FALSE in that
> case?

Such as:

nsCOMPtr<nsIDOMNSHTMLElement> htmlElement = do_QueryInterface(aContent);
if (htmlElement) {
  PRBool draggable = PR_FALSE;
  htmlElement->GetDraggable(&draggable);
  if (draggable)
    return PR_TRUE;

  if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::draggable,
                            nsGkAtoms::_false, eIgnoreCase)
    return PR_FALSE;
}

?
Um, I wasn't CC'd to this bug - sorry didn't notice the comment.

But yes, something like that if you can't find any better way.
Attached patch updated patchSplinter Review
Attachment #336138 - Attachment is obsolete: true
Attachment #337086 - Flags: superreview?(roc)
Attachment #337086 - Flags: review?(Olli.Pettay)
Attachment #336138 - Flags: superreview?(roc)
Attachment #336138 - Flags: review?(Olli.Pettay)
Attachment #337086 - Flags: review?(Olli.Pettay) → review+
Attachment #337086 - Flags: superreview?(roc) → superreview+
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Flags: blocking1.9.1? → in-testsuite+
Regressions: 739071
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: