2009-07-13 Erik Arvidsson <arv@chromium.org>
Reviewed by Darin Adler and Maciej Stachowiak.
Implement HTML5 draggable
https://bugs.webkit.org/show_bug.cgi?id=26262
This adds support for the HTML5 draggable attribute and its DOM binding. It maps the draggable property
to the CSS properties -webkit-user-drag and -webkit-user-select respectively.
Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#the-draggable-attribute
Test: fast/html/draggable.html
* css/html.css:
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::draggable):
* html/HTMLAnchorElement.h:
* html/HTMLAttributeNames.in:
* html/HTMLElement.cpp:
(WebCore::HTMLElement::draggable):
(WebCore::HTMLElement::setDraggable):
* html/HTMLElement.h:
* html/HTMLElement.idl:
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::draggable):
* html/HTMLImageElement.h:
LayoutTests:
2009-07-13 Erik Arvidsson <arv@chromium.org>
Reviewed by Darin Adler and Maciej Stachowiak.
Implement HTML5 draggable
https://bugs.webkit.org/show_bug.cgi?id=26262
This adds support for the HTML5 draggable attribute and its DOM binding. It maps the draggable property
to the CSS properties -webkit-user-drag and -webkit-user-select respectively.
Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#the-draggable-attribute
* fast/html/draggable-expected.txt: Added.
* fast/html/draggable.html: Added.
* fast/html/resources: Added.
* fast/html/resources/images: Added.
* fast/html/resources/images/lime.png: Added.
* fast/dom/resources/domListEnumeration.js: Updated.
* fast/dom/domListEnumeration-expected.txt: Updated.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45851
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2009-07-13 Erik Arvidsson <arv@chromium.org>
+
+ Reviewed by Darin Adler and Maciej Stachowiak.
+
+ Implement HTML5 draggable
+ https://bugs.webkit.org/show_bug.cgi?id=26262
+
+ This adds support for the HTML5 draggable attribute and its DOM binding. It maps the draggable property
+ to the CSS properties -webkit-user-drag and -webkit-user-select respectively.
+
+ Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#the-draggable-attribute
+
+ * fast/html/draggable-expected.txt: Added.
+ * fast/html/draggable.html: Added.
+ * fast/html/resources: Added.
+ * fast/html/resources/images: Added.
+ * fast/html/resources/images/lime.png: Added.
+
+ * fast/dom/resources/domListEnumeration.js: Updated.
+ * fast/dom/domListEnumeration-expected.txt: Updated.
+
2009-07-13 Simon Fraser <simon.fraser@apple.com>
Reviewed by Dan Bernstein.
PASS resultArray[2].item is namedNodeMap.item(2)
[object HTMLFormElement]
-PASS resultArray.length is 130
+PASS resultArray.length is 131
PASS resultArray[0].i is '0'
PASS resultArray[0].item is document.getElementsByTagName('select')[0]
PASS resultArray[1].i is '1'
PASS resultArray[2].item is document.getElementsByTagName('select')[2]
[object HTMLSelectElement]
-PASS resultArray.length is 135
+PASS resultArray.length is 136
PASS resultArray[0].i is '0'
PASS resultArray[0].item is document.getElementsByTagName('option')[0]
PASS resultArray[1].i is '1'
// HTMLFormElement
var htmlFormElement = document.getElementsByTagName('form')[0];
resultArray = iterateList(htmlFormElement);
-shouldBe("resultArray.length", "130");
+shouldBe("resultArray.length", "131");
shouldBe("resultArray[0].i", "'0'");
shouldBe("resultArray[0].item", "document.getElementsByTagName('select')[0]");
shouldBe("resultArray[1].i", "'1'");
// HTMLSelectElement
var htmlSelectElement = document.getElementsByTagName('select')[0];
resultArray = iterateList(htmlSelectElement);
-shouldBe("resultArray.length", "135");
+shouldBe("resultArray.length", "136");
shouldBe("resultArray[0].i", "'0'");
shouldBe("resultArray[0].item", "document.getElementsByTagName('option')[0]");
shouldBe("resultArray[1].i", "'1'");
--- /dev/null
+Intrinsic
+
+ webkit.org <a no href> <span>
+draggable attr set to true
+
+ webkit.org <a no href> <span>
+draggable attr set to false
+
+ webkit.org <a no href> <span>
+draggable attr set to maybe
+
+ webkit.org <a no href> <span>
+draggable dom prop set to true
+
+ webkit.org <a no href> <span>
+draggable dom prop set to false
+
+ webkit.org <a no href> <span>
+dom - attr
+----------
+true - null
+true - null
+false - null
+false - null
+true - true
+true - true
+true - true
+true - true
+false - false
+false - false
+false - false
+false - false
+true - maybe
+true - maybe
+false - maybe
+false - maybe
+true - true
+true - true
+true - true
+true - true
+false - false
+false - false
+false - false
+false - false
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<title>HTML5 Draggable</title>
+<style>
+
+[draggable="true"] {
+ outline: 1px solid lime;
+}
+
+[draggable="false"] {
+ outline: 1px solid pink;
+}
+
+</style>
+<script>
+
+function test()
+{
+ var elements = document.querySelectorAll('body > :not(h2)');
+
+ for (var i = 16; i < 24; i++) {
+ elements[i].draggable = i < 20;
+ }
+
+ var s = 'dom - attr\n----------\n';
+ for (var i = 0; i < elements.length; i++) {
+ s += elements[i].draggable + ' - ' + elements[i].getAttribute('draggable') + '\n';
+ }
+
+ var pre = document.createElement('pre');
+ pre.textContent = s;
+ document.body.appendChild(pre);
+
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+};
+
+document.ondragstart = function(e)
+{
+ e.dataTransfer.setData('Text', e.target.textContent || e.target.src || e.target.href);
+};
+
+</script>
+</head>
+<body onload="test()">
+
+<h2>Intrinsic</h2>
+
+<img src="resources/images/lime.png">
+<a href="http://webgkit.org">webkit.org</a>
+<a><a no href></a>
+<span><span></span>
+
+<h2>draggable attr set to true</h2>
+
+<img src="resources/images/lime.png" draggable="true">
+<a href="http://webgkit.org" draggable="true">webkit.org</a>
+<a draggable="true"><a no href></a>
+<span draggable="true"><span></span>
+
+<h2>draggable attr set to false</h2>
+
+<img src="resources/images/lime.png" draggable="false">
+<a href="http://webgkit.org" draggable="false">webkit.org</a>
+<a draggable="false"><a no href></a>
+<span draggable="false"><span></span>
+
+<h2>draggable attr set to maybe</h2>
+
+<img src="resources/images/lime.png" draggable="maybe">
+<a href="http://webgkit.org" draggable="maybe">webkit.org</a>
+<a draggable="maybe"><a no href></a>
+<span draggable="maybe"><span></span>
+
+<h2>draggable dom prop set to true</h2>
+
+<img src="resources/images/lime.png">
+<a href="http://webgkit.org">webkit.org</a>
+<a><a no href></a>
+<span><span></span>
+
+<h2>draggable dom prop set to false</h2>
+
+<img src="resources/images/lime.png">
+<a href="http://webgkit.org">webkit.org</a>
+<a><a no href></a>
+<span><span></span>
+
+</body>
+</html>
+2009-07-13 Erik Arvidsson <arv@chromium.org>
+
+ Reviewed by Darin Adler and Maciej Stachowiak.
+
+ Implement HTML5 draggable
+ https://bugs.webkit.org/show_bug.cgi?id=26262
+
+ This adds support for the HTML5 draggable attribute and its DOM binding. It maps the draggable property
+ to the CSS properties -webkit-user-drag and -webkit-user-select respectively.
+
+ Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#the-draggable-attribute
+
+ Test: fast/html/draggable.html
+
+ * css/html.css:
+ * html/HTMLAnchorElement.cpp:
+ (WebCore::HTMLAnchorElement::draggable):
+ * html/HTMLAnchorElement.h:
+ * html/HTMLAttributeNames.in:
+ * html/HTMLElement.cpp:
+ (WebCore::HTMLElement::draggable):
+ (WebCore::HTMLElement::setDraggable):
+ * html/HTMLElement.h:
+ * html/HTMLElement.idl:
+ * html/HTMLImageElement.cpp:
+ (WebCore::HTMLImageElement::draggable):
+ * html/HTMLImageElement.h:
+
2009-07-13 Simon Fraser <simon.fraser@apple.com>
Reviewed by Dan Bernstein.
setAttribute(coordsAttr, value);
}
+bool HTMLAnchorElement::draggable() const
+{
+ // Should be draggable if we have an href attribute.
+ const AtomicString& value = getAttribute(draggableAttr);
+ if (equalIgnoringCase(value, "true"))
+ return true;
+ if (equalIgnoringCase(value, "false"))
+ return false;
+ return hasAttribute(hrefAttr);
+}
+
KURL HTMLAnchorElement::href() const
{
return document()->completeURL(getAttribute(hrefAttr));
const AtomicString& coords() const;
void setCoords(const AtomicString&);
+ virtual bool draggable() const;
+
KURL href() const;
void setHref(const AtomicString&);
dir
direction
disabled
+draggable
enctype
end
expanded
} else if (attr->name() == dirAttr) {
addCSSProperty(attr, CSSPropertyDirection, attr->value());
addCSSProperty(attr, CSSPropertyUnicodeBidi, hasLocalName(bdoTag) ? CSSValueBidiOverride : CSSValueEmbed);
+ } else if (attr->name() == draggableAttr) {
+ const AtomicString& value = attr->value();
+ if (equalIgnoringCase(value, "true")) {
+ addCSSProperty(attr, CSSPropertyWebkitUserDrag, CSSValueElement);
+ addCSSProperty(attr, CSSPropertyWebkitUserSelect, CSSValueNone);
+ } else if (equalIgnoringCase(value, "false"))
+ addCSSProperty(attr, CSSPropertyWebkitUserDrag, CSSValueNone);
}
// standard events
else if (attr->name() == onclickAttr) {
setAttribute(contenteditableAttr, enabled.isEmpty() ? "true" : enabled);
}
+bool HTMLElement::draggable() const
+{
+ return equalIgnoringCase(getAttribute(draggableAttr), "true");
+}
+
+void HTMLElement::setDraggable(bool value)
+{
+ setAttribute(draggableAttr, value ? "true" : "false");
+}
+
void HTMLElement::click()
{
dispatchSimulatedClick(0, false, false);
virtual void setContentEditable(MappedAttribute*);
virtual void setContentEditable(const String&);
+ virtual bool draggable() const;
+ void setDraggable(bool);
+
void click();
virtual void accessKeyAction(bool sendToAnyElement);
attribute [ConvertNullToNullString, Reflect=class] DOMString className;
attribute long tabIndex;
+ attribute boolean draggable;
// Extensions
attribute [ConvertNullToNullString] DOMString innerHTML
setAttribute(borderAttr, value);
}
+bool HTMLImageElement::draggable() const
+{
+ // Image elements are draggable by default.
+ return !equalIgnoringCase(getAttribute(draggableAttr), "false");
+}
+
void HTMLImageElement::setHeight(int value)
{
setAttribute(heightAttr, String::number(value));
String border() const;
void setBorder(const String&);
+ virtual bool draggable() const;
+
void setHeight(int);
int hspace() const;