WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
26262
Implement HTML5 draggable
https://bugs.webkit.org/show_bug.cgi?id=26262
Summary
Implement HTML5 draggable
Erik Arvidsson
Reported
2009-06-08 16:17:07 PDT
Currently, to drag something in webkit it has to be a link or an image (or text selection). HTML5 defines a draggable attribute that allows any element to be draggable.
http://www.whatwg.org/specs/web-apps/current-work/#the-draggable-attribute
Attachments
Patch
(10.35 KB, patch)
2009-07-02 18:45 PDT
,
Erik Arvidsson
mjs
: review-
Details
Formatted Diff
Diff
Uses parseMappedAttribute instead of the user style sheet
(11.20 KB, patch)
2009-07-04 00:09 PDT
,
Erik Arvidsson
darin
: review-
Details
Formatted Diff
Diff
Fixed Darin's comments.
(11.09 KB, patch)
2009-07-04 20:56 PDT
,
Erik Arvidsson
mjs
: review+
Details
Formatted Diff
Diff
Style nits fixed
(11.08 KB, patch)
2009-07-06 14:32 PDT
,
Erik Arvidsson
darin
: review+
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Erik Arvidsson
Comment 1
2009-06-30 18:43:55 PDT
This is actually trivial. All we need to do is add the following to the ua style sheet. [draggable] { -webkit-user-drag: element; -webkit-user-select: none; }
Erik Arvidsson
Comment 2
2009-07-02 18:45:05 PDT
Created
attachment 32215
[details]
Patch
Sam Weinig
Comment 3
2009-07-02 20:57:37 PDT
Comment on
attachment 32215
[details]
Patch The style part should probably be implemented in parseMappedAttribute instead of the ua stylesheet.
Maciej Stachowiak
Comment 4
2009-07-03 00:57:06 PDT
Comment on
attachment 32215
[details]
Patch Hyatt confirms that "draggable" should be implemented in code via parseMappedAttribute rather than in the UA stylesheet, because in our CSS implementation it's fairly inefficient to have an attribute selector that's not scoped to particular tags. I believe HTMLElement::parseMappedAttribute would be the right place. r- to fix this, patch otherwise looks good to me.
Erik Arvidsson
Comment 5
2009-07-04 00:09:42 PDT
Created
attachment 32253
[details]
Uses parseMappedAttribute instead of the user style sheet I also did some testing with Firefox 3.5 and it ignores the case of true and false so I made all the checks ignore the case. Also, added code to correctly handle when the attribute is set to something other than true or false and updated the test to reflect that.
Erik Arvidsson
Comment 6
2009-07-04 00:14:05 PDT
(In reply to
comment #4
)
> (From update of
attachment 32215
[details]
) > Hyatt confirms that "draggable" should be implemented in code via > parseMappedAttribute rather than in the UA stylesheet, because in our CSS > implementation it's fairly inefficient to have an attribute selector that's not > scoped to particular tags. I believe HTMLElement::parseMappedAttribute would be > the right place.
Thanks for the hint about parseMappedAttribute. It makes total sense to me now. I'll try to keep that in mind any time I think I need to touch the UA stylesheet.
Darin Adler
Comment 7
2009-07-04 11:23:12 PDT
Comment on
attachment 32253
[details]
Uses parseMappedAttribute instead of the user style sheet
> + if (equalIgnoringCase(getAttribute(draggableAttr), "true")) > + return true; > + if (equalIgnoringCase(getAttribute(draggableAttr), "false")) > + return false;
It would be more efficient to call getAttribute only once. A local variable of type const AtomicString& can be used to hold the attribute value.
> +void HTMLElement::setDraggable(MappedAttribute* attr)
I think it would be best to give this a different name, rather than using overloading. Perhaps it could be called parseDraggableAttribute.
> +void HTMLElement::setDraggable(const bool& value)
This should just be bool, not const bool&.
> + void setDraggable(MappedAttribute*);
This newly-added member function should be private. This looks good, but I'm going to say review- since I'd really like to see the name and visibility of the setDraggable function that takes an attribute changed.
Erik Arvidsson
Comment 8
2009-07-04 20:55:15 PDT
(In reply to
comment #7
) Thanks for the review Darin
> (From update of
attachment 32253
[details]
) > > + if (equalIgnoringCase(getAttribute(draggableAttr), "true")) > > + return true; > > + if (equalIgnoringCase(getAttribute(draggableAttr), "false")) > > + return false; > > It would be more efficient to call getAttribute only once. A local variable of > type const AtomicString& can be used to hold the attribute value.
Done.
> > +void HTMLElement::setDraggable(MappedAttribute* attr) > > I think it would be best to give this a different name, rather than using > overloading. Perhaps it could be called parseDraggableAttribute.
I ended up inlining it in parseMappedAttribute since the logic is pretty simple and other cases are more complicated already.
> > +void HTMLElement::setDraggable(const bool& value) > > This should just be bool, not const bool&.
Done.
> > + void setDraggable(MappedAttribute*); > > This newly-added member function should be private. > > This looks good, but I'm going to say review- since I'd really like to see the > name and visibility of the setDraggable function that takes an attribute > changed.
Another patch coming in a sec
Erik Arvidsson
Comment 9
2009-07-04 20:56:43 PDT
Created
attachment 32266
[details]
Fixed Darin's comments.
Maciej Stachowiak
Comment 10
2009-07-05 04:22:30 PDT
Comment on
attachment 32266
[details]
Fixed Darin's comments. Looks to me like the comments are all addressed, and I do not see any new issues. Thanks for the contribution and the several revised versions! r=me
Eric Seidel (no email)
Comment 11
2009-07-06 14:14:39 PDT
Comment on
attachment 32266
[details]
Fixed Darin's comments. There are style issues in this patch: Spacing: + for (var i = 16; i < 24; i++) { + elements[i].draggable = i < 20; + } Extra { 151 } else if (equalIgnoringCase(value, "false")) { 152 addCSSProperty(attr, CSSPropertyWebkitUserDrag, CSSValueNone); 153 } Extra space: 357 if (equalIgnoringCase(value , "true")) Those certainly could be corrected when landing. But having them here, makes this hard to land automatically.
Erik Arvidsson
Comment 12
2009-07-06 14:21:19 PDT
(In reply to
comment #11
)
> (From update of
attachment 32266
[details]
) > There are style issues in this patch: > > Spacing: > + for (var i = 16; i < 24; i++) { > + elements[i].draggable = i < 20; > + } > > Extra { > 151 } else if (equalIgnoringCase(value, "false")) { > 152 addCSSProperty(attr, CSSPropertyWebkitUserDrag, CSSValueNone); > 153 } > > Extra space: > 357 if (equalIgnoringCase(value , "true")) > > Those certainly could be corrected when landing. But having them here, makes > this hard to land automatically.
I'll just fix them and ask for another review.
Erik Arvidsson
Comment 13
2009-07-06 14:32:27 PDT
Created
attachment 32327
[details]
Style nits fixed
Erik Arvidsson
Comment 14
2009-07-13 16:17:05 PDT
Can anyone submit this for me? I do not have commit rights.
Darin Adler
Comment 15
2009-07-13 17:42:20 PDT
This changes the result of fast/dom/domListEnumeration.html but the patch doesn't include new results. I had to fix that myself. I'm concerned, because this should have showed up when you ran the regression tests yourself.
Erik Arvidsson
Comment 16
2009-07-13 17:50:00 PDT
(In reply to
comment #15
)
> This changes the result of fast/dom/domListEnumeration.html but the patch > doesn't include new results. I had to fix that myself. I'm concerned, because > this should have showed up when you ran the regression tests yourself.
My bad. Feel free to r- and I'll look into it
Darin Adler
Comment 17
2009-07-13 18:06:13 PDT
http://trac.webkit.org/changeset/45851
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug