summaryrefslogtreecommitdiffstats
path: root/WebCore/html
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/html')
-rw-r--r--WebCore/html/CollectionType.h1
-rw-r--r--WebCore/html/HTMLAnchorElement.cpp55
-rw-r--r--WebCore/html/HTMLAnchorElement.h8
-rw-r--r--WebCore/html/HTMLAppletElement.cpp9
-rw-r--r--WebCore/html/HTMLAppletElement.h7
-rw-r--r--WebCore/html/HTMLAreaElement.cpp15
-rw-r--r--WebCore/html/HTMLAreaElement.h10
-rw-r--r--WebCore/html/HTMLAttributeNames.in9
-rw-r--r--WebCore/html/HTMLBodyElement.cpp118
-rw-r--r--WebCore/html/HTMLBodyElement.h39
-rw-r--r--WebCore/html/HTMLBodyElement.idl12
-rw-r--r--WebCore/html/HTMLButtonElement.idl2
-rw-r--r--WebCore/html/HTMLCanvasElement.cpp65
-rw-r--r--WebCore/html/HTMLCanvasElement.h43
-rw-r--r--WebCore/html/HTMLCanvasElement.idl3
-rw-r--r--WebCore/html/HTMLCollection.cpp9
-rw-r--r--WebCore/html/HTMLDataListElement.cpp60
-rw-r--r--WebCore/html/HTMLDataListElement.h55
-rw-r--r--WebCore/html/HTMLDataListElement.idl38
-rw-r--r--WebCore/html/HTMLDocument.cpp6
-rw-r--r--WebCore/html/HTMLDocument.h10
-rw-r--r--WebCore/html/HTMLElement.cpp77
-rw-r--r--WebCore/html/HTMLElement.h67
-rw-r--r--WebCore/html/HTMLEmbedElement.cpp31
-rw-r--r--WebCore/html/HTMLEmbedElement.h16
-rw-r--r--WebCore/html/HTMLEmbedElement.idl12
-rw-r--r--WebCore/html/HTMLFieldSetElement.cpp4
-rw-r--r--WebCore/html/HTMLFieldSetElement.h2
-rw-r--r--WebCore/html/HTMLFieldSetElement.idl1
-rw-r--r--WebCore/html/HTMLFormControlElement.cpp190
-rw-r--r--WebCore/html/HTMLFormControlElement.h52
-rw-r--r--WebCore/html/HTMLFormElement.cpp46
-rw-r--r--WebCore/html/HTMLFormElement.h11
-rw-r--r--WebCore/html/HTMLFormElement.idl2
-rw-r--r--WebCore/html/HTMLFrameElement.cpp31
-rw-r--r--WebCore/html/HTMLFrameElement.h20
-rw-r--r--WebCore/html/HTMLFrameElement.idl14
-rw-r--r--WebCore/html/HTMLFrameElementBase.cpp93
-rw-r--r--WebCore/html/HTMLFrameElementBase.h54
-rw-r--r--WebCore/html/HTMLFrameOwnerElement.cpp4
-rw-r--r--WebCore/html/HTMLFrameOwnerElement.h24
-rw-r--r--WebCore/html/HTMLFrameSetElement.cpp114
-rw-r--r--WebCore/html/HTMLFrameSetElement.h44
-rw-r--r--WebCore/html/HTMLFrameSetElement.idl8
-rw-r--r--WebCore/html/HTMLIFrameElement.cpp41
-rw-r--r--WebCore/html/HTMLIFrameElement.h15
-rw-r--r--WebCore/html/HTMLIFrameElement.idl22
-rw-r--r--WebCore/html/HTMLImageElement.cpp50
-rw-r--r--WebCore/html/HTMLImageElement.h15
-rw-r--r--WebCore/html/HTMLImageLoader.cpp3
-rw-r--r--WebCore/html/HTMLInputElement.cpp340
-rw-r--r--WebCore/html/HTMLInputElement.h62
-rw-r--r--WebCore/html/HTMLInputElement.idl17
-rw-r--r--WebCore/html/HTMLIsIndexElement.cpp2
-rw-r--r--WebCore/html/HTMLKeygenElement.cpp2
-rw-r--r--WebCore/html/HTMLLegendElement.cpp4
-rw-r--r--WebCore/html/HTMLLegendElement.h2
-rw-r--r--WebCore/html/HTMLLinkElement.cpp47
-rw-r--r--WebCore/html/HTMLMediaElement.cpp318
-rw-r--r--WebCore/html/HTMLMediaElement.h20
-rw-r--r--WebCore/html/HTMLObjectElement.cpp139
-rw-r--r--WebCore/html/HTMLObjectElement.h73
-rw-r--r--WebCore/html/HTMLObjectElement.idl29
-rw-r--r--WebCore/html/HTMLOptGroupElement.cpp8
-rw-r--r--WebCore/html/HTMLOptGroupElement.h1
-rw-r--r--WebCore/html/HTMLOptionElement.cpp10
-rw-r--r--WebCore/html/HTMLOptionElement.h1
-rw-r--r--WebCore/html/HTMLParser.cpp8
-rw-r--r--WebCore/html/HTMLPlugInElement.cpp20
-rw-r--r--WebCore/html/HTMLPlugInElement.h43
-rw-r--r--WebCore/html/HTMLPlugInImageElement.h9
-rw-r--r--WebCore/html/HTMLScriptElement.cpp9
-rw-r--r--WebCore/html/HTMLSelectElement.idl1
-rw-r--r--WebCore/html/HTMLSourceElement.cpp3
-rw-r--r--WebCore/html/HTMLTagNames.in153
-rw-r--r--WebCore/html/HTMLTextAreaElement.cpp131
-rw-r--r--WebCore/html/HTMLTextAreaElement.h25
-rw-r--r--WebCore/html/HTMLTextAreaElement.idl5
-rw-r--r--WebCore/html/HTMLTokenizer.cpp26
-rw-r--r--WebCore/html/HTMLVideoElement.cpp13
-rw-r--r--WebCore/html/HTMLVideoElement.h2
-rw-r--r--WebCore/html/HTMLViewSourceDocument.cpp33
-rw-r--r--WebCore/html/HTMLViewSourceDocument.h23
-rw-r--r--WebCore/html/ValidityState.cpp56
-rw-r--r--WebCore/html/ValidityState.h10
-rw-r--r--WebCore/html/canvas/CanvasArray.cpp52
-rw-r--r--WebCore/html/canvas/CanvasArray.h67
-rw-r--r--WebCore/html/canvas/CanvasArray.idl32
-rw-r--r--WebCore/html/canvas/CanvasArrayBuffer.cpp57
-rw-r--r--WebCore/html/canvas/CanvasArrayBuffer.h51
-rw-r--r--WebCore/html/canvas/CanvasArrayBuffer.idl30
-rw-r--r--WebCore/html/canvas/CanvasBuffer.cpp53
-rw-r--r--WebCore/html/canvas/CanvasBuffer.h50
-rw-r--r--WebCore/html/canvas/CanvasBuffer.idl29
-rw-r--r--WebCore/html/canvas/CanvasByteArray.cpp77
-rw-r--r--WebCore/html/canvas/CanvasByteArray.h88
-rw-r--r--WebCore/html/canvas/CanvasByteArray.idl36
-rw-r--r--WebCore/html/canvas/CanvasFloatArray.cpp78
-rw-r--r--WebCore/html/canvas/CanvasFloatArray.h84
-rw-r--r--WebCore/html/canvas/CanvasFloatArray.idl36
-rw-r--r--WebCore/html/canvas/CanvasFramebuffer.cpp53
-rw-r--r--WebCore/html/canvas/CanvasFramebuffer.h50
-rw-r--r--WebCore/html/canvas/CanvasFramebuffer.idl29
-rw-r--r--WebCore/html/canvas/CanvasIntArray.cpp82
-rw-r--r--WebCore/html/canvas/CanvasIntArray.h86
-rw-r--r--WebCore/html/canvas/CanvasIntArray.idl36
-rw-r--r--WebCore/html/canvas/CanvasNumberArray.cpp47
-rw-r--r--WebCore/html/canvas/CanvasNumberArray.h55
-rw-r--r--WebCore/html/canvas/CanvasNumberArray.idl34
-rw-r--r--WebCore/html/canvas/CanvasObject.cpp69
-rw-r--r--WebCore/html/canvas/CanvasObject.h65
-rw-r--r--WebCore/html/canvas/CanvasPixelArray.h10
-rw-r--r--WebCore/html/canvas/CanvasPixelArray.idl2
-rw-r--r--WebCore/html/canvas/CanvasProgram.cpp53
-rw-r--r--WebCore/html/canvas/CanvasProgram.h50
-rw-r--r--WebCore/html/canvas/CanvasProgram.idl29
-rw-r--r--WebCore/html/canvas/CanvasRenderbuffer.cpp53
-rw-r--r--WebCore/html/canvas/CanvasRenderbuffer.h50
-rw-r--r--WebCore/html/canvas/CanvasRenderbuffer.idl29
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext.cpp48
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext.h55
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext.idl39
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext2D.cpp31
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext2D.h13
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext2D.idl7
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext3D.cpp1401
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext3D.h321
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext3D.idl687
-rw-r--r--WebCore/html/canvas/CanvasShader.cpp53
-rw-r--r--WebCore/html/canvas/CanvasShader.h50
-rw-r--r--WebCore/html/canvas/CanvasShader.idl29
-rw-r--r--WebCore/html/canvas/CanvasShortArray.cpp82
-rw-r--r--WebCore/html/canvas/CanvasShortArray.h84
-rw-r--r--WebCore/html/canvas/CanvasShortArray.idl36
-rw-r--r--WebCore/html/canvas/CanvasTexture.cpp54
-rw-r--r--WebCore/html/canvas/CanvasTexture.h61
-rw-r--r--WebCore/html/canvas/CanvasTexture.idl29
-rw-r--r--WebCore/html/canvas/CanvasUnsignedByteArray.cpp78
-rw-r--r--WebCore/html/canvas/CanvasUnsignedByteArray.h84
-rw-r--r--WebCore/html/canvas/CanvasUnsignedByteArray.idl36
-rw-r--r--WebCore/html/canvas/CanvasUnsignedIntArray.cpp83
-rw-r--r--WebCore/html/canvas/CanvasUnsignedIntArray.h84
-rw-r--r--WebCore/html/canvas/CanvasUnsignedIntArray.idl36
-rw-r--r--WebCore/html/canvas/CanvasUnsignedShortArray.cpp85
-rw-r--r--WebCore/html/canvas/CanvasUnsignedShortArray.h85
-rw-r--r--WebCore/html/canvas/CanvasUnsignedShortArray.idl36
146 files changed, 7208 insertions, 1463 deletions
diff --git a/WebCore/html/CollectionType.h b/WebCore/html/CollectionType.h
index e5973a3..9d7bb54 100644
--- a/WebCore/html/CollectionType.h
+++ b/WebCore/html/CollectionType.h
@@ -51,6 +51,7 @@ enum CollectionType {
TSectionRows, // all row elements in this table section
TRCells, // all cells in this row
SelectOptions,
+ DataListOptions,
MapAreas,
OtherCollection
diff --git a/WebCore/html/HTMLAnchorElement.cpp b/WebCore/html/HTMLAnchorElement.cpp
index 1515460..daa7919 100644
--- a/WebCore/html/HTMLAnchorElement.cpp
+++ b/WebCore/html/HTMLAnchorElement.cpp
@@ -40,51 +40,46 @@ namespace WebCore {
using namespace HTMLNames;
-HTMLAnchorElement::HTMLAnchorElement(Document* document)
- : HTMLElement(aTag, document)
- , m_rootEditableElementForSelectionOnMouseDown(0)
+HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document* document)
+ : HTMLElement(tagName, document, CreateElement)
, m_wasShiftKeyDownOnMouseDown(false)
{
}
-HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document* document)
- : HTMLElement(tagName, document)
- , m_rootEditableElementForSelectionOnMouseDown(0)
- , m_wasShiftKeyDownOnMouseDown(false)
+PassRefPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document* document)
{
+ return adoptRef(new HTMLAnchorElement(aTag, document));
}
-bool HTMLAnchorElement::supportsFocus() const
+PassRefPtr<HTMLAnchorElement> HTMLAnchorElement::create(const QualifiedName& tagName, Document* document)
{
- if (isContentEditable())
- return HTMLElement::supportsFocus();
- return isFocusable() || (isLink() && document() && !document()->haveStylesheetsLoaded());
+ return adoptRef(new HTMLAnchorElement(tagName, document));
}
-bool HTMLAnchorElement::isFocusable() const
+bool HTMLAnchorElement::supportsFocus() const
{
if (isContentEditable())
- return HTMLElement::isFocusable();
-
- // FIXME: Even if we are not visible, we might have a child that is visible.
- // Dave wants to fix that some day with a "has visible content" flag or the like.
- if (!(isLink() && renderer() && renderer()->style()->visibility() == VISIBLE))
- return false;
-
- return true;
+ return HTMLElement::supportsFocus();
+ // If not a link we should still be able to focus the element if it has tabIndex.
+ return isLink() || HTMLElement::supportsFocus();
}
bool HTMLAnchorElement::isMouseFocusable() const
{
-#if PLATFORM(GTK)
- return HTMLElement::isMouseFocusable();
-#else
- return false;
+ // Anchor elements should be mouse focusable, https://bugs.webkit.org/show_bug.cgi?id=26856
+#if !PLATFORM(GTK)
+ if (isLink())
+ return false;
#endif
+ // Allow tab index etc to control focus.
+ return HTMLElement::isMouseFocusable();
}
bool HTMLAnchorElement::isKeyboardFocusable(KeyboardEvent* event) const
{
+ if (!isLink())
+ return HTMLElement::isKeyboardFocusable(event);
+
if (!isFocusable())
return false;
@@ -350,15 +345,17 @@ String HTMLAnchorElement::hash() const
String HTMLAnchorElement::host() const
{
- return href().host();
+ const KURL& url = href();
+ if (url.hostEnd() == url.pathStart())
+ return url.host();
+ if (SecurityOrigin::isDefaultPortForProtocol(url.port(), url.protocol()))
+ return url.host();
+ return url.host() + ":" + String::number(url.port());
}
String HTMLAnchorElement::hostname() const
{
- const KURL& url = href();
- if (url.port() == 0)
- return url.host();
- return url.host() + ":" + String::number(url.port());
+ return href().host();
}
String HTMLAnchorElement::pathname() const
diff --git a/WebCore/html/HTMLAnchorElement.h b/WebCore/html/HTMLAnchorElement.h
index 7779bed..8274af4 100644
--- a/WebCore/html/HTMLAnchorElement.h
+++ b/WebCore/html/HTMLAnchorElement.h
@@ -30,8 +30,8 @@ namespace WebCore {
class HTMLAnchorElement : public HTMLElement {
public:
- HTMLAnchorElement(Document*);
- HTMLAnchorElement(const QualifiedName&, Document*);
+ static PassRefPtr<HTMLAnchorElement> create(Document*);
+ static PassRefPtr<HTMLAnchorElement> create(const QualifiedName&, Document*);
KURL href() const;
void setHref(const AtomicString&);
@@ -53,6 +53,8 @@ public:
bool isLiveLink() const;
protected:
+ HTMLAnchorElement(const QualifiedName&, Document*);
+
virtual void parseMappedAttribute(MappedAttribute*);
private:
@@ -70,7 +72,7 @@ private:
virtual short tabIndex() const;
virtual bool draggable() const;
- Element* m_rootEditableElementForSelectionOnMouseDown;
+ RefPtr<Element> m_rootEditableElementForSelectionOnMouseDown;
bool m_wasShiftKeyDownOnMouseDown;
};
diff --git a/WebCore/html/HTMLAppletElement.cpp b/WebCore/html/HTMLAppletElement.cpp
index dfa2597..46045d6 100644
--- a/WebCore/html/HTMLAppletElement.cpp
+++ b/WebCore/html/HTMLAppletElement.cpp
@@ -34,12 +34,17 @@ namespace WebCore {
using namespace HTMLNames;
-HTMLAppletElement::HTMLAppletElement(const QualifiedName& tagName, Document* doc)
- : HTMLPlugInElement(tagName, doc)
+inline HTMLAppletElement::HTMLAppletElement(const QualifiedName& tagName, Document* document)
+ : HTMLPlugInElement(tagName, document)
{
ASSERT(hasTagName(appletTag));
}
+PassRefPtr<HTMLAppletElement> HTMLAppletElement::create(const QualifiedName& tagName, Document* document)
+{
+ return adoptRef(new HTMLAppletElement(tagName, document));
+}
+
void HTMLAppletElement::parseMappedAttribute(MappedAttribute* attr)
{
if (attr->name() == altAttr ||
diff --git a/WebCore/html/HTMLAppletElement.h b/WebCore/html/HTMLAppletElement.h
index c616bb4..baaab38 100644
--- a/WebCore/html/HTMLAppletElement.h
+++ b/WebCore/html/HTMLAppletElement.h
@@ -27,12 +27,9 @@
namespace WebCore {
-class HTMLFormElement;
-class HTMLImageLoader;
-
class HTMLAppletElement : public HTMLPlugInElement {
public:
- HTMLAppletElement(const QualifiedName&, Document*);
+ static PassRefPtr<HTMLAppletElement> create(const QualifiedName&, Document*);
String hspace() const;
void setHspace(const String&);
@@ -41,6 +38,8 @@ public:
void setVspace(const String&);
private:
+ HTMLAppletElement(const QualifiedName&, Document*);
+
virtual int tagPriority() const { return 1; }
virtual void parseMappedAttribute(MappedAttribute*);
diff --git a/WebCore/html/HTMLAreaElement.cpp b/WebCore/html/HTMLAreaElement.cpp
index b878a1a..b202cae 100644
--- a/WebCore/html/HTMLAreaElement.cpp
+++ b/WebCore/html/HTMLAreaElement.cpp
@@ -34,9 +34,8 @@ namespace WebCore {
using namespace HTMLNames;
-HTMLAreaElement::HTMLAreaElement(const QualifiedName& tagName, Document* document)
+inline HTMLAreaElement::HTMLAreaElement(const QualifiedName& tagName, Document* document)
: HTMLAnchorElement(tagName, document)
- , m_coords(0)
, m_coordsLen(0)
, m_lastSize(-1, -1)
, m_shape(Unknown)
@@ -44,9 +43,9 @@ HTMLAreaElement::HTMLAreaElement(const QualifiedName& tagName, Document* documen
ASSERT(hasTagName(areaTag));
}
-HTMLAreaElement::~HTMLAreaElement()
+PassRefPtr<HTMLAreaElement> HTMLAreaElement::create(const QualifiedName& tagName, Document* document)
{
- delete [] m_coords;
+ return adoptRef(new HTMLAreaElement(tagName, document));
}
void HTMLAreaElement::parseMappedAttribute(MappedAttribute* attr)
@@ -61,8 +60,7 @@ void HTMLAreaElement::parseMappedAttribute(MappedAttribute* attr)
else if (equalIgnoringCase(attr->value(), "rect"))
m_shape = Rect;
} else if (attr->name() == coordsAttr) {
- delete [] m_coords;
- m_coords = newCoordsArray(attr->value().string(), m_coordsLen);
+ m_coords.set(newCoordsArray(attr->value().string(), m_coordsLen));
} else if (attr->name() == altAttr || attr->name() == accesskeyAttr) {
// Do nothing.
} else
@@ -164,9 +162,10 @@ void HTMLAreaElement::setNoHref(bool noHref)
setAttribute(nohrefAttr, noHref ? "" : 0);
}
-bool HTMLAreaElement::isFocusable() const
+bool HTMLAreaElement::supportsFocus() const
{
- return HTMLElement::isFocusable();
+ // Skip HTMLAnchorElements isLink() check.
+ return HTMLElement::supportsFocus();
}
String HTMLAreaElement::target() const
diff --git a/WebCore/html/HTMLAreaElement.h b/WebCore/html/HTMLAreaElement.h
index fffd45e..7b2497c 100644
--- a/WebCore/html/HTMLAreaElement.h
+++ b/WebCore/html/HTMLAreaElement.h
@@ -25,6 +25,7 @@
#include "HTMLAnchorElement.h"
#include "IntSize.h"
+#include <wtf/OwnArrayPtr.h>
namespace WebCore {
@@ -33,8 +34,7 @@ class Path;
class HTMLAreaElement : public HTMLAnchorElement {
public:
- HTMLAreaElement(const QualifiedName&, Document*);
- virtual ~HTMLAreaElement();
+ static PassRefPtr<HTMLAreaElement> create(const QualifiedName&, Document*);
bool isDefault() const { return m_shape == Default; }
@@ -48,17 +48,19 @@ public:
void setNoHref(bool);
private:
+ HTMLAreaElement(const QualifiedName&, Document*);
+
virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
virtual int tagPriority() const { return 0; }
virtual void parseMappedAttribute(MappedAttribute*);
- virtual bool isFocusable() const;
+ virtual bool supportsFocus() const;
virtual String target() const;
enum Shape { Default, Poly, Rect, Circle, Unknown };
Path getRegion(const IntSize&) const;
OwnPtr<Path> m_region;
- Length* m_coords;
+ OwnArrayPtr<Length> m_coords;
int m_coordsLen;
IntSize m_lastSize;
Shape m_shape;
diff --git a/WebCore/html/HTMLAttributeNames.in b/WebCore/html/HTMLAttributeNames.in
index 05c0cb7..3e16015 100644
--- a/WebCore/html/HTMLAttributeNames.in
+++ b/WebCore/html/HTMLAttributeNames.in
@@ -78,6 +78,7 @@ expanded
face
focused
for
+formnovalidate
frame
frameborder
headers
@@ -97,6 +98,7 @@ lang
language
leftmargin
link
+list
longdesc
loop
playcount
@@ -117,11 +119,13 @@ name
nohref
noresize
noshade
+novalidate
nowrap
object
onabort
onbeforecopy
onbeforecut
+onbeforeload
onbeforepaste
onbeforeunload
onblur
@@ -147,12 +151,14 @@ onerror
onfocus
onhashchange
oninput
+oninvalid
onkeydown
onkeypress
onkeyup
onload
onloadeddata
onloadedmetadata
+onloadend
onloadstart
onmousedown
onmousemove
@@ -162,6 +168,9 @@ onmouseup
onmousewheel
ononline
onoffline
+onorientationchange
+onpagehide
+onpageshow
onpaste
onpause
onplay
diff --git a/WebCore/html/HTMLBodyElement.cpp b/WebCore/html/HTMLBodyElement.cpp
index 4667381..b203cc0 100644
--- a/WebCore/html/HTMLBodyElement.cpp
+++ b/WebCore/html/HTMLBodyElement.cpp
@@ -140,10 +140,18 @@ void HTMLBodyElement::parseMappedAttribute(MappedAttribute *attr)
document()->setWindowAttributeEventListener(eventNames().beforeunloadEvent, createAttributeEventListener(document()->frame(), attr));
else if (attr->name() == onunloadAttr)
document()->setWindowAttributeEventListener(eventNames().unloadEvent, createAttributeEventListener(document()->frame(), attr));
+ else if (attr->name() == onpagehideAttr)
+ document()->setWindowAttributeEventListener(eventNames().pagehideEvent, createAttributeEventListener(document()->frame(), attr));
+ else if (attr->name() == onpageshowAttr)
+ document()->setWindowAttributeEventListener(eventNames().pageshowEvent, createAttributeEventListener(document()->frame(), attr));
else if (attr->name() == onblurAttr)
document()->setWindowAttributeEventListener(eventNames().blurEvent, createAttributeEventListener(document()->frame(), attr));
else if (attr->name() == onfocusAttr)
document()->setWindowAttributeEventListener(eventNames().focusEvent, createAttributeEventListener(document()->frame(), attr));
+#if ENABLE(ORIENTATION_EVENTS)
+ else if (attr->name() == onorientationchangeAttr)
+ document()->setWindowAttributeEventListener(eventNames().orientationchangeEvent, createAttributeEventListener(document()->frame(), attr));
+#endif
else if (attr->name() == onhashchangeAttr)
document()->setWindowAttributeEventListener(eventNames().hashchangeEvent, createAttributeEventListener(document()->frame(), attr));
else if (attr->name() == onresizeAttr)
@@ -341,114 +349,4 @@ void HTMLBodyElement::didMoveToNewOwnerDocument()
HTMLElement::didMoveToNewOwnerDocument();
}
-EventListener* HTMLBodyElement::onblur() const
-{
- return document()->getWindowAttributeEventListener(eventNames().blurEvent);
-}
-
-void HTMLBodyElement::setOnblur(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().blurEvent, eventListener);
-}
-
-EventListener* HTMLBodyElement::onerror() const
-{
- return document()->getWindowAttributeEventListener(eventNames().errorEvent);
-}
-
-void HTMLBodyElement::setOnerror(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().errorEvent, eventListener);
-}
-
-EventListener* HTMLBodyElement::onfocus() const
-{
- return document()->getWindowAttributeEventListener(eventNames().focusEvent);
-}
-
-void HTMLBodyElement::setOnfocus(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().focusEvent, eventListener);
-}
-
-EventListener* HTMLBodyElement::onload() const
-{
- return document()->getWindowAttributeEventListener(eventNames().loadEvent);
-}
-
-void HTMLBodyElement::setOnload(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().loadEvent, eventListener);
-}
-
-EventListener* HTMLBodyElement::onbeforeunload() const
-{
- return document()->getWindowAttributeEventListener(eventNames().beforeunloadEvent);
-}
-
-void HTMLBodyElement::setOnbeforeunload(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().beforeunloadEvent, eventListener);
-}
-
-EventListener* HTMLBodyElement::onmessage() const
-{
- return document()->getWindowAttributeEventListener(eventNames().messageEvent);
-}
-
-void HTMLBodyElement::setOnmessage(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().messageEvent, eventListener);
-}
-
-EventListener* HTMLBodyElement::onoffline() const
-{
- return document()->getWindowAttributeEventListener(eventNames().offlineEvent);
-}
-
-void HTMLBodyElement::setOnoffline(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().offlineEvent, eventListener);
-}
-
-EventListener* HTMLBodyElement::ononline() const
-{
- return document()->getWindowAttributeEventListener(eventNames().onlineEvent);
-}
-
-void HTMLBodyElement::setOnonline(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().onlineEvent, eventListener);
-}
-
-EventListener* HTMLBodyElement::onresize() const
-{
- return document()->getWindowAttributeEventListener(eventNames().resizeEvent);
-}
-
-void HTMLBodyElement::setOnresize(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().resizeEvent, eventListener);
-}
-
-EventListener* HTMLBodyElement::onstorage() const
-{
- return document()->getWindowAttributeEventListener(eventNames().storageEvent);
-}
-
-void HTMLBodyElement::setOnstorage(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().storageEvent, eventListener);
-}
-
-EventListener* HTMLBodyElement::onunload() const
-{
- return document()->getWindowAttributeEventListener(eventNames().unloadEvent);
-}
-
-void HTMLBodyElement::setOnunload(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().unloadEvent, eventListener);
-}
-
} // namespace WebCore
diff --git a/WebCore/html/HTMLBodyElement.h b/WebCore/html/HTMLBodyElement.h
index 575d562..e898c88 100644
--- a/WebCore/html/HTMLBodyElement.h
+++ b/WebCore/html/HTMLBodyElement.h
@@ -25,6 +25,7 @@
#define HTMLBodyElement_h
#include "HTMLElement.h"
+#include "Document.h"
namespace WebCore {
@@ -44,29 +45,23 @@ public:
String vLink() const;
void setVLink(const String&);
- virtual EventListener* onblur() const;
- virtual void setOnblur(PassRefPtr<EventListener>);
- virtual EventListener* onerror() const;
- virtual void setOnerror(PassRefPtr<EventListener>);
- virtual EventListener* onfocus() const;
- virtual void setOnfocus(PassRefPtr<EventListener>);
- virtual EventListener* onload() const;
- virtual void setOnload(PassRefPtr<EventListener>);
+ // Declared virtual in Element
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(blur);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(error);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(focus);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(load);
- EventListener* onbeforeunload() const;
- void setOnbeforeunload(PassRefPtr<EventListener>);
- EventListener* onmessage() const;
- void setOnmessage(PassRefPtr<EventListener>);
- EventListener* onoffline() const;
- void setOnoffline(PassRefPtr<EventListener>);
- EventListener* ononline() const;
- void setOnonline(PassRefPtr<EventListener>);
- EventListener* onresize() const;
- void setOnresize(PassRefPtr<EventListener>);
- EventListener* onstorage() const;
- void setOnstorage(PassRefPtr<EventListener>);
- EventListener* onunload() const;
- void setOnunload(PassRefPtr<EventListener>);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(beforeunload);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(message);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(hashchange);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(offline);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(online);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(resize);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(storage);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(unload);
+#if ENABLE(ORIENTATION_EVENTS)
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(orientationchange);
+#endif
private:
virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
diff --git a/WebCore/html/HTMLBodyElement.idl b/WebCore/html/HTMLBodyElement.idl
index 097b4ac..2e93e2e 100644
--- a/WebCore/html/HTMLBodyElement.idl
+++ b/WebCore/html/HTMLBodyElement.idl
@@ -36,6 +36,7 @@ module html {
#if !defined(LANGUAGE_COM) || !LANGUAGE_COM
// Event handler attributes
attribute [DontEnum] EventListener onbeforeunload;
+ attribute [DontEnum] EventListener onhashchange;
attribute [DontEnum] EventListener onmessage;
attribute [DontEnum] EventListener onoffline;
attribute [DontEnum] EventListener ononline;
@@ -43,10 +44,19 @@ module html {
attribute [DontEnum] EventListener onstorage;
attribute [DontEnum] EventListener onunload;
+#if defined(ENABLE_ORIENTATION_EVENTS) && ENABLE_ORIENTATION_EVENTS
+ attribute [DontEnum] EventListener onorientationchange;
+#endif
+
+ // Overrides of Element attributes (left in for completeness).
+ // attribute [DontEnum] EventListener onblur;
+ // attribute [DontEnum] EventListener onerror;
+ // attribute [DontEnum] EventListener onfocus;
+ // attribute [DontEnum] EventListener onload;
+
// Not implemented yet.
// attribute [DontEnum] EventListener onafterprint;
// attribute [DontEnum] EventListener onbeforeprint;
- // attribute [DontEnum] EventListener onhashchange;
// attribute [DontEnum] EventListener onpopstate;
// attribute [DontEnum] EventListener onredo;
// attribute [DontEnum] EventListener onundo;
diff --git a/WebCore/html/HTMLButtonElement.idl b/WebCore/html/HTMLButtonElement.idl
index 5fd0075..55803df 100644
--- a/WebCore/html/HTMLButtonElement.idl
+++ b/WebCore/html/HTMLButtonElement.idl
@@ -26,6 +26,7 @@ module html {
ImplementationUUID=1be13b5f-40df-4550-b70e-8c805e546cad
] HTMLButtonElement : HTMLElement {
readonly attribute HTMLFormElement form;
+ attribute boolean formNoValidate;
#if !defined(LANGUAGE_COM) || !LANGUAGE_COM
readonly attribute ValidityState validity;
#endif
@@ -36,6 +37,7 @@ module html {
readonly attribute DOMString type;
attribute [ConvertNullToNullString] DOMString value;
readonly attribute boolean willValidate;
+ boolean checkValidity();
void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error);
void click();
};
diff --git a/WebCore/html/HTMLCanvasElement.cpp b/WebCore/html/HTMLCanvasElement.cpp
index 203579b..e3fe329 100644
--- a/WebCore/html/HTMLCanvasElement.cpp
+++ b/WebCore/html/HTMLCanvasElement.cpp
@@ -30,6 +30,9 @@
#include "CanvasGradient.h"
#include "CanvasPattern.h"
#include "CanvasRenderingContext2D.h"
+#if ENABLE(3D_CANVAS)
+#include "CanvasRenderingContext3D.h"
+#endif
#include "CanvasStyle.h"
#include "Chrome.h"
#include "Document.h"
@@ -146,17 +149,45 @@ String HTMLCanvasElement::toDataURL(const String& mimeType, ExceptionCode& ec)
CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type)
{
+ // A Canvas can either be "2D" or "3D" never both. If you request a 2D canvas and the existing
+ // context is already 2D, just return that. If the existing context is 3D, then destroy it
+ // before creating a new 2D context. Vice versa when requesting a 3D canvas. Requesting a
+ // context with any other type string will destroy any existing context.
+
+ // FIXME - The code depends on the context not going away once created, to prevent JS from
+ // seeing a dangling pointer. So for now we will disallow the context from being changed
+ // once it is created.
if (type == "2d") {
- if (!m_2DContext)
- m_2DContext.set(new CanvasRenderingContext2D(this));
- return m_2DContext.get();
+ if (m_context && !m_context->is2d())
+ return 0;
+ if (!m_context)
+ m_context = new CanvasRenderingContext2D(this);
+ return m_context.get();
+ }
+#if ENABLE(3D_CANVAS)
+ Settings* settings = document()->settings();
+ if (settings && settings->webGLEnabled()) {
+ if ((type == "webkit-3d") ||
+ (type == "GL")) {
+ if (m_context && !m_context->is3d())
+ return 0;
+ if (!m_context) {
+ m_context = new CanvasRenderingContext3D(this);
+
+ // Need to make sure a RenderLayer and compositing layer get created for the Canvas
+ setNeedsStyleRecalc(SyntheticStyleChange);
+ }
+ return m_context.get();
+ }
}
+#endif
return 0;
}
void HTMLCanvasElement::willDraw(const FloatRect& rect)
{
- m_imageBuffer->clearImage();
+ if (m_imageBuffer)
+ m_imageBuffer->clearImage();
if (RenderBox* ro = renderBox()) {
FloatRect destRect = ro->contentBoxRect();
@@ -192,8 +223,8 @@ void HTMLCanvasElement::reset()
bool hadImageBuffer = m_createdImageBuffer;
m_createdImageBuffer = false;
m_imageBuffer.clear();
- if (m_2DContext)
- m_2DContext->reset();
+ if (m_context && m_context->is2d())
+ static_cast<CanvasRenderingContext2D*>(m_context.get())->reset();
if (RenderObject* renderer = this->renderer()) {
if (m_rendererIsCanvas) {
@@ -216,11 +247,26 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r)
if (context->paintingDisabled())
return;
+#if ENABLE(3D_CANVAS)
+ CanvasRenderingContext3D* context3D = NULL;
+ if (m_context && m_context->is3d()) {
+ context3D = static_cast<CanvasRenderingContext3D*>(m_context.get());
+ context3D->beginPaint();
+ }
+#endif
+
if (m_imageBuffer) {
Image* image = m_imageBuffer->image();
if (image)
context->drawImage(image, r);
}
+
+#if ENABLE(3D_CANVAS)
+ if (context3D != NULL) {
+ context3D->reshape(r.width(), r.height());
+ context3D->endPaint();
+ }
+#endif
}
IntRect HTMLCanvasElement::convertLogicalToDevice(const FloatRect& logicalRect) const
@@ -293,4 +339,11 @@ TransformationMatrix HTMLCanvasElement::baseTransform() const
return transform;
}
+#if ENABLE(3D_CANVAS)
+bool HTMLCanvasElement::is3D() const
+{
+ return m_context && m_context->is3d();
+}
+#endif
+
}
diff --git a/WebCore/html/HTMLCanvasElement.h b/WebCore/html/HTMLCanvasElement.h
index bba1f2d..edae9e5 100644
--- a/WebCore/html/HTMLCanvasElement.h
+++ b/WebCore/html/HTMLCanvasElement.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
*
* Redistribution and use in source and binary forms, with or without
@@ -30,12 +30,14 @@
#include "TransformationMatrix.h"
#include "FloatRect.h"
#include "HTMLElement.h"
+#if ENABLE(3D_CANVAS)
+#include "GraphicsContext3D.h"
+#endif
#include "IntSize.h"
namespace WebCore {
-class CanvasRenderingContext2D;
-typedef CanvasRenderingContext2D CanvasRenderingContext;
+class CanvasRenderingContext;
class FloatPoint;
class FloatRect;
class FloatSize;
@@ -47,7 +49,7 @@ class IntSize;
class CanvasObserver {
public:
- virtual ~CanvasObserver() {};
+ virtual ~CanvasObserver() { }
virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect) = 0;
virtual void canvasResized(HTMLCanvasElement*) = 0;
@@ -59,11 +61,6 @@ public:
HTMLCanvasElement(const QualifiedName&, Document*);
virtual ~HTMLCanvasElement();
-#if ENABLE(DASHBOARD_SUPPORT)
- virtual HTMLTagStatus endTagRequirement() const;
- virtual int tagPriority() const;
-#endif
-
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
void setWidth(int);
@@ -73,10 +70,7 @@ public:
CanvasRenderingContext* getContext(const String&);
- virtual void parseMappedAttribute(MappedAttribute*);
- virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
-
- IntSize size() const { return m_size; }
+ const IntSize& size() const { return m_size; }
void setSize(const IntSize& size)
{
if (size == m_size)
@@ -103,18 +97,33 @@ public:
void setOriginTainted() { m_originClean = false; }
bool originClean() const { return m_originClean; }
- static const float MaxCanvasArea;
-
- void setObserver(CanvasObserver* o) { m_observer = o; }
+ void setObserver(CanvasObserver* observer) { m_observer = observer; }
TransformationMatrix baseTransform() const;
+
+ CanvasRenderingContext* renderingContext() const { return m_context.get(); }
+
+#if ENABLE(3D_CANVAS)
+ bool is3D() const;
+#endif
+
private:
+#if ENABLE(DASHBOARD_SUPPORT)
+ virtual HTMLTagStatus endTagRequirement() const;
+ virtual int tagPriority() const;
+#endif
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
void createImageBuffer() const;
void reset();
+ static const float MaxCanvasArea;
+
bool m_rendererIsCanvas;
- OwnPtr<CanvasRenderingContext2D> m_2DContext;
+ OwnPtr<CanvasRenderingContext> m_context;
IntSize m_size;
CanvasObserver* m_observer;
diff --git a/WebCore/html/HTMLCanvasElement.idl b/WebCore/html/HTMLCanvasElement.idl
index 13fc623..4b1b057 100644
--- a/WebCore/html/HTMLCanvasElement.idl
+++ b/WebCore/html/HTMLCanvasElement.idl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
module html {
interface [
+ CustomMarkFunction,
GenerateConstructor,
InterfaceUUID=a14d88c8-c6af-4e34-ad17-659700c77a10,
ImplementationUUID=7ae731bc-c264-4ee3-a4b4-5d4540af26c3
diff --git a/WebCore/html/HTMLCollection.cpp b/WebCore/html/HTMLCollection.cpp
index de4c424..76de60a 100644
--- a/WebCore/html/HTMLCollection.cpp
+++ b/WebCore/html/HTMLCollection.cpp
@@ -27,6 +27,7 @@
#include "HTMLElement.h"
#include "HTMLNames.h"
#include "HTMLObjectElement.h"
+#include "HTMLOptionElement.h"
#include "NodeList.h"
#include <utility>
@@ -104,6 +105,7 @@ Element* HTMLCollection::itemAfter(Element* previous) const
case MapAreas:
case OtherCollection:
case SelectOptions:
+ case DataListOptions:
case WindowNamedItems:
break;
case NodeChildren:
@@ -153,6 +155,13 @@ Element* HTMLCollection::itemAfter(Element* previous) const
if (e->hasLocalName(optionTag))
return e;
break;
+ case DataListOptions:
+ if (e->hasLocalName(optionTag)) {
+ HTMLOptionElement* option = static_cast<HTMLOptionElement*>(e);
+ if (!option->disabled() && !option->value().isEmpty())
+ return e;
+ }
+ break;
case MapAreas:
if (e->hasLocalName(areaTag))
return e;
diff --git a/WebCore/html/HTMLDataListElement.cpp b/WebCore/html/HTMLDataListElement.cpp
new file mode 100644
index 0000000..a6ca525
--- /dev/null
+++ b/WebCore/html/HTMLDataListElement.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2009, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#if ENABLE(DATALIST)
+#include "HTMLDataListElement.h"
+
+#include "HTMLNames.h"
+
+namespace WebCore {
+
+HTMLDataListElement::HTMLDataListElement(const QualifiedName& tagName, Document *doc)
+ : HTMLElement(tagName, doc)
+{
+}
+
+HTMLDataListElement::~HTMLDataListElement()
+{
+}
+
+bool HTMLDataListElement::checkDTD(const Node* newChild)
+{
+ return newChild->hasTagName(HTMLNames::optionTag) || HTMLElement::inInlineTagList(newChild);
+}
+
+PassRefPtr<HTMLCollection> HTMLDataListElement::options()
+{
+ return HTMLCollection::create(this, DataListOptions);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(DATALIST)
diff --git a/WebCore/html/HTMLDataListElement.h b/WebCore/html/HTMLDataListElement.h
new file mode 100644
index 0000000..8c4cfbc
--- /dev/null
+++ b/WebCore/html/HTMLDataListElement.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2009, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HTMLDataListElement_h
+#define HTMLDataListElement_h
+
+#if ENABLE(DATALIST)
+
+#include "HTMLCollection.h"
+#include "HTMLElement.h"
+
+namespace WebCore {
+
+ class HTMLDataListElement : public HTMLElement {
+ public:
+ HTMLDataListElement(const QualifiedName&, Document*);
+ virtual ~HTMLDataListElement();
+ PassRefPtr<HTMLCollection> options();
+
+ private:
+ virtual bool checkDTD(const Node*);
+ };
+
+} // namespace WebCore
+
+#endif // ENABLE(DATALIST)
+
+#endif // HTMLDataListElement_h
diff --git a/WebCore/html/HTMLDataListElement.idl b/WebCore/html/HTMLDataListElement.idl
new file mode 100644
index 0000000..916c0a1
--- /dev/null
+++ b/WebCore/html/HTMLDataListElement.idl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2009, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ GenerateConstructor,
+ Conditional=DATALIST
+ ] HTMLDataListElement : HTMLElement {
+ readonly attribute HTMLCollection options;
+ };
+}
diff --git a/WebCore/html/HTMLDocument.cpp b/WebCore/html/HTMLDocument.cpp
index 96ae9e4..fd939c8 100644
--- a/WebCore/html/HTMLDocument.cpp
+++ b/WebCore/html/HTMLDocument.cpp
@@ -109,14 +109,14 @@ String HTMLDocument::dir()
HTMLElement* b = body();
if (!b)
return String();
- return b->dir();
+ return b->getAttribute(dirAttr);
}
void HTMLDocument::setDir(const String& value)
{
HTMLElement* b = body();
if (b)
- b->setDir(value);
+ b->setAttribute(dirAttr, value);
}
String HTMLDocument::designMode() const
@@ -284,8 +284,10 @@ void HTMLDocument::releaseEvents()
Tokenizer *HTMLDocument::createTokenizer()
{
bool reportErrors = false;
+#if ENABLE(INSPECTOR)
if (Page* page = this->page())
reportErrors = page->inspectorController()->windowVisible();
+#endif
return new HTMLTokenizer(this, reportErrors);
}
diff --git a/WebCore/html/HTMLDocument.h b/WebCore/html/HTMLDocument.h
index eda7593..4b14d0c 100644
--- a/WebCore/html/HTMLDocument.h
+++ b/WebCore/html/HTMLDocument.h
@@ -37,7 +37,7 @@ class HTMLDocument : public Document, public CachedResourceClient {
public:
static PassRefPtr<HTMLDocument> create(Frame* frame)
{
- return new HTMLDocument(frame);
+ return adoptRef(new HTMLDocument(frame));
}
virtual ~HTMLDocument();
@@ -71,10 +71,6 @@ public:
void captureEvents();
void releaseEvents();
- virtual bool childAllowed(Node*);
-
- virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
-
void addNamedItem(const AtomicString& name);
void removeNamedItem(const AtomicString& name);
bool hasNamedItem(AtomicStringImpl* name);
@@ -87,6 +83,10 @@ protected:
HTMLDocument(Frame*);
private:
+ virtual bool childAllowed(Node*);
+
+ virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
+
virtual bool isHTMLDocument() const { return true; }
virtual bool isFrameSet() const;
virtual Tokenizer* createTokenizer();
diff --git a/WebCore/html/HTMLElement.cpp b/WebCore/html/HTMLElement.cpp
index b310cad..a4807ba 100644
--- a/WebCore/html/HTMLElement.cpp
+++ b/WebCore/html/HTMLElement.cpp
@@ -56,13 +56,9 @@ using namespace HTMLNames;
using std::min;
using std::max;
-HTMLElement::HTMLElement(const QualifiedName& tagName, Document *doc)
- : StyledElement(tagName, doc)
-{
-}
-
-HTMLElement::~HTMLElement()
+PassRefPtr<HTMLElement> HTMLElement::create(const QualifiedName& tagName, Document* document)
{
+ return adoptRef(new HTMLElement(tagName, document, CreateElement));
}
String HTMLElement::nodeName() const
@@ -92,7 +88,7 @@ int HTMLElement::tagPriority() const
return 0;
if (hasLocalName(addressTag) || hasLocalName(ddTag) || hasLocalName(dtTag) || hasLocalName(noscriptTag) || hasLocalName(rpTag) || hasLocalName(rtTag))
return 3;
- if (hasLocalName(centerTag) || hasLocalName(nobrTag) || hasLocalName(rubyTag))
+ if (hasLocalName(centerTag) || hasLocalName(nobrTag) || hasLocalName(rubyTag) || hasLocalName(navTag))
return 5;
if (hasLocalName(noembedTag) || hasLocalName(noframesTag))
return 10;
@@ -234,6 +230,8 @@ void HTMLElement::parseMappedAttribute(MappedAttribute *attr)
#endif
} else if (attr->name() == oninputAttr) {
setAttributeEventListener(eventNames().inputEvent, createAttributeEventListener(this, attr));
+ } else if (attr->name() == oninvalidAttr) {
+ setAttributeEventListener(eventNames().invalidEvent, createAttributeEventListener(this, attr));
}
}
@@ -257,7 +255,7 @@ PassRefPtr<DocumentFragment> HTMLElement::createContextualFragment(const String
hasLocalName(headTag) || hasLocalName(styleTag) || hasLocalName(titleTag))
return 0;
- RefPtr<DocumentFragment> fragment = new DocumentFragment(document());
+ RefPtr<DocumentFragment> fragment = DocumentFragment::create(document());
if (document()->isHTMLDocument())
parseHTMLDocumentFragment(html, fragment.get());
@@ -319,7 +317,7 @@ static void replaceChildrenWithFragment(HTMLElement* element, PassRefPtr<Documen
}
if (hasOneTextChild(element) && hasOneTextChild(fragment.get())) {
- static_cast<Text*>(element->firstChild())->setData(static_cast<Text*>(fragment->firstChild())->string(), ec);
+ static_cast<Text*>(element->firstChild())->setData(static_cast<Text*>(fragment->firstChild())->data(), ec);
return;
}
@@ -339,7 +337,7 @@ static void replaceChildrenWithText(HTMLElement* element, const String& text, Ex
return;
}
- RefPtr<Text> textNode = new Text(element->document(), text);
+ RefPtr<Text> textNode = Text::create(element->document(), text);
if (hasOneChild(element)) {
element->replaceChild(textNode.release(), element->firstChild(), ec);
@@ -425,7 +423,7 @@ void HTMLElement::setInnerText(const String& text, ExceptionCode& ec)
// Add text nodes and <br> elements.
ec = 0;
- RefPtr<DocumentFragment> fragment = new DocumentFragment(document());
+ RefPtr<DocumentFragment> fragment = DocumentFragment::create(document());
int lineStart = 0;
UChar prev = 0;
int length = text.length();
@@ -433,7 +431,7 @@ void HTMLElement::setInnerText(const String& text, ExceptionCode& ec)
UChar c = text[i];
if (c == '\n' || c == '\r') {
if (i > lineStart) {
- fragment->appendChild(new Text(document(), text.substring(lineStart, i - lineStart)), ec);
+ fragment->appendChild(Text::create(document(), text.substring(lineStart, i - lineStart)), ec);
if (ec)
return;
}
@@ -447,7 +445,7 @@ void HTMLElement::setInnerText(const String& text, ExceptionCode& ec)
prev = c;
}
if (length > lineStart)
- fragment->appendChild(new Text(document(), text.substring(lineStart, length - lineStart)), ec);
+ fragment->appendChild(Text::create(document(), text.substring(lineStart, length - lineStart)), ec);
replaceChildrenWithFragment(this, fragment.release(), ec);
}
@@ -475,7 +473,7 @@ void HTMLElement::setOuterText(const String &text, ExceptionCode& ec)
// FIXME: This creates a new text node even when the text is empty.
// FIXME: This creates a single text node even when the text has CR and LF
// characters in it. Instead it should create <br> elements.
- RefPtr<Text> t = new Text(document(), text);
+ RefPtr<Text> t = Text::create(document(), text);
ec = 0;
parent->replaceChild(t, this, ec);
if (ec)
@@ -613,9 +611,9 @@ void HTMLElement::addHTMLAlignmentToStyledElement(StyledElement* element, Mapped
element->addCSSProperty(attr, CSSPropertyVerticalAlign, verticalAlignValue);
}
-bool HTMLElement::isFocusable() const
+bool HTMLElement::supportsFocus() const
{
- return Element::isFocusable() || (isContentEditable() && parent() && !parent()->isContentEditable());
+ return Element::supportsFocus() || (isContentEditable() && parent() && !parent()->isContentEditable());
}
bool HTMLElement::isContentEditable() const
@@ -737,56 +735,11 @@ void HTMLElement::accessKeyAction(bool sendToAnyElement)
dispatchSimulatedClick(0, true);
}
-String HTMLElement::id() const
-{
- return getAttribute(idAttr);
-}
-
-void HTMLElement::setId(const String& value)
-{
- setAttribute(idAttr, value);
-}
-
String HTMLElement::title() const
{
return getAttribute(titleAttr);
}
-void HTMLElement::setTitle(const String& value)
-{
- setAttribute(titleAttr, value);
-}
-
-String HTMLElement::lang() const
-{
- return getAttribute(langAttr);
-}
-
-void HTMLElement::setLang(const String& value)
-{
- setAttribute(langAttr, value);
-}
-
-String HTMLElement::dir() const
-{
- return getAttribute(dirAttr);
-}
-
-void HTMLElement::setDir(const String &value)
-{
- setAttribute(dirAttr, value);
-}
-
-String HTMLElement::className() const
-{
- return getAttribute(classAttr);
-}
-
-void HTMLElement::setClassName(const String &value)
-{
- setAttribute(classAttr, value);
-}
-
short HTMLElement::tabIndex() const
{
if (supportsFocus())
@@ -894,6 +847,7 @@ static HashSet<AtomicStringImpl*>* inlineTagList()
tagList.add(textareaTag.localName().impl());
tagList.add(labelTag.localName().impl());
tagList.add(buttonTag.localName().impl());
+ tagList.add(datalistTag.localName().impl());
tagList.add(insTag.localName().impl());
tagList.add(delTag.localName().impl());
tagList.add(nobrTag.localName().impl());
@@ -936,6 +890,7 @@ static HashSet<AtomicStringImpl*>* blockTagList()
tagList.add(listingTag.localName().impl());
tagList.add(marqueeTag.localName().impl());
tagList.add(menuTag.localName().impl());
+ tagList.add(navTag.localName().impl());
tagList.add(noembedTag.localName().impl());
tagList.add(noframesTag.localName().impl());
tagList.add(nolayerTag.localName().impl());
diff --git a/WebCore/html/HTMLElement.h b/WebCore/html/HTMLElement.h
index 21b3bb5..c6a384b 100644
--- a/WebCore/html/HTMLElement.h
+++ b/WebCore/html/HTMLElement.h
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -35,28 +35,12 @@ enum HTMLTagStatus { TagStatusOptional, TagStatusRequired, TagStatusForbidden };
class HTMLElement : public StyledElement {
public:
- HTMLElement(const QualifiedName& tagName, Document*);
- virtual ~HTMLElement();
-
- virtual bool isHTMLElement() const { return true; }
-
- virtual String nodeName() const;
-
- virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
- virtual void parseMappedAttribute(MappedAttribute*);
+ static PassRefPtr<HTMLElement> create(const QualifiedName& tagName, Document*);
PassRefPtr<HTMLCollection> children();
- String id() const;
- void setId(const String&);
virtual String title() const;
- void setTitle(const String&);
- String lang() const;
- void setLang(const String&);
- String dir() const;
- void setDir(const String&);
- String className() const;
- void setClassName(const String&);
+
virtual short tabIndex() const;
void setTabIndex(int);
@@ -72,12 +56,13 @@ public:
void insertAdjacentHTML(const String& where, const String& html, ExceptionCode&);
void insertAdjacentText(const String& where, const String& text, ExceptionCode&);
- virtual bool isFocusable() const;
+ virtual bool supportsFocus() const;
+
virtual bool isContentEditable() const;
virtual bool isContentRichlyEditable() const;
- virtual String contentEditable() const;
- virtual void setContentEditable(MappedAttribute*);
- virtual void setContentEditable(const String&);
+
+ String contentEditable() const;
+ void setContentEditable(const String&);
virtual bool draggable() const;
void setDraggable(bool);
@@ -88,31 +73,51 @@ public:
virtual HTMLTagStatus endTagRequirement() const;
virtual int tagPriority() const;
+
+ virtual bool rendererIsNeeded(RenderStyle*);
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ HTMLFormElement* form() const { return virtualForm(); }
+
+ static void addHTMLAlignmentToStyledElement(StyledElement*, MappedAttribute*);
+
+protected:
+ HTMLElement(const QualifiedName& tagName, Document*, ConstructionType = CreateElementZeroRefCount);
+
+ void addHTMLAlignment(MappedAttribute*);
+
+ virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
+ virtual void parseMappedAttribute(MappedAttribute*);
+
virtual bool childAllowed(Node* newChild); // Error-checking during parsing that checks the DTD
// Helper function to check the DTD for a given child node.
virtual bool checkDTD(const Node*);
+
static bool inEitherTagList(const Node*);
static bool inInlineTagList(const Node*);
static bool inBlockTagList(const Node*);
static bool isRecognizedTagName(const QualifiedName&);
- virtual bool rendererIsNeeded(RenderStyle*);
- virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
-
- HTMLFormElement* form() const { return virtualForm(); }
HTMLFormElement* findFormAncestor() const;
- static void addHTMLAlignmentToStyledElement(StyledElement*, MappedAttribute*);
+private:
+ virtual bool isHTMLElement() const { return true; }
-protected:
- void addHTMLAlignment(MappedAttribute*);
+ virtual String nodeName() const;
+
+ void setContentEditable(MappedAttribute*);
-private:
virtual HTMLFormElement* virtualForm() const;
+
Node* insertAdjacent(const String& where, Node* newChild, ExceptionCode&);
};
+inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document* document, ConstructionType type)
+ : StyledElement(tagName, document, type)
+{
+}
+
} // namespace WebCore
#endif // HTMLElement_h
diff --git a/WebCore/html/HTMLEmbedElement.cpp b/WebCore/html/HTMLEmbedElement.cpp
index 3f6db9a..81b88a4 100644
--- a/WebCore/html/HTMLEmbedElement.cpp
+++ b/WebCore/html/HTMLEmbedElement.cpp
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Stefan Schimanski (1Stein@gmx.de)
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* This library is free software; you can redistribute it and/or
@@ -42,15 +42,16 @@ namespace WebCore {
using namespace HTMLNames;
-HTMLEmbedElement::HTMLEmbedElement(const QualifiedName& tagName, Document* doc)
- : HTMLPlugInImageElement(tagName, doc)
+inline HTMLEmbedElement::HTMLEmbedElement(const QualifiedName& tagName, Document* document)
+ : HTMLPlugInImageElement(tagName, document)
, m_needWidgetUpdate(false)
{
ASSERT(hasTagName(embedTag));
}
-HTMLEmbedElement::~HTMLEmbedElement()
+PassRefPtr<HTMLEmbedElement> HTMLEmbedElement::create(const QualifiedName& tagName, Document* document)
{
+ return adoptRef(new HTMLEmbedElement(tagName, document));
}
static inline RenderWidget* findWidgetRenderer(const Node* n)
@@ -238,31 +239,11 @@ const QualifiedName& HTMLEmbedElement::imageSourceAttributeName() const
return srcAttr;
}
-String HTMLEmbedElement::src() const
-{
- return getAttribute(srcAttr);
-}
-
-void HTMLEmbedElement::setSrc(const String& value)
-{
- setAttribute(srcAttr, value);
-}
-
-String HTMLEmbedElement::type() const
-{
- return getAttribute(typeAttr);
-}
-
-void HTMLEmbedElement::setType(const String& value)
-{
- setAttribute(typeAttr, value);
-}
-
void HTMLEmbedElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
{
HTMLPlugInImageElement::addSubresourceAttributeURLs(urls);
- addSubresourceURL(urls, document()->completeURL(src()));
+ addSubresourceURL(urls, document()->completeURL(getAttribute(srcAttr)));
}
}
diff --git a/WebCore/html/HTMLEmbedElement.h b/WebCore/html/HTMLEmbedElement.h
index 2ce182a..16f0893 100644
--- a/WebCore/html/HTMLEmbedElement.h
+++ b/WebCore/html/HTMLEmbedElement.h
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -29,8 +29,12 @@ namespace WebCore {
class HTMLEmbedElement : public HTMLPlugInImageElement {
public:
+ static PassRefPtr<HTMLEmbedElement> create(const QualifiedName&, Document*);
+
+ void setNeedWidgetUpdate(bool needWidgetUpdate) { m_needWidgetUpdate = needWidgetUpdate; }
+
+private:
HTMLEmbedElement(const QualifiedName&, Document*);
- ~HTMLEmbedElement();
virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
virtual int tagPriority() const { return 0; }
@@ -50,19 +54,11 @@ public:
virtual const QualifiedName& imageSourceAttributeName() const;
virtual void updateWidget();
- void setNeedWidgetUpdate(bool needWidgetUpdate) { m_needWidgetUpdate = needWidgetUpdate; }
virtual RenderWidget* renderWidgetForJSBindings() const;
- String src() const;
- void setSrc(const String&);
-
- String type() const;
- void setType(const String&);
-
virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
-private:
bool m_needWidgetUpdate;
};
diff --git a/WebCore/html/HTMLEmbedElement.idl b/WebCore/html/HTMLEmbedElement.idl
index a38402c..05c10db 100644
--- a/WebCore/html/HTMLEmbedElement.idl
+++ b/WebCore/html/HTMLEmbedElement.idl
@@ -29,17 +29,17 @@ module html {
InterfaceUUID=18f9bd58-6bb3-4b5c-aa30-6da13adfc91e,
ImplementationUUID=93e0407a-8380-4ff0-978d-f773f2dee6a3
] HTMLEmbedElement : HTMLElement {
- attribute [ConvertNullToNullString] DOMString align;
+ attribute [ConvertNullToNullString, Reflect] DOMString align;
#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
- attribute [ConvertNullToNullString] DOMString height;
+ attribute [ConvertNullToNullString, Reflect] DOMString height;
#else
attribute [ConvertFromString] long height;
#endif
- attribute [ConvertNullToNullString] DOMString name;
- attribute [ConvertNullToNullString] DOMString src;
- attribute [ConvertNullToNullString] DOMString type;
+ attribute [ConvertNullToNullString, Reflect] DOMString name;
+ attribute [ConvertNullToNullString, Reflect] DOMString src;
+ attribute [ConvertNullToNullString, Reflect] DOMString type;
#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
- attribute [ConvertNullToNullString] DOMString width;
+ attribute [ConvertNullToNullString, Reflect] DOMString width;
#else
attribute [ConvertFromString] long width;
#endif
diff --git a/WebCore/html/HTMLFieldSetElement.cpp b/WebCore/html/HTMLFieldSetElement.cpp
index eb83173..b792075 100644
--- a/WebCore/html/HTMLFieldSetElement.cpp
+++ b/WebCore/html/HTMLFieldSetElement.cpp
@@ -48,9 +48,9 @@ bool HTMLFieldSetElement::checkDTD(const Node* newChild)
return newChild->hasTagName(legendTag) || HTMLElement::checkDTD(newChild);
}
-bool HTMLFieldSetElement::isFocusable() const
+bool HTMLFieldSetElement::supportsFocus() const
{
- return HTMLElement::isFocusable();
+ return HTMLElement::supportsFocus();
}
const AtomicString& HTMLFieldSetElement::formControlType() const
diff --git a/WebCore/html/HTMLFieldSetElement.h b/WebCore/html/HTMLFieldSetElement.h
index e79f2c5..0900317 100644
--- a/WebCore/html/HTMLFieldSetElement.h
+++ b/WebCore/html/HTMLFieldSetElement.h
@@ -44,7 +44,7 @@ public:
virtual int tagPriority() const { return 3; }
virtual bool checkDTD(const Node* newChild);
- virtual bool isFocusable() const;
+ virtual bool supportsFocus() const;
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual const AtomicString& formControlType() const;
diff --git a/WebCore/html/HTMLFieldSetElement.idl b/WebCore/html/HTMLFieldSetElement.idl
index 4d11304..ca8563b 100644
--- a/WebCore/html/HTMLFieldSetElement.idl
+++ b/WebCore/html/HTMLFieldSetElement.idl
@@ -29,6 +29,7 @@ module html {
readonly attribute ValidityState validity;
#endif
readonly attribute boolean willValidate;
+ boolean checkValidity();
void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error);
};
diff --git a/WebCore/html/HTMLFormControlElement.cpp b/WebCore/html/HTMLFormControlElement.cpp
index 09d91df..ea46980 100644
--- a/WebCore/html/HTMLFormControlElement.cpp
+++ b/WebCore/html/HTMLFormControlElement.cpp
@@ -27,6 +27,7 @@
#include "ChromeClient.h"
#include "Document.h"
+#include "Event.h"
#include "EventHandler.h"
#include "EventNames.h"
#include "Frame.h"
@@ -38,7 +39,9 @@
#include "MappedAttribute.h"
#include "Page.h"
#include "RenderBox.h"
+#include "RenderTextControl.h"
#include "RenderTheme.h"
+#include "ScriptEventListener.h"
#include "ValidityState.h"
namespace WebCore {
@@ -50,6 +53,7 @@ HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc
, m_form(f)
, m_disabled(false)
, m_readOnly(false)
+ , m_required(false)
, m_valueMatchesRenderer(false)
{
if (!m_form)
@@ -64,6 +68,16 @@ HTMLFormControlElement::~HTMLFormControlElement()
m_form->removeFormElement(this);
}
+bool HTMLFormControlElement::formNoValidate() const
+{
+ return !getAttribute(formnovalidateAttr).isNull();
+}
+
+void HTMLFormControlElement::setFormNoValidate(bool formnovalidate)
+{
+ setAttribute(formnovalidateAttr, formnovalidate ? "" : 0);
+}
+
ValidityState* HTMLFormControlElement::validity()
{
if (!m_validityState)
@@ -74,9 +88,9 @@ ValidityState* HTMLFormControlElement::validity()
void HTMLFormControlElement::parseMappedAttribute(MappedAttribute *attr)
{
- if (attr->name() == nameAttr) {
- // Do nothing.
- } else if (attr->name() == disabledAttr) {
+ if (attr->name() == nameAttr)
+ setNeedsStyleRecalc();
+ else if (attr->name() == disabledAttr) {
bool oldDisabled = m_disabled;
m_disabled = !attr->isNull();
if (oldDisabled != m_disabled) {
@@ -92,6 +106,11 @@ void HTMLFormControlElement::parseMappedAttribute(MappedAttribute *attr)
if (renderer() && renderer()->style()->hasAppearance())
renderer()->theme()->stateChanged(renderer(), ReadOnlyState);
}
+ } else if (attr->name() == requiredAttr) {
+ bool oldRequired = m_required;
+ m_required = !attr->isNull();
+ if (oldRequired != m_required)
+ setNeedsStyleRecalc();
} else
HTMLElement::parseMappedAttribute(attr);
}
@@ -176,7 +195,7 @@ void HTMLFormControlElement::setName(const AtomicString &value)
void HTMLFormControlElement::dispatchFormControlChangeEvent()
{
- dispatchEvent(eventNames().changeEvent, true, false);
+ dispatchEvent(Event::create(eventNames().changeEvent, true, false));
}
bool HTMLFormControlElement::disabled() const
@@ -206,7 +225,7 @@ void HTMLFormControlElement::setAutofocus(bool b)
bool HTMLFormControlElement::required() const
{
- return hasAttribute(requiredAttr);
+ return m_required;
}
void HTMLFormControlElement::setRequired(bool b)
@@ -222,13 +241,19 @@ void HTMLFormControlElement::recalcStyle(StyleChange change)
renderer()->updateFromElement();
}
+bool HTMLFormControlElement::supportsFocus() const
+{
+ return !disabled();
+}
+
bool HTMLFormControlElement::isFocusable() const
{
- if (disabled() || !renderer() ||
- (renderer()->style() && renderer()->style()->visibility() != VISIBLE) ||
+ if (!renderer() ||
!renderer()->isBox() || toRenderBox(renderer())->size().isEmpty())
return false;
- return true;
+ // HTMLElement::isFocusable handles visibility and calls suportsFocus which
+ // will cover the disabled case.
+ return HTMLElement::isFocusable();
}
bool HTMLFormControlElement::isKeyboardFocusable(KeyboardEvent* event) const
@@ -260,7 +285,25 @@ bool HTMLFormControlElement::willValidate() const
// The control does not have a repetition template as an ancestor.
// The control does not have a datalist element as an ancestor.
// The control is not an output element.
- return form() && name().length() && !disabled() && !isReadOnlyFormControl();
+ return form() && !name().isEmpty() && !disabled() && !isReadOnlyFormControl();
+}
+
+bool HTMLFormControlElement::checkValidity()
+{
+ if (willValidate() && !isValidFormControlElement()) {
+ dispatchEvent(Event::create(EventNames().invalidEvent, false, true));
+ return false;
+ }
+
+ return true;
+}
+
+void HTMLFormControlElement::updateValidity()
+{
+ if (willValidate()) {
+ // Update style for pseudo classes such as :valid :invalid.
+ setNeedsStyleRecalc();
+ }
}
void HTMLFormControlElement::setCustomValidity(const String& error)
@@ -284,14 +327,19 @@ void HTMLFormControlElement::dispatchBlurEvent()
HTMLElement::dispatchBlurEvent();
}
-bool HTMLFormControlElement::supportsFocus() const
+HTMLFormElement* HTMLFormControlElement::virtualForm() const
{
- return isFocusable() || (!disabled() && !document()->haveStylesheetsLoaded());
+ return m_form;
}
-HTMLFormElement* HTMLFormControlElement::virtualForm() const
+bool HTMLFormControlElement::isDefaultButtonForForm() const
{
- return m_form;
+ return isSuccessfulSubmitButton() && m_form && m_form->defaultButton() == this;
+}
+
+bool HTMLFormControlElement::isValidFormControlElement()
+{
+ return validity()->valid();
}
void HTMLFormControlElement::removeFromForm()
@@ -336,4 +384,120 @@ void HTMLFormControlElementWithState::finishParsingChildren()
}
}
+HTMLTextFormControlElement::HTMLTextFormControlElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* form)
+ : HTMLFormControlElementWithState(tagName, doc, form)
+{
+}
+
+HTMLTextFormControlElement::~HTMLTextFormControlElement()
+{
+}
+
+void HTMLTextFormControlElement::dispatchFocusEvent()
+{
+ if (supportsPlaceholder())
+ updatePlaceholderVisibility(false);
+ handleFocusEvent();
+ HTMLFormControlElementWithState::dispatchFocusEvent();
+}
+
+void HTMLTextFormControlElement::dispatchBlurEvent()
+{
+ if (supportsPlaceholder())
+ updatePlaceholderVisibility(false);
+ handleBlurEvent();
+ HTMLFormControlElementWithState::dispatchBlurEvent();
+}
+
+bool HTMLTextFormControlElement::placeholderShouldBeVisible() const
+{
+ return supportsPlaceholder()
+ && isEmptyValue()
+ && document()->focusedNode() != this
+ && !getAttribute(placeholderAttr).isEmpty();
+}
+
+void HTMLTextFormControlElement::updatePlaceholderVisibility(bool placeholderValueChanged)
+{
+ if (supportsPlaceholder() && renderer())
+ toRenderTextControl(renderer())->updatePlaceholderVisibility(placeholderShouldBeVisible(), placeholderValueChanged);
+}
+
+RenderTextControl* HTMLTextFormControlElement::textRendererAfterUpdateLayout()
+{
+ if (!isTextFormControl())
+ return 0;
+ document()->updateLayoutIgnorePendingStylesheets();
+ return toRenderTextControl(renderer());
+}
+
+void HTMLTextFormControlElement::setSelectionStart(int start)
+{
+ if (RenderTextControl* renderer = textRendererAfterUpdateLayout())
+ renderer->setSelectionStart(start);
+}
+
+void HTMLTextFormControlElement::setSelectionEnd(int end)
+{
+ if (RenderTextControl* renderer = textRendererAfterUpdateLayout())
+ renderer->setSelectionEnd(end);
+}
+
+void HTMLTextFormControlElement::select()
+{
+ if (RenderTextControl* renderer = textRendererAfterUpdateLayout())
+ renderer->select();
+}
+
+void HTMLTextFormControlElement::setSelectionRange(int start, int end)
+{
+ if (RenderTextControl* renderer = textRendererAfterUpdateLayout())
+ renderer->setSelectionRange(start, end);
+}
+
+int HTMLTextFormControlElement::selectionStart()
+{
+ if (!isTextFormControl())
+ return 0;
+ if (document()->focusedNode() != this && cachedSelectionStart() >= 0)
+ return cachedSelectionStart();
+ if (!renderer())
+ return 0;
+ return toRenderTextControl(renderer())->selectionStart();
+}
+
+int HTMLTextFormControlElement::selectionEnd()
+{
+ if (!isTextFormControl())
+ return 0;
+ if (document()->focusedNode() != this && cachedSelectionEnd() >= 0)
+ return cachedSelectionEnd();
+ if (!renderer())
+ return 0;
+ return toRenderTextControl(renderer())->selectionEnd();
+}
+
+VisibleSelection HTMLTextFormControlElement::selection() const
+{
+ if (!renderer() || !isTextFormControl() || cachedSelectionStart() < 0 || cachedSelectionEnd() < 0)
+ return VisibleSelection();
+ return toRenderTextControl(renderer())->selection(cachedSelectionStart(), cachedSelectionEnd());
+}
+
+void HTMLTextFormControlElement::parseMappedAttribute(MappedAttribute* attr)
+{
+ if (attr->name() == placeholderAttr)
+ updatePlaceholderVisibility(true);
+ else if (attr->name() == onfocusAttr)
+ setAttributeEventListener(eventNames().focusEvent, createAttributeEventListener(this, attr));
+ else if (attr->name() == onblurAttr)
+ setAttributeEventListener(eventNames().blurEvent, createAttributeEventListener(this, attr));
+ else if (attr->name() == onselectAttr)
+ setAttributeEventListener(eventNames().selectEvent, createAttributeEventListener(this, attr));
+ else if (attr->name() == onchangeAttr)
+ setAttributeEventListener(eventNames().changeEvent, createAttributeEventListener(this, attr));
+ else
+ HTMLFormControlElementWithState::parseMappedAttribute(attr);
+}
+
} // namespace Webcore
diff --git a/WebCore/html/HTMLFormControlElement.h b/WebCore/html/HTMLFormControlElement.h
index a30f46c..b5dc7ce 100644
--- a/WebCore/html/HTMLFormControlElement.h
+++ b/WebCore/html/HTMLFormControlElement.h
@@ -30,7 +30,9 @@ namespace WebCore {
class FormDataList;
class HTMLFormElement;
+class RenderTextControl;
class ValidityState;
+class VisibleSelection;
class HTMLFormControlElement : public HTMLElement {
public:
@@ -43,6 +45,9 @@ public:
HTMLFormElement* form() const { return m_form; }
virtual ValidityState* validity();
+ bool formNoValidate() const;
+ void setFormNoValidate(bool);
+
virtual bool isTextFormControl() const { return false; }
virtual bool isEnabledFormControl() const { return !disabled(); }
@@ -102,10 +107,12 @@ public:
virtual short tabIndex() const;
virtual bool willValidate() const;
+ bool checkValidity();
+ void updateValidity();
void setCustomValidity(const String&);
-
virtual bool valueMissing() const { return false; }
virtual bool patternMismatch() const { return false; }
+ virtual bool tooLong() const { return false; }
void formDestroyed() { m_form = 0; }
@@ -117,12 +124,15 @@ protected:
private:
virtual HTMLFormElement* virtualForm() const;
+ virtual bool isDefaultButtonForForm() const;
+ virtual bool isValidFormControlElement();
HTMLFormElement* m_form;
RefPtr<ValidityState> m_validityState;
- bool m_disabled;
- bool m_readOnly;
- bool m_valueMatchesRenderer;
+ bool m_disabled : 1;
+ bool m_readOnly : 1;
+ bool m_required : 1;
+ bool m_valueMatchesRenderer : 1;
};
class HTMLFormControlElementWithState : public HTMLFormControlElement {
@@ -137,6 +147,40 @@ protected:
virtual void didMoveToNewOwnerDocument();
};
+class HTMLTextFormControlElement : public HTMLFormControlElementWithState {
+public:
+ HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);
+ virtual ~HTMLTextFormControlElement();
+ virtual void dispatchFocusEvent();
+ virtual void dispatchBlurEvent();
+
+ int selectionStart();
+ int selectionEnd();
+ void setSelectionStart(int);
+ void setSelectionEnd(int);
+ void select();
+ void setSelectionRange(int start, int end);
+ VisibleSelection selection() const;
+
+protected:
+ bool placeholderShouldBeVisible() const;
+ void updatePlaceholderVisibility(bool);
+ virtual int cachedSelectionStart() const = 0;
+ virtual int cachedSelectionEnd() const = 0;
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+private:
+ // A subclass should return true if placeholder processing is needed.
+ virtual bool supportsPlaceholder() const = 0;
+ // Returns true if user-editable value is empty. This is used to check placeholder visibility.
+ virtual bool isEmptyValue() const = 0;
+ // Called in dispatchFocusEvent(), after placeholder process, before calling parent's dispatchFocusEvent().
+ virtual void handleFocusEvent() { }
+ // Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent().
+ virtual void handleBlurEvent() { }
+ RenderTextControl* textRendererAfterUpdateLayout();
+};
+
} //namespace
#endif
diff --git a/WebCore/html/HTMLFormElement.cpp b/WebCore/html/HTMLFormElement.cpp
index 54986b0..ace0f2f 100644
--- a/WebCore/html/HTMLFormElement.cpp
+++ b/WebCore/html/HTMLFormElement.cpp
@@ -47,6 +47,7 @@
#include "MappedAttribute.h"
#include "Page.h"
#include "RenderTextControl.h"
+#include "ValidityState.h"
#include <limits>
#include <wtf/CurrentTime.h>
#include <wtf/RandomNumber.h>
@@ -149,14 +150,14 @@ void HTMLFormElement::removedFromDocument()
HTMLElement::removedFromDocument();
}
-void HTMLFormElement::handleLocalEvents(Event* event, bool useCapture)
+void HTMLFormElement::handleLocalEvents(Event* event)
{
Node* targetNode = event->target()->toNode();
- if (!useCapture && targetNode && targetNode != this && (event->type() == eventNames().submitEvent || event->type() == eventNames().resetEvent)) {
+ if (event->eventPhase() != Event::CAPTURING_PHASE && targetNode && targetNode != this && (event->type() == eventNames().submitEvent || event->type() == eventNames().resetEvent)) {
event->stopPropagation();
return;
}
- HTMLElement::handleLocalEvents(event, useCapture);
+ HTMLElement::handleLocalEvents(event);
}
unsigned HTMLFormElement::length() const
@@ -295,7 +296,7 @@ bool HTMLFormElement::prepareSubmit(Event* event)
m_insubmit = true;
m_doingsubmit = false;
- if (dispatchEvent(eventNames().submitEvent, true, true) && !m_doingsubmit)
+ if (dispatchEvent(Event::create(eventNames().submitEvent, true, true)) && !m_doingsubmit)
m_doingsubmit = true;
m_insubmit = false;
@@ -415,7 +416,7 @@ void HTMLFormElement::reset()
// ### DOM2 labels this event as not cancelable, however
// common browsers( sick! ) allow it be cancelled.
- if ( !dispatchEvent(eventNames().resetEvent, true, true) ) {
+ if (!dispatchEvent(Event::create(eventNames().resetEvent, true, true))) {
m_inreset = false;
return;
}
@@ -537,6 +538,16 @@ void HTMLFormElement::setName(const String &value)
setAttribute(nameAttr, value);
}
+bool HTMLFormElement::noValidate() const
+{
+ return !getAttribute(novalidateAttr).isNull();
+}
+
+void HTMLFormElement::setNoValidate(bool novalidate)
+{
+ setAttribute(novalidateAttr, novalidate ? "" : 0);
+}
+
void HTMLFormElement::setAcceptCharset(const String &value)
{
setAttribute(accept_charsetAttr, value);
@@ -577,6 +588,31 @@ void HTMLFormElement::setTarget(const String &value)
setAttribute(targetAttr, value);
}
+HTMLFormControlElement* HTMLFormElement::defaultButton() const
+{
+ for (unsigned i = 0; i < formElements.size(); ++i) {
+ HTMLFormControlElement* control = formElements[i];
+ if (control->isSuccessfulSubmitButton())
+ return control;
+ }
+
+ return 0;
+}
+
+bool HTMLFormElement::checkValidity()
+{
+ // TODO: Check for unhandled invalid controls, see #27452 for tips.
+
+ bool hasOnlyValidControls = true;
+ for (unsigned i = 0; i < formElements.size(); ++i) {
+ HTMLFormControlElement* control = formElements[i];
+ if (!control->checkValidity())
+ hasOnlyValidControls = false;
+ }
+
+ return hasOnlyValidControls;
+}
+
PassRefPtr<HTMLFormControlElement> HTMLFormElement::elementForAlias(const AtomicString& alias)
{
if (alias.isEmpty() || !m_elementAliases)
diff --git a/WebCore/html/HTMLFormElement.h b/WebCore/html/HTMLFormElement.h
index 6b7812a..a2e9585 100644
--- a/WebCore/html/HTMLFormElement.h
+++ b/WebCore/html/HTMLFormElement.h
@@ -54,7 +54,7 @@ public:
virtual void insertedIntoDocument();
virtual void removedFromDocument();
- virtual void handleLocalEvents(Event*, bool useCapture);
+ virtual void handleLocalEvents(Event*);
PassRefPtr<HTMLCollection> elements();
void getNamedElements(const AtomicString&, Vector<RefPtr<Node> >&);
@@ -96,6 +96,9 @@ public:
String name() const;
void setName(const String&);
+ bool noValidate() const;
+ void setNoValidate(bool);
+
String acceptCharset() const { return m_formDataBuilder.acceptCharset(); }
void setAcceptCharset(const String&);
@@ -107,7 +110,11 @@ public:
virtual String target() const;
void setTarget(const String&);
-
+
+ HTMLFormControlElement* defaultButton() const;
+
+ bool checkValidity();
+
PassRefPtr<HTMLFormControlElement> elementForAlias(const AtomicString&);
void addElementAlias(HTMLFormControlElement*, const AtomicString& alias);
diff --git a/WebCore/html/HTMLFormElement.idl b/WebCore/html/HTMLFormElement.idl
index f3aca87..3e846d6 100644
--- a/WebCore/html/HTMLFormElement.idl
+++ b/WebCore/html/HTMLFormElement.idl
@@ -30,6 +30,7 @@ module html {
readonly attribute HTMLCollection elements;
readonly attribute long length;
attribute [ConvertNullToNullString] DOMString name;
+ attribute boolean noValidate;
attribute [ConvertNullToNullString] DOMString acceptCharset;
attribute [ConvertNullToNullString] DOMString action;
attribute [ConvertNullToNullString] DOMString encoding; /* Netscape/Firefox legacy attribute. Same as enctype. */
@@ -39,5 +40,6 @@ module html {
[Custom] void submit();
void reset();
+ boolean checkValidity();
};
}
diff --git a/WebCore/html/HTMLFrameElement.cpp b/WebCore/html/HTMLFrameElement.cpp
index adc3ff1..b456ac3 100644
--- a/WebCore/html/HTMLFrameElement.cpp
+++ b/WebCore/html/HTMLFrameElement.cpp
@@ -1,9 +1,9 @@
-/**
+/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Simon Hausmann (hausmann@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -34,18 +34,24 @@ namespace WebCore {
using namespace HTMLNames;
-HTMLFrameElement::HTMLFrameElement(const QualifiedName& tagName, Document* document)
+inline HTMLFrameElement::HTMLFrameElement(const QualifiedName& tagName, Document* document)
: HTMLFrameElementBase(tagName, document)
, m_frameBorder(true)
, m_frameBorderSet(false)
+ , m_noResize(false)
{
ASSERT(hasTagName(frameTag));
}
+PassRefPtr<HTMLFrameElement> HTMLFrameElement::create(const QualifiedName& tagName, Document* document)
+{
+ return adoptRef(new HTMLFrameElement(tagName, document));
+}
+
bool HTMLFrameElement::rendererIsNeeded(RenderStyle*)
{
// For compatibility, frames render even when display: none is set.
- return isURLAllowed(m_URL);
+ return isURLAllowed();
}
RenderObject* HTMLFrameElement::createRenderer(RenderArena* arena, RenderStyle*)
@@ -55,9 +61,10 @@ RenderObject* HTMLFrameElement::createRenderer(RenderArena* arena, RenderStyle*)
static inline HTMLFrameSetElement* containingFrameSetElement(Node* node)
{
- while ((node = node->parentNode()))
+ while ((node = node->parentNode())) {
if (node->hasTagName(framesetTag))
return static_cast<HTMLFrameSetElement*>(node);
+ }
return 0;
}
@@ -73,14 +80,26 @@ void HTMLFrameElement::attach()
}
}
-void HTMLFrameElement::parseMappedAttribute(MappedAttribute *attr)
+void HTMLFrameElement::parseMappedAttribute(MappedAttribute* attr)
{
if (attr->name() == frameborderAttr) {
m_frameBorder = attr->value().toInt();
m_frameBorderSet = !attr->isNull();
// FIXME: If we are already attached, this has no effect.
+ } else if (attr->name() == noresizeAttr) {
+ m_noResize = true;
+ // FIXME: If we are already attached, this has no effect.
+ // FIXME: Since this does not check attr->isNull(), it can
+ // never reset m_noResize to false if the attribute is removed.
+ // FIXME: There seems to be no code that looks at this
+ // value and prevents resizing.
} else
HTMLFrameElementBase::parseMappedAttribute(attr);
}
+void HTMLFrameElement::setNoResize(bool noResize)
+{
+ setAttribute(noresizeAttr, noResize ? "" : 0);
+}
+
} // namespace WebCore
diff --git a/WebCore/html/HTMLFrameElement.h b/WebCore/html/HTMLFrameElement.h
index ab602ee..4a8e16c 100644
--- a/WebCore/html/HTMLFrameElement.h
+++ b/WebCore/html/HTMLFrameElement.h
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Simon Hausmann <hausmann@kde.org>
- * Copyright (C) 2004, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -28,13 +28,16 @@
namespace WebCore {
-class Document;
-class RenderObject;
-class RenderArena;
-class RenderStyle;
-
class HTMLFrameElement : public HTMLFrameElementBase {
public:
+ static PassRefPtr<HTMLFrameElement> create(const QualifiedName&, Document*);
+
+ bool hasFrameBorder() const { return m_frameBorder; }
+
+ bool noResize() const { return m_noResize; }
+ void setNoResize(bool);
+
+private:
HTMLFrameElement(const QualifiedName&, Document*);
virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
@@ -47,11 +50,10 @@ public:
virtual void parseMappedAttribute(MappedAttribute*);
- bool hasFrameBorder() const { return m_frameBorder; }
-
-private:
bool m_frameBorder;
bool m_frameBorderSet;
+
+ bool m_noResize;
};
} // namespace WebCore
diff --git a/WebCore/html/HTMLFrameElement.idl b/WebCore/html/HTMLFrameElement.idl
index 106e57e..d0076eb 100644
--- a/WebCore/html/HTMLFrameElement.idl
+++ b/WebCore/html/HTMLFrameElement.idl
@@ -26,14 +26,14 @@ module html {
ImplementationUUID=38c9e3c8-3384-40b6-a484-cb845c48b67d
] HTMLFrameElement : HTMLElement {
- attribute [ConvertNullToNullString] DOMString frameBorder;
- attribute [ConvertNullToNullString] DOMString longDesc;
- attribute [ConvertNullToNullString] DOMString marginHeight;
- attribute [ConvertNullToNullString] DOMString marginWidth;
- attribute [ConvertNullToNullString] DOMString name;
+ attribute [ConvertNullToNullString, Reflect=frameborder] DOMString frameBorder;
+ attribute [ConvertNullToNullString, Reflect=longdesc] DOMString longDesc;
+ attribute [ConvertNullToNullString, Reflect=marginheight] DOMString marginHeight;
+ attribute [ConvertNullToNullString, Reflect=marginwidth] DOMString marginWidth;
+ attribute [ConvertNullToNullString, Reflect] DOMString name;
attribute boolean noResize;
- attribute [ConvertNullToNullString] DOMString scrolling;
- attribute [ConvertNullToNullString, CustomSetter] DOMString src;
+ attribute [ConvertNullToNullString, Reflect] DOMString scrolling;
+ attribute [ConvertNullToNullString, CustomSetter, ReflectURL] DOMString src;
// Introduced in DOM Level 2:
readonly attribute [CheckFrameSecurity] Document contentDocument;
diff --git a/WebCore/html/HTMLFrameElementBase.cpp b/WebCore/html/HTMLFrameElementBase.cpp
index a4f0a5e..1bc4995 100644
--- a/WebCore/html/HTMLFrameElementBase.cpp
+++ b/WebCore/html/HTMLFrameElementBase.cpp
@@ -50,18 +50,17 @@ HTMLFrameElementBase::HTMLFrameElementBase(const QualifiedName& tagName, Documen
, m_scrolling(ScrollbarAuto)
, m_marginWidth(-1)
, m_marginHeight(-1)
- , m_noResize(false)
, m_viewSource(false)
, m_shouldOpenURLAfterAttach(false)
{
}
-bool HTMLFrameElementBase::isURLAllowed(const AtomicString& URLString) const
+bool HTMLFrameElementBase::isURLAllowed() const
{
- if (URLString.isEmpty())
+ if (m_URL.isEmpty())
return true;
- const KURL& completeURL = document()->completeURL(URLString);
+ const KURL& completeURL = document()->completeURL(m_URL);
// Don't allow more than 200 total frames in a set. This seems
// like a reasonable upper bound, and otherwise mutually recursive
@@ -93,7 +92,7 @@ void HTMLFrameElementBase::openURL()
{
ASSERT(!m_frameName.isEmpty());
- if (!isURLAllowed(m_URL))
+ if (!isURLAllowed())
return;
if (m_URL.isEmpty())
@@ -127,9 +126,6 @@ void HTMLFrameElementBase::parseMappedAttribute(MappedAttribute *attr)
} else if (attr->name() == marginheightAttr) {
m_marginHeight = attr->value().toInt();
// FIXME: If we are already attached, this has no effect.
- } else if (attr->name() == noresizeAttr) {
- m_noResize = true;
- // FIXME: If we are already attached, this has no effect.
} else if (attr->name() == scrollingAttr) {
// Auto and yes both simply mean "allow scrolling." No means "don't allow scrolling."
if (equalIgnoringCase(attr->value(), "auto") || equalIgnoringCase(attr->value(), "yes"))
@@ -201,7 +197,7 @@ void HTMLFrameElementBase::attach()
KURL HTMLFrameElementBase::location() const
{
- return src();
+ return document()->completeURL(getAttribute(srcAttr));
}
void HTMLFrameElementBase::setLocation(const String& str)
@@ -216,9 +212,9 @@ void HTMLFrameElementBase::setLocation(const String& str)
openURL();
}
-bool HTMLFrameElementBase::isFocusable() const
+bool HTMLFrameElementBase::supportsFocus() const
{
- return renderer();
+ return true;
}
void HTMLFrameElementBase::setFocus(bool received)
@@ -233,81 +229,6 @@ bool HTMLFrameElementBase::isURLAttribute(Attribute *attr) const
return attr->name() == srcAttr;
}
-String HTMLFrameElementBase::frameBorder() const
-{
- return getAttribute(frameborderAttr);
-}
-
-void HTMLFrameElementBase::setFrameBorder(const String &value)
-{
- setAttribute(frameborderAttr, value);
-}
-
-String HTMLFrameElementBase::longDesc() const
-{
- return getAttribute(longdescAttr);
-}
-
-void HTMLFrameElementBase::setLongDesc(const String &value)
-{
- setAttribute(longdescAttr, value);
-}
-
-String HTMLFrameElementBase::marginHeight() const
-{
- return getAttribute(marginheightAttr);
-}
-
-void HTMLFrameElementBase::setMarginHeight(const String &value)
-{
- setAttribute(marginheightAttr, value);
-}
-
-String HTMLFrameElementBase::marginWidth() const
-{
- return getAttribute(marginwidthAttr);
-}
-
-void HTMLFrameElementBase::setMarginWidth(const String &value)
-{
- setAttribute(marginwidthAttr, value);
-}
-
-String HTMLFrameElementBase::name() const
-{
- return getAttribute(nameAttr);
-}
-
-void HTMLFrameElementBase::setName(const String &value)
-{
- setAttribute(nameAttr, value);
-}
-
-void HTMLFrameElementBase::setNoResize(bool noResize)
-{
- setAttribute(noresizeAttr, noResize ? "" : 0);
-}
-
-String HTMLFrameElementBase::scrolling() const
-{
- return getAttribute(scrollingAttr);
-}
-
-void HTMLFrameElementBase::setScrolling(const String &value)
-{
- setAttribute(scrollingAttr, value);
-}
-
-KURL HTMLFrameElementBase::src() const
-{
- return document()->completeURL(getAttribute(srcAttr));
-}
-
-void HTMLFrameElementBase::setSrc(const String &value)
-{
- setAttribute(srcAttr, value);
-}
-
int HTMLFrameElementBase::width() const
{
if (!renderer())
diff --git a/WebCore/html/HTMLFrameElementBase.h b/WebCore/html/HTMLFrameElementBase.h
index 4a24451..c211ba7 100644
--- a/WebCore/html/HTMLFrameElementBase.h
+++ b/WebCore/html/HTMLFrameElementBase.h
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Simon Hausmann <hausmann@kde.org>
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -31,60 +31,39 @@ namespace WebCore {
class HTMLFrameElementBase : public HTMLFrameOwnerElement {
public:
- virtual void parseMappedAttribute(MappedAttribute*);
-
- virtual void insertedIntoDocument();
- virtual void removedFromDocument();
-
- virtual void attach();
- virtual bool canLazyAttach() { return false; }
-
KURL location() const;
void setLocation(const String&);
- virtual bool isFocusable() const;
- virtual void setFocus(bool);
-
- virtual bool isURLAttribute(Attribute*) const;
-
virtual ScrollbarMode scrollingMode() const { return m_scrolling; }
int getMarginWidth() const { return m_marginWidth; }
int getMarginHeight() const { return m_marginHeight; }
- String frameBorder() const;
- void setFrameBorder(const String&);
-
- String longDesc() const;
- void setLongDesc(const String&);
+ int width() const;
+ int height() const;
- String marginHeight() const;
- void setMarginHeight(const String&);
+protected:
+ HTMLFrameElementBase(const QualifiedName&, Document*);
- String marginWidth() const;
- void setMarginWidth(const String&);
+ bool isURLAllowed() const;
- String name() const;
- void setName(const String&);
+ virtual void parseMappedAttribute(MappedAttribute*);
- bool noResize() const { return m_noResize; }
- void setNoResize(bool);
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
- String scrolling() const;
- void setScrolling(const String&);
+ virtual void attach();
- KURL src() const;
- void setSrc(const String&);
+private:
+ virtual bool canLazyAttach() { return false; }
- int width() const;
- int height() const;
+ virtual bool supportsFocus() const;
+ virtual void setFocus(bool);
+
+ virtual bool isURLAttribute(Attribute*) const;
bool viewSourceMode() const { return m_viewSource; }
-protected:
- HTMLFrameElementBase(const QualifiedName&, Document*);
-
- bool isURLAllowed(const AtomicString&) const;
void setNameAndOpenURL();
void openURL();
@@ -98,7 +77,6 @@ protected:
int m_marginWidth;
int m_marginHeight;
- bool m_noResize;
bool m_viewSource;
bool m_shouldOpenURLAfterAttach;
diff --git a/WebCore/html/HTMLFrameOwnerElement.cpp b/WebCore/html/HTMLFrameOwnerElement.cpp
index a98a3df..84958c2 100644
--- a/WebCore/html/HTMLFrameOwnerElement.cpp
+++ b/WebCore/html/HTMLFrameOwnerElement.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -33,7 +33,7 @@
namespace WebCore {
HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Document* document)
- : HTMLElement(tagName, document)
+ : HTMLElement(tagName, document, CreateElement)
, m_contentFrame(0)
{
}
diff --git a/WebCore/html/HTMLFrameOwnerElement.h b/WebCore/html/HTMLFrameOwnerElement.h
index 3f50a02..1437e2c 100644
--- a/WebCore/html/HTMLFrameOwnerElement.h
+++ b/WebCore/html/HTMLFrameOwnerElement.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -27,36 +27,36 @@ namespace WebCore {
class DOMWindow;
class Frame;
-class KeyboardEvent;
#if ENABLE(SVG)
class SVGDocument;
#endif
class HTMLFrameOwnerElement : public HTMLElement {
-protected:
- HTMLFrameOwnerElement(const QualifiedName& tagName, Document*);
-
public:
virtual ~HTMLFrameOwnerElement();
- virtual void willRemove();
-
Frame* contentFrame() const { return m_contentFrame; }
DOMWindow* contentWindow() const;
Document* contentDocument() const;
- virtual bool isFrameOwnerElement() const { return true; }
- virtual bool isKeyboardFocusable(KeyboardEvent*) const { return m_contentFrame; }
-
- virtual ScrollbarMode scrollingMode() const { return ScrollbarAuto; }
-
#if ENABLE(SVG)
SVGDocument* getSVGDocument(ExceptionCode&) const;
#endif
+ virtual ScrollbarMode scrollingMode() const { return ScrollbarAuto; }
+
+protected:
+ HTMLFrameOwnerElement(const QualifiedName& tagName, Document*);
+
private:
friend class Frame;
+
+ virtual bool isFrameOwnerElement() const { return true; }
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const { return m_contentFrame; }
+
+ virtual void willRemove();
+
Frame* m_contentFrame;
};
diff --git a/WebCore/html/HTMLFrameSetElement.cpp b/WebCore/html/HTMLFrameSetElement.cpp
index a8f544b..5874b84 100644
--- a/WebCore/html/HTMLFrameSetElement.cpp
+++ b/WebCore/html/HTMLFrameSetElement.cpp
@@ -135,6 +135,10 @@ void HTMLFrameSetElement::parseMappedAttribute(MappedAttribute *attr)
document()->setWindowAttributeEventListener(eventNames().blurEvent, createAttributeEventListener(document()->frame(), attr));
else if (attr->name() == onfocusAttr)
document()->setWindowAttributeEventListener(eventNames().focusEvent, createAttributeEventListener(document()->frame(), attr));
+#if ENABLE(ORIENTATION_EVENTS)
+ else if (attr->name() == onorientationchangeAttr)
+ document()->setWindowAttributeEventListener(eventNames().orientationchangeEvent, createAttributeEventListener(document()->frame(), attr));
+#endif
else if (attr->name() == onhashchangeAttr)
document()->setWindowAttributeEventListener(eventNames().hashchangeEvent, createAttributeEventListener(document()->frame(), attr));
else if (attr->name() == onresizeAttr)
@@ -233,114 +237,4 @@ void HTMLFrameSetElement::setRows(const String &value)
setAttribute(rowsAttr, value);
}
-EventListener* HTMLFrameSetElement::onblur() const
-{
- return document()->getWindowAttributeEventListener(eventNames().blurEvent);
-}
-
-void HTMLFrameSetElement::setOnblur(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().blurEvent, eventListener);
-}
-
-EventListener* HTMLFrameSetElement::onerror() const
-{
- return document()->getWindowAttributeEventListener(eventNames().errorEvent);
-}
-
-void HTMLFrameSetElement::setOnerror(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().errorEvent, eventListener);
-}
-
-EventListener* HTMLFrameSetElement::onfocus() const
-{
- return document()->getWindowAttributeEventListener(eventNames().focusEvent);
-}
-
-void HTMLFrameSetElement::setOnfocus(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().focusEvent, eventListener);
-}
-
-EventListener* HTMLFrameSetElement::onload() const
-{
- return document()->getWindowAttributeEventListener(eventNames().loadEvent);
-}
-
-void HTMLFrameSetElement::setOnload(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().loadEvent, eventListener);
-}
-
-EventListener* HTMLFrameSetElement::onbeforeunload() const
-{
- return document()->getWindowAttributeEventListener(eventNames().beforeunloadEvent);
-}
-
-void HTMLFrameSetElement::setOnbeforeunload(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().beforeunloadEvent, eventListener);
-}
-
-EventListener* HTMLFrameSetElement::onmessage() const
-{
- return document()->getWindowAttributeEventListener(eventNames().messageEvent);
-}
-
-void HTMLFrameSetElement::setOnmessage(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().messageEvent, eventListener);
-}
-
-EventListener* HTMLFrameSetElement::onoffline() const
-{
- return document()->getWindowAttributeEventListener(eventNames().offlineEvent);
-}
-
-void HTMLFrameSetElement::setOnoffline(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().offlineEvent, eventListener);
-}
-
-EventListener* HTMLFrameSetElement::ononline() const
-{
- return document()->getWindowAttributeEventListener(eventNames().onlineEvent);
-}
-
-void HTMLFrameSetElement::setOnonline(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().onlineEvent, eventListener);
-}
-
-EventListener* HTMLFrameSetElement::onresize() const
-{
- return document()->getWindowAttributeEventListener(eventNames().resizeEvent);
-}
-
-void HTMLFrameSetElement::setOnresize(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().resizeEvent, eventListener);
-}
-
-EventListener* HTMLFrameSetElement::onstorage() const
-{
- return document()->getWindowAttributeEventListener(eventNames().storageEvent);
-}
-
-void HTMLFrameSetElement::setOnstorage(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().storageEvent, eventListener);
-}
-
-EventListener* HTMLFrameSetElement::onunload() const
-{
- return document()->getWindowAttributeEventListener(eventNames().unloadEvent);
-}
-
-void HTMLFrameSetElement::setOnunload(PassRefPtr<EventListener> eventListener)
-{
- document()->setAttributeEventListener(eventNames().unloadEvent, eventListener);
-}
-
} // namespace WebCore
diff --git a/WebCore/html/HTMLFrameSetElement.h b/WebCore/html/HTMLFrameSetElement.h
index 4319c7a..2b2d7ea 100644
--- a/WebCore/html/HTMLFrameSetElement.h
+++ b/WebCore/html/HTMLFrameSetElement.h
@@ -24,8 +24,9 @@
#ifndef HTMLFrameSetElement_h
#define HTMLFrameSetElement_h
-#include "HTMLElement.h"
#include "Color.h"
+#include "Document.h"
+#include "HTMLElement.h"
namespace WebCore {
@@ -67,30 +68,23 @@ public:
const Length* rowLengths() const { return m_rows; }
const Length* colLengths() const { return m_cols; }
- // Event handler attributes
- virtual EventListener* onblur() const;
- virtual void setOnblur(PassRefPtr<EventListener>);
- virtual EventListener* onerror() const;
- virtual void setOnerror(PassRefPtr<EventListener>);
- virtual EventListener* onfocus() const;
- virtual void setOnfocus(PassRefPtr<EventListener>);
- virtual EventListener* onload() const;
- virtual void setOnload(PassRefPtr<EventListener>);
-
- EventListener* onbeforeunload() const;
- void setOnbeforeunload(PassRefPtr<EventListener>);
- EventListener* onmessage() const;
- void setOnmessage(PassRefPtr<EventListener>);
- EventListener* onoffline() const;
- void setOnoffline(PassRefPtr<EventListener>);
- EventListener* ononline() const;
- void setOnonline(PassRefPtr<EventListener>);
- EventListener* onresize() const;
- void setOnresize(PassRefPtr<EventListener>);
- EventListener* onstorage() const;
- void setOnstorage(PassRefPtr<EventListener>);
- EventListener* onunload() const;
- void setOnunload(PassRefPtr<EventListener>);
+ // Declared virtual in Element
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(blur);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(error);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(focus);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(load);
+
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(beforeunload);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(hashchange);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(message);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(offline);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(online);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(resize);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(storage);
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(unload);
+#if ENABLE(ORIENTATION_EVENTS)
+ DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(orientationchange);
+#endif
private:
Length* m_rows;
diff --git a/WebCore/html/HTMLFrameSetElement.idl b/WebCore/html/HTMLFrameSetElement.idl
index 4050f2c..b44a071 100644
--- a/WebCore/html/HTMLFrameSetElement.idl
+++ b/WebCore/html/HTMLFrameSetElement.idl
@@ -33,6 +33,7 @@ module html {
#if !defined(LANGUAGE_COM) || !LANGUAGE_COM
// Event handler attributes
attribute [DontEnum] EventListener onbeforeunload;
+ attribute [DontEnum] EventListener onhashchange;
attribute [DontEnum] EventListener onmessage;
attribute [DontEnum] EventListener onoffline;
attribute [DontEnum] EventListener ononline;
@@ -40,7 +41,11 @@ module html {
attribute [DontEnum] EventListener onstorage;
attribute [DontEnum] EventListener onunload;
- // Overrides of Element attributes.
+#if defined(ENABLE_ORIENTATION_EVENTS) && ENABLE_ORIENTATION_EVENTS
+ attribute [DontEnum] EventListener onorientationchange;
+#endif
+
+ // Overrides of Element attributes (left in for completeness).
// attribute [DontEnum] EventListener onblur;
// attribute [DontEnum] EventListener onerror;
// attribute [DontEnum] EventListener onfocus;
@@ -49,7 +54,6 @@ module html {
// Not implemented yet.
// attribute [DontEnum] EventListener onafterprint;
// attribute [DontEnum] EventListener onbeforeprint;
- // attribute [DontEnum] EventListener onhashchange;
// attribute [DontEnum] EventListener onpopstate;
// attribute [DontEnum] EventListener onredo;
// attribute [DontEnum] EventListener onundo;
diff --git a/WebCore/html/HTMLIFrameElement.cpp b/WebCore/html/HTMLIFrameElement.cpp
index 478925a..cae9b8d 100644
--- a/WebCore/html/HTMLIFrameElement.cpp
+++ b/WebCore/html/HTMLIFrameElement.cpp
@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Simon Hausmann (hausmann@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -35,12 +35,17 @@ namespace WebCore {
using namespace HTMLNames;
-HTMLIFrameElement::HTMLIFrameElement(const QualifiedName& tagName, Document* document)
+inline HTMLIFrameElement::HTMLIFrameElement(const QualifiedName& tagName, Document* document)
: HTMLFrameElementBase(tagName, document)
{
ASSERT(hasTagName(iframeTag));
}
+PassRefPtr<HTMLIFrameElement> HTMLIFrameElement::create(const QualifiedName& tagName, Document* document)
+{
+ return adoptRef(new HTMLIFrameElement(tagName, document));
+}
+
bool HTMLIFrameElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
{
if (attrName == widthAttr || attrName == heightAttr) {
@@ -89,7 +94,7 @@ void HTMLIFrameElement::parseMappedAttribute(MappedAttribute* attr)
bool HTMLIFrameElement::rendererIsNeeded(RenderStyle* style)
{
- return isURLAllowed(m_URL) && style->display() != NONE;
+ return isURLAllowed() && style->display() != NONE;
}
RenderObject* HTMLIFrameElement::createRenderer(RenderArena* arena, RenderStyle*)
@@ -126,34 +131,4 @@ bool HTMLIFrameElement::isURLAttribute(Attribute* attr) const
return attr->name() == srcAttr;
}
-String HTMLIFrameElement::align() const
-{
- return getAttribute(alignAttr);
-}
-
-void HTMLIFrameElement::setAlign(const String &value)
-{
- setAttribute(alignAttr, value);
-}
-
-String HTMLIFrameElement::height() const
-{
- return getAttribute(heightAttr);
-}
-
-void HTMLIFrameElement::setHeight(const String &value)
-{
- setAttribute(heightAttr, value);
-}
-
-String HTMLIFrameElement::width() const
-{
- return getAttribute(widthAttr);
-}
-
-void HTMLIFrameElement::setWidth(const String &value)
-{
- setAttribute(widthAttr, value);
-}
-
}
diff --git a/WebCore/html/HTMLIFrameElement.h b/WebCore/html/HTMLIFrameElement.h
index 362b991..f1c6a35 100644
--- a/WebCore/html/HTMLIFrameElement.h
+++ b/WebCore/html/HTMLIFrameElement.h
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Simon Hausmann <hausmann@kde.org>
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -30,6 +30,9 @@ namespace WebCore {
class HTMLIFrameElement : public HTMLFrameElementBase {
public:
+ static PassRefPtr<HTMLIFrameElement> create(const QualifiedName&, Document*);
+
+private:
HTMLIFrameElement(const QualifiedName&, Document*);
virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
@@ -48,16 +51,6 @@ public:
virtual bool isURLAttribute(Attribute*) const;
- String align() const;
- void setAlign(const String&);
-
- String height() const;
- void setHeight(const String&);
-
- String width() const;
- void setWidth(const String&);
-
-private:
AtomicString m_name;
};
diff --git a/WebCore/html/HTMLIFrameElement.idl b/WebCore/html/HTMLIFrameElement.idl
index b5684ca..e288b54 100644
--- a/WebCore/html/HTMLIFrameElement.idl
+++ b/WebCore/html/HTMLIFrameElement.idl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* This library is free software; you can redistribute it and/or
@@ -26,16 +26,16 @@ module html {
ImplementationUUID=370c6318-f804-49f9-bc8a-46b99cd87399
] HTMLIFrameElement : HTMLElement {
- attribute [ConvertNullToNullString] DOMString align;
- attribute [ConvertNullToNullString] DOMString frameBorder;
- attribute [ConvertNullToNullString] DOMString height;
- attribute [ConvertNullToNullString] DOMString longDesc;
- attribute [ConvertNullToNullString] DOMString marginHeight;
- attribute [ConvertNullToNullString] DOMString marginWidth;
- attribute [ConvertNullToNullString] DOMString name;
- attribute [ConvertNullToNullString] DOMString scrolling;
- attribute [ConvertNullToNullString, CustomSetter] DOMString src;
- attribute [ConvertNullToNullString] DOMString width;
+ attribute [ConvertNullToNullString, Reflect] DOMString align;
+ attribute [ConvertNullToNullString, Reflect=frameborder] DOMString frameBorder;
+ attribute [ConvertNullToNullString, Reflect] DOMString height;
+ attribute [ConvertNullToNullString, Reflect=longdesc] DOMString longDesc;
+ attribute [ConvertNullToNullString, Reflect=marginheight] DOMString marginHeight;
+ attribute [ConvertNullToNullString, Reflect=marginwidth] DOMString marginWidth;
+ attribute [ConvertNullToNullString, Reflect] DOMString name;
+ attribute [ConvertNullToNullString, Reflect] DOMString scrolling;
+ attribute [ConvertNullToNullString, CustomSetter, Reflect] DOMString src;
+ attribute [ConvertNullToNullString, Reflect] DOMString width;
// Introduced in DOM Level 2:
readonly attribute [CheckFrameSecurity] Document contentDocument;
diff --git a/WebCore/html/HTMLImageElement.cpp b/WebCore/html/HTMLImageElement.cpp
index 5173964..932e718 100644
--- a/WebCore/html/HTMLImageElement.cpp
+++ b/WebCore/html/HTMLImageElement.cpp
@@ -279,46 +279,11 @@ bool HTMLImageElement::isURLAttribute(Attribute* attr) const
|| (attr->name() == usemapAttr && attr->value().string()[0] != '#');
}
-String HTMLImageElement::name() const
-{
- return getAttribute(nameAttr);
-}
-
-void HTMLImageElement::setName(const String& value)
-{
- setAttribute(nameAttr, value);
-}
-
-String HTMLImageElement::align() const
-{
- return getAttribute(alignAttr);
-}
-
-void HTMLImageElement::setAlign(const String& value)
-{
- setAttribute(alignAttr, value);
-}
-
-String HTMLImageElement::alt() const
+const AtomicString& HTMLImageElement::alt() const
{
return getAttribute(altAttr);
}
-void HTMLImageElement::setAlt(const String& value)
-{
- setAttribute(altAttr, value);
-}
-
-String HTMLImageElement::border() const
-{
- return getAttribute(borderAttr);
-}
-
-void HTMLImageElement::setBorder(const String& value)
-{
- setAttribute(borderAttr, value);
-}
-
bool HTMLImageElement::draggable() const
{
// Image elements are draggable by default.
@@ -381,16 +346,6 @@ void HTMLImageElement::setSrc(const String& value)
setAttribute(srcAttr, value);
}
-String HTMLImageElement::useMap() const
-{
- return getAttribute(usemapAttr);
-}
-
-void HTMLImageElement::setUseMap(const String& value)
-{
- setAttribute(usemapAttr, value);
-}
-
int HTMLImageElement::vspace() const
{
// ### return actual vspace
@@ -439,7 +394,8 @@ void HTMLImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons
HTMLElement::addSubresourceAttributeURLs(urls);
addSubresourceURL(urls, src());
- addSubresourceURL(urls, document()->completeURL(useMap()));
+ // FIXME: What about when the usemap attribute begins with "#"?
+ addSubresourceURL(urls, document()->completeURL(getAttribute(usemapAttr)));
}
}
diff --git a/WebCore/html/HTMLImageElement.h b/WebCore/html/HTMLImageElement.h
index 5e82186..f58574d 100644
--- a/WebCore/html/HTMLImageElement.h
+++ b/WebCore/html/HTMLImageElement.h
@@ -69,17 +69,7 @@ public:
void setLoadManually(bool loadManually) { m_imageLoader.setLoadManually(loadManually); }
- String name() const;
- void setName(const String&);
-
- String align() const;
- void setAlign(const String&);
-
- String alt() const;
- void setAlt(const String&);
-
- String border() const;
- void setBorder(const String&);
+ const AtomicString& alt() const;
virtual bool draggable() const;
@@ -100,9 +90,6 @@ public:
KURL src() const;
void setSrc(const String&);
- String useMap() const;
- void setUseMap(const String&);
-
int vspace() const;
void setVspace(int);
diff --git a/WebCore/html/HTMLImageLoader.cpp b/WebCore/html/HTMLImageLoader.cpp
index 2b9f09c..c6f49aa 100644
--- a/WebCore/html/HTMLImageLoader.cpp
+++ b/WebCore/html/HTMLImageLoader.cpp
@@ -25,6 +25,7 @@
#include "CSSHelper.h"
#include "CachedImage.h"
#include "Element.h"
+#include "Event.h"
#include "EventNames.h"
#include "HTMLNames.h"
#include "HTMLObjectElement.h"
@@ -45,7 +46,7 @@ void HTMLImageLoader::dispatchLoadEvent()
bool errorOccurred = image()->errorOccurred();
if (!errorOccurred && image()->httpStatusCodeErrorOccurred())
errorOccurred = element()->hasTagName(HTMLNames::objectTag); // An <object> considers a 404 to be an error and should fire onerror.
- element()->dispatchEvent(errorOccurred ? eventNames().errorEvent : eventNames().loadEvent, false, false);
+ element()->dispatchEvent(Event::create(errorOccurred ? eventNames().errorEvent : eventNames().loadEvent, false, false));
}
String HTMLImageLoader::sourceURI(const AtomicString& attr) const
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index 59e4e2f..5689e73 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -34,14 +34,17 @@
#include "Event.h"
#include "EventHandler.h"
#include "EventNames.h"
+#include "ExceptionCode.h"
#include "File.h"
#include "FileList.h"
#include "FocusController.h"
#include "FormDataList.h"
#include "Frame.h"
+#include "HTMLDataListElement.h"
#include "HTMLFormElement.h"
#include "HTMLImageLoader.h"
#include "HTMLNames.h"
+#include "HTMLOptionElement.h"
#include "ScriptEventListener.h"
#include "KeyboardEvent.h"
#include "LocalizedStrings.h"
@@ -57,9 +60,13 @@
#include "RenderTextControlSingleLine.h"
#include "RenderTheme.h"
#include "TextEvent.h"
+<<<<<<< HEAD:WebCore/html/HTMLInputElement.cpp
#ifdef ANDROID_ACCEPT_CHANGES_TO_FOCUSED_TEXTFIELDS
#include "WebViewCore.h"
#endif
+=======
+#include <wtf/MathExtras.h>
+>>>>>>> webkit.org at 49305:WebCore/html/HTMLInputElement.cpp
#include <wtf/StdLibExtras.h>
using namespace std;
@@ -71,7 +78,7 @@ using namespace HTMLNames;
const int maxSavedResults = 256;
HTMLInputElement::HTMLInputElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* f)
- : HTMLFormControlElementWithState(tagName, doc, f)
+ : HTMLTextFormControlElement(tagName, doc, f)
, m_xPos(0)
, m_yPos(0)
, m_maxResults(-1)
@@ -138,6 +145,8 @@ bool HTMLInputElement::valueMissing() const
return !checked();
case RADIO:
return !document()->checkedRadioButtons().checkedButtonForGroup(name());
+ case COLOR:
+ return false;
case HIDDEN:
case RANGE:
case SUBMIT:
@@ -166,6 +175,7 @@ bool HTMLInputElement::patternMismatch() const
case BUTTON:
case RANGE:
case NUMBER:
+ case COLOR:
return false;
case TEXT:
case SEARCH:
@@ -192,6 +202,98 @@ bool HTMLInputElement::patternMismatch() const
return false;
}
+bool HTMLInputElement::tooLong() const
+{
+ switch (inputType()) {
+ case EMAIL:
+ case PASSWORD:
+ case SEARCH:
+ case TELEPHONE:
+ case TEXT:
+ case URL: {
+ int max = maxLength();
+ if (max < 0)
+ return false;
+ // Return false for the default value even if it is longer than maxLength.
+ bool userEdited = !m_data.value().isNull();
+ if (!userEdited)
+ return false;
+ return value().length() > static_cast<unsigned>(max);
+ }
+ case BUTTON:
+ case CHECKBOX:
+ case COLOR:
+ case FILE:
+ case HIDDEN:
+ case IMAGE:
+ case ISINDEX:
+ case NUMBER:
+ case RADIO:
+ case RANGE:
+ case RESET:
+ case SUBMIT:
+ return false;
+ }
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+bool HTMLInputElement::rangeUnderflow() const
+{
+ if (inputType() == NUMBER) {
+ double min = 0.0;
+ double doubleValue = 0.0;
+ if (formStringToDouble(getAttribute(minAttr), &min) && formStringToDouble(value(), &doubleValue))
+ return doubleValue < min;
+ } else if (inputType() == RANGE) {
+ double doubleValue;
+ if (formStringToDouble(value(), &doubleValue))
+ return doubleValue < rangeMinimum();
+ }
+ return false;
+}
+
+bool HTMLInputElement::rangeOverflow() const
+{
+ if (inputType() == NUMBER) {
+ double max = 0.0;
+ double doubleValue = 0.0;
+ if (formStringToDouble(getAttribute(maxAttr), &max) && formStringToDouble(value(), &doubleValue))
+ return doubleValue > max;
+ } else if (inputType() == RANGE) {
+ double doubleValue;
+ if (formStringToDouble(value(), &doubleValue))
+ return doubleValue > rangeMaximum();
+ }
+ return false;
+}
+
+double HTMLInputElement::rangeMinimum() const
+{
+ ASSERT(inputType() == RANGE);
+ // The range type's "default minimum" is 0.
+ double min = 0.0;
+ formStringToDouble(getAttribute(minAttr), &min);
+ return min;
+}
+
+double HTMLInputElement::rangeMaximum() const
+{
+ ASSERT(inputType() == RANGE);
+ // The range type's "default maximum" is 100.
+ static const double defaultMaximum = 100.0;
+ double max = defaultMaximum;
+ formStringToDouble(getAttribute(maxAttr), &max);
+ const double min = rangeMinimum();
+
+ if (max < min) {
+ // A remedy for the inconsistent min/max values.
+ // Sets the maxmimum to the default (100.0) or the minimum value.
+ max = min < defaultMaximum ? defaultMaximum : min;
+ }
+ return max;
+}
+
static inline CheckedRadioButtons& checkedRadioButtons(const HTMLInputElement *element)
{
if (HTMLFormElement* form = element->form())
@@ -254,20 +356,17 @@ bool HTMLInputElement::shouldUseInputMethod() const
return m_type == TEXT || m_type == SEARCH || m_type == ISINDEX;
}
-void HTMLInputElement::dispatchFocusEvent()
+void HTMLInputElement::handleFocusEvent()
{
- InputElement::dispatchFocusEvent(m_data, this, this);
+ InputElement::dispatchFocusEvent(this, this);
if (isTextField())
m_autofilled = false;
-
- HTMLFormControlElementWithState::dispatchFocusEvent();
}
-void HTMLInputElement::dispatchBlurEvent()
+void HTMLInputElement::handleBlurEvent()
{
- InputElement::dispatchBlurEvent(m_data, this, this);
- HTMLFormControlElementWithState::dispatchBlurEvent();
+ InputElement::dispatchBlurEvent(this, this);
}
void HTMLInputElement::setType(const String& t)
@@ -325,6 +424,8 @@ void HTMLInputElement::setInputType(const String& t)
newType = TELEPHONE;
else if (equalIgnoringCase(t, "url"))
newType = URL;
+ else if (equalIgnoringCase(t, "color"))
+ newType = COLOR;
else
newType = TEXT;
@@ -359,7 +460,7 @@ void HTMLInputElement::setInputType(const String& t)
m_data.setValue(String());
}
if (!didStoreValue && willStoreValue)
- m_data.setValue(constrainValue(getAttribute(valueAttr)));
+ m_data.setValue(sanitizeValue(getAttribute(valueAttr)));
else
InputElement::updateValueIfNeeded(m_data, this);
@@ -389,6 +490,7 @@ void HTMLInputElement::setInputType(const String& t)
}
InputElement::notifyFormStateChanged(this);
+ updateValidity();
}
m_haveType = true;
@@ -408,6 +510,10 @@ const AtomicString& HTMLInputElement::formControlType() const
DEFINE_STATIC_LOCAL(const AtomicString, checkbox, ("checkbox"));
return checkbox;
}
+ case COLOR: {
+ DEFINE_STATIC_LOCAL(const AtomicString, color, ("color"));
+ return color;
+ }
case EMAIL: {
DEFINE_STATIC_LOCAL(const AtomicString, email, ("email"));
return email;
@@ -477,6 +583,7 @@ bool HTMLInputElement::saveFormControlState(String& result) const
switch (inputType()) {
case BUTTON:
+ case COLOR:
case EMAIL:
case FILE:
case HIDDEN:
@@ -508,6 +615,7 @@ void HTMLInputElement::restoreFormControlState(const String& state)
ASSERT(inputType() != PASSWORD); // should never save/restore password fields
switch (inputType()) {
case BUTTON:
+ case COLOR:
case EMAIL:
case FILE:
case HIDDEN:
@@ -544,63 +652,6 @@ bool HTMLInputElement::canHaveSelection() const
return isTextField();
}
-int HTMLInputElement::selectionStart() const
-{
- if (!isTextField())
- return 0;
- if (document()->focusedNode() != this && m_data.cachedSelectionStart() != -1)
- return m_data.cachedSelectionStart();
- if (!renderer())
- return 0;
- return toRenderTextControl(renderer())->selectionStart();
-}
-
-int HTMLInputElement::selectionEnd() const
-{
- if (!isTextField())
- return 0;
- if (document()->focusedNode() != this && m_data.cachedSelectionEnd() != -1)
- return m_data.cachedSelectionEnd();
- if (!renderer())
- return 0;
- return toRenderTextControl(renderer())->selectionEnd();
-}
-
-static bool isTextFieldWithRenderer(HTMLInputElement* element)
-{
- if (!element->isTextField())
- return false;
-
- element->document()->updateLayoutIgnorePendingStylesheets();
- if (!element->renderer())
- return false;
-
- return true;
-}
-
-void HTMLInputElement::setSelectionStart(int start)
-{
- if (isTextFieldWithRenderer(this))
- toRenderTextControl(renderer())->setSelectionStart(start);
-}
-
-void HTMLInputElement::setSelectionEnd(int end)
-{
- if (isTextFieldWithRenderer(this))
- toRenderTextControl(renderer())->setSelectionEnd(end);
-}
-
-void HTMLInputElement::select()
-{
- if (isTextFieldWithRenderer(this))
- toRenderTextControl(renderer())->select();
-}
-
-void HTMLInputElement::setSelectionRange(int start, int end)
-{
- InputElement::updateSelectionRange(this, this, start, end);
-}
-
void HTMLInputElement::accessKeyAction(bool sendToAnyElement)
{
switch (inputType()) {
@@ -619,6 +670,7 @@ void HTMLInputElement::accessKeyAction(bool sendToAnyElement)
case HIDDEN:
// a no-op for this type
break;
+ case COLOR:
case EMAIL:
case ISINDEX:
case NUMBER:
@@ -659,6 +711,7 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr)
checkedRadioButtons(this).removeButton(this);
m_data.setName(attr->value());
checkedRadioButtons(this).addButton(this);
+ HTMLFormControlElementWithState::parseMappedAttribute(attr);
} else if (attr->name() == autocompleteAttr) {
if (equalIgnoringCase(attr->value(), "off")) {
m_autocomplete = Off;
@@ -678,12 +731,14 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr)
if (m_data.value().isNull())
setNeedsStyleRecalc();
setFormControlValueMatchesRenderer(false);
+ updateValidity();
} else if (attr->name() == checkedAttr) {
m_defaultChecked = !attr->isNull();
if (m_useDefaultChecked) {
setChecked(m_defaultChecked);
m_useDefaultChecked = true;
}
+ updateValidity();
} else if (attr->name() == maxlengthAttr)
InputElement::parseMaxLengthAttribute(m_data, this, this, attr);
else if (attr->name() == sizeAttr)
@@ -715,14 +770,6 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr)
} else if (attr->name() == heightAttr) {
if (respectHeightAndWidthAttrs())
addCSSLength(attr, CSSPropertyHeight, attr->value());
- } else if (attr->name() == onfocusAttr) {
- setAttributeEventListener(eventNames().focusEvent, createAttributeEventListener(this, attr));
- } else if (attr->name() == onblurAttr) {
- setAttributeEventListener(eventNames().blurEvent, createAttributeEventListener(this, attr));
- } else if (attr->name() == onselectAttr) {
- setAttributeEventListener(eventNames().selectEvent, createAttributeEventListener(this, attr));
- } else if (attr->name() == onchangeAttr) {
- setAttributeEventListener(eventNames().changeEvent, createAttributeEventListener(this, attr));
}
// Search field and slider attributes all just cause updateFromElement to be called through style
// recalcing.
@@ -730,7 +777,7 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr)
setAttributeEventListener(eventNames().searchEvent, createAttributeEventListener(this, attr));
} else if (attr->name() == resultsAttr) {
int oldResults = m_maxResults;
- m_maxResults = !attr->isNull() ? min(attr->value().toInt(), maxSavedResults) : -1;
+ m_maxResults = !attr->isNull() ? std::min(attr->value().toInt(), maxSavedResults) : -1;
// FIXME: Detaching just for maxResults change is not ideal. We should figure out the right
// time to relayout for this change.
if (m_maxResults != oldResults && (m_maxResults <= 0 || oldResults <= 0) && attached()) {
@@ -738,9 +785,6 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr)
attach();
}
setNeedsStyleRecalc();
- } else if (attr->name() == placeholderAttr) {
- if (isTextField())
- updatePlaceholderVisibility();
} else if (attr->name() == autosaveAttr ||
attr->name() == incrementalAttr ||
attr->name() == minAttr ||
@@ -748,8 +792,15 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr)
attr->name() == multipleAttr ||
attr->name() == precisionAttr)
setNeedsStyleRecalc();
+ else if (attr->name() == patternAttr)
+ updateValidity();
+#if ENABLE(DATALIST)
+ else if (attr->name() == listAttr)
+ m_hasNonEmptyList = !attr->isEmpty();
+ // FIXME: we need to tell this change to a renderer if the attribute affects the appearance.
+#endif
else
- HTMLFormControlElementWithState::parseMappedAttribute(attr);
+ HTMLTextFormControlElement::parseMappedAttribute(attr);
}
bool HTMLInputElement::rendererIsNeeded(RenderStyle *style)
@@ -757,6 +808,7 @@ bool HTMLInputElement::rendererIsNeeded(RenderStyle *style)
switch (inputType()) {
case BUTTON:
case CHECKBOX:
+ case COLOR:
case EMAIL:
case FILE:
case IMAGE:
@@ -797,6 +849,7 @@ RenderObject *HTMLInputElement::createRenderer(RenderArena *arena, RenderStyle *
return new (arena) RenderImage(this);
case RANGE:
return new (arena) RenderSlider(this);
+ case COLOR:
case EMAIL:
case ISINDEX:
case NUMBER:
@@ -805,7 +858,7 @@ RenderObject *HTMLInputElement::createRenderer(RenderArena *arena, RenderStyle *
case TELEPHONE:
case TEXT:
case URL:
- return new (arena) RenderTextControlSingleLine(this);
+ return new (arena) RenderTextControlSingleLine(this, placeholderShouldBeVisible());
}
ASSERT(false);
return 0;
@@ -883,6 +936,7 @@ bool HTMLInputElement::appendFormData(FormDataList& encoding, bool multipart)
return false;
switch (inputType()) {
+ case COLOR:
case EMAIL:
case HIDDEN:
case ISINDEX:
@@ -990,7 +1044,7 @@ void HTMLInputElement::setChecked(bool nowChecked, bool sendChangeEvent)
// RenderTextView), but it's not possible to do it at the moment
// because of the way the code is structured.
if (renderer() && AXObjectCache::accessibilityEnabled())
- renderer()->document()->axObjectCache()->postNotification(renderer(), "AXCheckedStateChanged", true);
+ renderer()->document()->axObjectCache()->postNotification(renderer(), AXObjectCache::AXCheckedStateChanged, true);
// Only send a change event for items in the document (avoid firing during
// parsing) and don't send a change event for a radio button that's getting
@@ -1043,7 +1097,7 @@ String HTMLInputElement::value() const
String value = m_data.value();
if (value.isNull()) {
- value = constrainValue(getAttribute(valueAttr));
+ value = sanitizeValue(getAttribute(valueAttr));
// If no attribute exists, then just use "on" or "" based off the checked() state of the control.
if (value.isNull() && (inputType() == CHECKBOX || inputType() == RADIO))
@@ -1060,6 +1114,7 @@ String HTMLInputElement::valueWithDefault() const
switch (inputType()) {
case BUTTON:
case CHECKBOX:
+ case COLOR:
case EMAIL:
case FILE:
case HIDDEN:
@@ -1098,9 +1153,9 @@ void HTMLInputElement::setValue(const String& value)
if (inputType() == FILE)
m_fileList->clear();
else {
- m_data.setValue(constrainValue(value));
+ m_data.setValue(sanitizeValue(value));
if (isTextField()) {
- InputElement::updatePlaceholderVisibility(m_data, this, this);
+ updatePlaceholderVisibility(false);
if (inDocument())
document()->updateStyleIfNeeded();
}
@@ -1109,7 +1164,7 @@ void HTMLInputElement::setValue(const String& value)
renderer()->updateFromElement();
setNeedsStyleRecalc();
} else
- setAttribute(valueAttr, constrainValue(value));
+ setAttribute(valueAttr, sanitizeValue(value));
if (isTextField()) {
unsigned max = m_data.value().length();
@@ -1123,6 +1178,7 @@ void HTMLInputElement::setValue(const String& value)
cacheSelection(max, max);
}
InputElement::notifyFormStateChanged(this);
+ updateValidity();
}
String HTMLInputElement::placeholder() const
@@ -1144,7 +1200,9 @@ void HTMLInputElement::setValueFromRenderer(const String& value)
{
// File upload controls will always use setFileListFromRenderer.
ASSERT(inputType() != FILE);
+ updatePlaceholderVisibility(false);
InputElement::setValueFromRenderer(m_data, this, this, value);
+ updateValidity();
}
void HTMLInputElement::setFileListFromRenderer(const Vector<String>& paths)
@@ -1156,6 +1214,7 @@ void HTMLInputElement::setFileListFromRenderer(const Vector<String>& paths)
setFormControlValueMatchesRenderer(true);
InputElement::notifyFormStateChanged(this);
+ updateValidity();
}
bool HTMLInputElement::storesValueSeparateFromAttribute() const
@@ -1169,6 +1228,7 @@ bool HTMLInputElement::storesValueSeparateFromAttribute() const
case RESET:
case SUBMIT:
return false;
+ case COLOR:
case EMAIL:
case FILE:
case ISINDEX:
@@ -1344,6 +1404,7 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
if (charCode == '\r') {
switch (inputType()) {
case CHECKBOX:
+ case COLOR:
case EMAIL:
case HIDDEN:
case ISINDEX:
@@ -1472,6 +1533,7 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
if (!checked())
clickElement = true;
break;
+ case COLOR:
case EMAIL:
case HIDDEN:
case ISINDEX:
@@ -1516,7 +1578,7 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
}
if (evt->isBeforeTextInsertedEvent())
- InputElement::handleBeforeTextInsertedEvent(m_data, this, document(), evt);
+ InputElement::handleBeforeTextInsertedEvent(m_data, this, this, evt);
if (isTextField() && renderer() && (evt->isMouseEvent() || evt->isDragEvent() || evt->isWheelEvent() || evt->type() == eventNames().blurEvent || evt->type() == eventNames().focusEvent))
toRenderTextControlSingleLine(renderer())->forwardEvent(evt);
@@ -1603,9 +1665,12 @@ int HTMLInputElement::maxLength() const
return m_data.maxLength();
}
-void HTMLInputElement::setMaxLength(int _maxLength)
+void HTMLInputElement::setMaxLength(int maxLength, ExceptionCode& ec)
{
- setAttribute(maxlengthAttr, String::number(_maxLength));
+ if (maxLength < 0)
+ ec = INDEX_SIZE_ERR;
+ else
+ setAttribute(maxlengthAttr, String::number(maxLength));
}
bool HTMLInputElement::multiple() const
@@ -1659,9 +1724,11 @@ FileList* HTMLInputElement::files()
return m_fileList.get();
}
-String HTMLInputElement::constrainValue(const String& proposedValue) const
+String HTMLInputElement::sanitizeValue(const String& proposedValue) const
{
- return InputElement::constrainValue(this, proposedValue, m_data.maxLength());
+ if (isTextField())
+ return InputElement::sanitizeValue(this, proposedValue);
+ return proposedValue;
}
bool HTMLInputElement::needsActivationCallback()
@@ -1704,6 +1771,7 @@ bool HTMLInputElement::isRequiredFormControl() const
case IMAGE:
case RESET:
case BUTTON:
+ case COLOR:
case ISINDEX:
return false;
}
@@ -1730,14 +1798,7 @@ void HTMLInputElement::onSearch()
ASSERT(isSearchField());
if (renderer())
toRenderTextControlSingleLine(renderer())->stopSearchEventTimer();
- dispatchEvent(eventNames().searchEvent, true, false);
-}
-
-VisibleSelection HTMLInputElement::selection() const
-{
- if (!renderer() || !isTextField() || m_data.cachedSelectionStart() == -1 || m_data.cachedSelectionEnd() == -1)
- return VisibleSelection();
- return toRenderTextControl(renderer())->selection(m_data.cachedSelectionStart(), m_data.cachedSelectionEnd());
+ dispatchEvent(Event::create(eventNames().searchEvent, true, false));
}
void HTMLInputElement::documentDidBecomeActive()
@@ -1778,9 +1839,88 @@ bool HTMLInputElement::willValidate() const
inputType() != BUTTON && inputType() != RESET;
}
-bool HTMLInputElement::placeholderShouldBeVisible() const
+bool HTMLInputElement::formStringToDouble(const String& src, double* out)
{
- return m_data.placeholderShouldBeVisible();
+ // See HTML5 2.4.4.3 `Real numbers.'
+
+ if (src.isEmpty())
+ return false;
+ // String::toDouble() accepts leading + \t \n \v \f \r and SPACE, which are invalid in HTML5.
+ // So, check the first character.
+ if (src[0] != '-' && (src[0] < '0' || src[0] > '9'))
+ return false;
+
+ bool valid = false;
+ double value = src.toDouble(&valid);
+ if (!valid)
+ return false;
+ // NaN and Infinity are not valid numbers according to the standard.
+ if (isnan(value) || isinf(value))
+ return false;
+ if (out)
+ *out = value;
+ return true;
+}
+
+#if ENABLE(DATALIST)
+HTMLElement* HTMLInputElement::list() const
+{
+ return dataList();
+}
+
+HTMLDataListElement* HTMLInputElement::dataList() const
+{
+ if (!m_hasNonEmptyList)
+ return 0;
+
+ switch (inputType()) {
+ case TEXT:
+ case SEARCH:
+ case URL:
+ case TELEPHONE:
+ case EMAIL:
+ case NUMBER:
+ case RANGE:
+ case COLOR: {
+ Element* element = document()->getElementById(getAttribute(listAttr));
+ if (element && element->hasTagName(datalistTag))
+ return static_cast<HTMLDataListElement*>(element);
+ break;
+ }
+ case HIDDEN:
+ case PASSWORD:
+ case CHECKBOX:
+ case RADIO:
+ case FILE:
+ case SUBMIT:
+ case IMAGE:
+ case RESET:
+ case BUTTON:
+ case ISINDEX:
+ break;
+ }
+ return 0;
+}
+
+HTMLOptionElement* HTMLInputElement::selectedOption() const
+{
+ String currentValue = value();
+ // The empty value never matches to a datalist option because it
+ // doesn't represent a suggestion according to the standard.
+ if (currentValue.isEmpty())
+ return 0;
+
+ HTMLDataListElement* sourceElement = dataList();
+ if (!sourceElement)
+ return 0;
+ RefPtr<HTMLCollection> options = sourceElement->options();
+ for (unsigned i = 0; options && i < options->length(); ++i) {
+ HTMLOptionElement* option = static_cast<HTMLOptionElement*>(options->item(i));
+ if (!option->disabled() && currentValue == option->value())
+ return option;
+ }
+ return 0;
}
+#endif // ENABLE(DATALIST)
} // namespace
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index 4d887f3..799d92c 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -31,11 +31,13 @@
namespace WebCore {
class FileList;
+class HTMLDataListElement;
class HTMLImageLoader;
+class HTMLOptionElement;
class KURL;
class VisibleSelection;
-class HTMLInputElement : public HTMLFormControlElementWithState, public InputElement {
+class HTMLInputElement : public HTMLTextFormControlElement, public InputElement {
public:
enum InputType {
TEXT,
@@ -54,7 +56,8 @@ public:
EMAIL,
NUMBER,
TELEPHONE,
- URL
+ URL,
+ COLOR
};
enum AutoCompleteSetting {
@@ -72,8 +75,6 @@ public:
virtual bool isKeyboardFocusable(KeyboardEvent*) const;
virtual bool isMouseFocusable() const;
virtual bool isEnumeratable() const { return inputType() != IMAGE; }
- virtual void dispatchFocusEvent();
- virtual void dispatchBlurEvent();
virtual void updateFocusAppearance(bool restorePreviousSelection);
virtual void aboutToUnload();
virtual bool shouldUseInputMethod() const;
@@ -92,10 +93,19 @@ public:
virtual bool valueMissing() const;
virtual bool patternMismatch() const;
+ virtual bool tooLong() const;
+ // For ValidityState
+ bool rangeUnderflow() const;
+ bool rangeOverflow() const;
+ // Returns the minimum value for type=range. Don't call this for other types.
+ double rangeMinimum() const;
+ // Returns the maximum value for type=range. Don't call this for other types.
+ // This always returns a value which is <= rangeMinimum().
+ double rangeMaximum() const;
bool isTextButton() const { return m_type == SUBMIT || m_type == RESET || m_type == BUTTON; }
virtual bool isRadioButton() const { return m_type == RADIO; }
- virtual bool isTextField() const { return m_type == TEXT || m_type == PASSWORD || m_type == SEARCH || m_type == ISINDEX || m_type == EMAIL || m_type == NUMBER || m_type == TELEPHONE || m_type == URL; }
+ virtual bool isTextField() const { return m_type == TEXT || m_type == PASSWORD || m_type == SEARCH || m_type == ISINDEX || m_type == EMAIL || m_type == NUMBER || m_type == TELEPHONE || m_type == URL || m_type == COLOR; }
virtual bool isSearchField() const { return m_type == SEARCH; }
virtual bool isInputTypeHidden() const { return m_type == HIDDEN; }
virtual bool isPasswordField() const { return m_type == PASSWORD; }
@@ -127,12 +137,7 @@ public:
virtual bool canStartSelection() const;
bool canHaveSelection() const;
- int selectionStart() const;
- int selectionEnd() const;
- void setSelectionStart(int);
- void setSelectionEnd(int);
- virtual void select();
- void setSelectionRange(int start, int end);
+ virtual void select() { HTMLTextFormControlElement::select(); }
virtual void accessKeyAction(bool sendToAnyElement);
@@ -194,8 +199,13 @@ public:
KURL src() const;
void setSrc(const String&);
+#if ENABLE(DATALIST)
+ HTMLElement* list() const;
+ HTMLOptionElement* selectedOption() const;
+#endif
+
int maxLength() const;
- void setMaxLength(int);
+ void setMaxLength(int, ExceptionCode&);
bool multiple() const;
void setMultiple(bool);
@@ -212,9 +222,7 @@ public:
void addSearchResult();
void onSearch();
- VisibleSelection selection() const;
-
- virtual String constrainValue(const String& proposedValue) const;
+ virtual String sanitizeValue(const String&) const;
virtual void documentDidBecomeActive();
@@ -222,17 +230,15 @@ public:
virtual bool willValidate() const;
- virtual bool placeholderShouldBeVisible() const;
+ // Converts the specified string to a floating number.
+ // If the conversion fails, the return value is false. Take care that leading or trailing unnecessary characters make failures. This returns false for an empty string input.
+ // The double* parameter may be 0.
+ static bool formStringToDouble(const String&, double*);
protected:
virtual void willMoveToNewOwnerDocument();
virtual void didMoveToNewOwnerDocument();
- void updatePlaceholderVisibility()
- {
- InputElement::updatePlaceholderVisibility(m_data, this, this, true);
- }
-
private:
bool storesValueSeparateFromAttribute() const;
@@ -240,9 +246,20 @@ private:
void registerForActivationCallbackIfNeeded();
void unregisterForActivationCallbackIfNeeded();
+ virtual bool supportsPlaceholder() const { return isTextField(); }
+ virtual bool isEmptyValue() const { return value().isEmpty(); }
+ virtual void handleFocusEvent();
+ virtual void handleBlurEvent();
+ virtual int cachedSelectionStart() const { return m_data.cachedSelectionStart(); }
+ virtual int cachedSelectionEnd() const { return m_data.cachedSelectionEnd(); }
+
virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); }
virtual bool isRequiredFormControl() const;
+#if ENABLE(DATALIST)
+ HTMLDataListElement* dataList() const;
+#endif
+
InputElementData m_data;
int m_xPos;
int m_yPos;
@@ -259,6 +276,9 @@ private:
unsigned m_autocomplete : 2; // AutoCompleteSetting
bool m_autofilled : 1;
bool m_inited : 1;
+#if ENABLE(DATALIST)
+ bool m_hasNonEmptyList : 1;
+#endif
};
} //namespace
diff --git a/WebCore/html/HTMLInputElement.idl b/WebCore/html/HTMLInputElement.idl
index e15c6b5..59248f4 100644
--- a/WebCore/html/HTMLInputElement.idl
+++ b/WebCore/html/HTMLInputElement.idl
@@ -28,6 +28,7 @@ module html {
attribute [ConvertNullToNullString] DOMString defaultValue;
attribute boolean defaultChecked;
readonly attribute HTMLFormElement form;
+ attribute boolean formNoValidate;
#if !defined(LANGUAGE_COM) || !LANGUAGE_COM
readonly attribute ValidityState validity;
#endif
@@ -38,7 +39,17 @@ module html {
attribute boolean checked;
attribute boolean disabled;
attribute boolean autofocus;
- attribute long maxLength;
+#if defined(ENABLE_DATALIST) && ENABLE_DATALIST
+ readonly attribute HTMLElement list;
+#endif
+#if !defined(LANGUAGE_COM) || !LANGUAGE_COM
+ attribute [Reflect] DOMString max;
+#endif
+ attribute long maxLength
+ setter raises(DOMException);
+#if !defined(LANGUAGE_COM) || !LANGUAGE_COM
+ attribute [Reflect] DOMString min;
+#endif
attribute boolean multiple;
attribute [ConvertNullToNullString] DOMString name;
attribute [Reflect] DOMString pattern;
@@ -55,7 +66,11 @@ module html {
attribute [ConvertNullToNullString, JSCCustomGetter] DOMString type; // readonly dropped as part of DOM level 2
attribute [ConvertNullToNullString] DOMString useMap;
attribute [ConvertNullToNullString] DOMString value;
+#if defined(ENABLE_DATALIST) && ENABLE_DATALIST
+ readonly attribute HTMLOptionElement selectedOption;
+#endif
readonly attribute boolean willValidate;
+ boolean checkValidity();
void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error);
void select();
void click();
diff --git a/WebCore/html/HTMLIsIndexElement.cpp b/WebCore/html/HTMLIsIndexElement.cpp
index bcfa623..31fafa6 100644
--- a/WebCore/html/HTMLIsIndexElement.cpp
+++ b/WebCore/html/HTMLIsIndexElement.cpp
@@ -44,7 +44,7 @@ void HTMLIsIndexElement::parseMappedAttribute(MappedAttribute* attr)
if (attr->name() == promptAttr)
setValue(attr->value());
else if (attr->name() == placeholderAttr)
- updatePlaceholderVisibility();
+ updatePlaceholderVisibility(true);
else
// don't call HTMLInputElement::parseMappedAttribute here, as it would
// accept attributes this element does not support
diff --git a/WebCore/html/HTMLKeygenElement.cpp b/WebCore/html/HTMLKeygenElement.cpp
index b1b6238..6af088f 100644
--- a/WebCore/html/HTMLKeygenElement.cpp
+++ b/WebCore/html/HTMLKeygenElement.cpp
@@ -51,7 +51,7 @@ HTMLKeygenElement::HTMLKeygenElement(const QualifiedName& tagName, Document* doc
for (Vector<String>::const_iterator it = keys.begin(); it != end; ++it) {
HTMLOptionElement* o = new HTMLOptionElement(optionTag, doc, form());
addChild(o);
- o->addChild(new Text(doc, *it));
+ o->addChild(Text::create(doc, *it));
}
}
diff --git a/WebCore/html/HTMLLegendElement.cpp b/WebCore/html/HTMLLegendElement.cpp
index d6e08c7..516ca54 100644
--- a/WebCore/html/HTMLLegendElement.cpp
+++ b/WebCore/html/HTMLLegendElement.cpp
@@ -42,9 +42,9 @@ HTMLLegendElement::~HTMLLegendElement()
{
}
-bool HTMLLegendElement::isFocusable() const
+bool HTMLLegendElement::supportsFocus() const
{
- return HTMLElement::isFocusable();
+ return HTMLElement::supportsFocus();
}
const AtomicString& HTMLLegendElement::formControlType() const
diff --git a/WebCore/html/HTMLLegendElement.h b/WebCore/html/HTMLLegendElement.h
index 713d73c..1b394e4 100644
--- a/WebCore/html/HTMLLegendElement.h
+++ b/WebCore/html/HTMLLegendElement.h
@@ -33,7 +33,7 @@ public:
HTMLLegendElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
virtual ~HTMLLegendElement();
- virtual bool isFocusable() const;
+ virtual bool supportsFocus() const;
virtual const AtomicString& formControlType() const;
virtual void accessKeyAction(bool sendToAnyElement);
diff --git a/WebCore/html/HTMLLinkElement.cpp b/WebCore/html/HTMLLinkElement.cpp
index f1313bb..57b0b5d 100644
--- a/WebCore/html/HTMLLinkElement.cpp
+++ b/WebCore/html/HTMLLinkElement.cpp
@@ -38,6 +38,7 @@
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
#include "Page.h"
+#include "ScriptEventListener.h"
#include "Settings.h"
namespace WebCore {
@@ -134,7 +135,9 @@ void HTMLLinkElement::parseMappedAttribute(MappedAttribute *attr)
process();
} else if (attr->name() == disabledAttr) {
setDisabledState(!attr->isNull());
- } else {
+ } else if (attr->name() == onbeforeloadAttr)
+ setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
+ else {
if (attr->name() == titleAttr && m_sheet)
m_sheet->setTitle(attr->value());
HTMLElement::parseMappedAttribute(attr);
@@ -217,11 +220,7 @@ void HTMLLinkElement::process()
// This was buggy and would incorrectly match <link rel="alternate">, which has a different specified meaning. -dwh
if (m_disabledState != 2 && (m_isStyleSheet || acceptIfTypeContainsTextCSS && type.contains("text/css")) && document()->frame() && m_url.isValid()) {
// also, don't load style sheets for standalone documents
- // Add ourselves as a pending sheet, but only if we aren't an alternate
- // stylesheet. Alternate stylesheets don't hold up render tree construction.
- if (!isAlternate())
- document()->addPendingSheet();
-
+
String charset = getAttribute(charsetAttr);
if (charset.isEmpty() && document()->frame())
charset = document()->frame()->loader()->encoding();
@@ -230,14 +229,28 @@ void HTMLLinkElement::process()
if (m_loading)
document()->removePendingSheet();
m_cachedSheet->removeClient(this);
+ m_cachedSheet = 0;
}
+
+ if (!dispatchBeforeLoadEvent(m_url))
+ return;
+
m_loading = true;
+
+ // Add ourselves as a pending sheet, but only if we aren't an alternate
+ // stylesheet. Alternate stylesheets don't hold up render tree construction.
+ if (!isAlternate())
+ document()->addPendingSheet();
+
m_cachedSheet = document()->docLoader()->requestCSSStyleSheet(m_url, charset);
+
if (m_cachedSheet)
m_cachedSheet->addClient(this);
- else if (!isAlternate()) { // The request may have been denied if stylesheet is local and document is remote.
+ else {
+ // The request may have been denied if (for example) the stylesheet is local and the document is remote.
m_loading = false;
- document()->removePendingSheet();
+ if (!isAlternate())
+ document()->removePendingSheet();
}
} else if (m_sheet) {
// we no longer contain a stylesheet, e.g. perhaps rel or type was changed
@@ -282,7 +295,23 @@ void HTMLLinkElement::setCSSStyleSheet(const String& url, const String& charset,
if (enforceMIMEType && document()->page() && !document()->page()->settings()->enforceCSSMIMETypeInStrictMode())
enforceMIMEType = false;
- m_sheet->parseString(sheet->sheetText(enforceMIMEType), strictParsing);
+ String sheetText = sheet->sheetText(enforceMIMEType);
+ m_sheet->parseString(sheetText, strictParsing);
+
+ if (strictParsing && document()->settings() && document()->settings()->needsSiteSpecificQuirks()) {
+ // Work around <https://bugs.webkit.org/show_bug.cgi?id=28350>.
+ DEFINE_STATIC_LOCAL(const String, slashKHTMLFixesDotCss, ("/KHTMLFixes.css"));
+ DEFINE_STATIC_LOCAL(const String, mediaWikiKHTMLFixesStyleSheet, ("/* KHTML fix stylesheet */\n/* work around the horizontal scrollbars */\n#column-content { margin-left: 0; }\n\n"));
+ // There are two variants of KHTMLFixes.css. One is equal to mediaWikiKHTMLFixesStyleSheet,
+ // while the other lacks the second trailing newline.
+ if (url.endsWith(slashKHTMLFixesDotCss) && !sheetText.isNull() && mediaWikiKHTMLFixesStyleSheet.startsWith(sheetText)
+ && sheetText.length() >= mediaWikiKHTMLFixesStyleSheet.length() - 1) {
+ ASSERT(m_sheet->length() == 1);
+ ExceptionCode ec;
+ m_sheet->deleteRule(0, ec);
+ }
+ }
+
m_sheet->setTitle(title());
RefPtr<MediaList> media = MediaList::createAllowingDescriptionSyntax(m_media);
diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp
index 401d79f..e90db4a 100644
--- a/WebCore/html/HTMLMediaElement.cpp
+++ b/WebCore/html/HTMLMediaElement.cpp
@@ -28,6 +28,9 @@
#if ENABLE(VIDEO)
#include "HTMLMediaElement.h"
+#include "ClientRect.h"
+#include "ClientRectList.h"
+#include "ChromeClient.h"
#include "CSSHelper.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
@@ -38,6 +41,8 @@
#include "ExceptionCode.h"
#include "Frame.h"
#include "FrameLoader.h"
+#include "FrameLoaderClient.h"
+#include "FrameView.h"
#include "HTMLDocument.h"
#include "HTMLNames.h"
#include "HTMLSourceElement.h"
@@ -52,6 +57,7 @@
#include "Page.h"
#include "ProgressEvent.h"
#include "RenderVideo.h"
+#include "RenderView.h"
#include "ScriptEventListener.h"
#include "TimeRanges.h"
#include <limits>
@@ -110,6 +116,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* doc)
, m_sentEndEvent(false)
, m_pausedInternal(false)
, m_sendProgressEvents(true)
+ , m_isFullscreen(false)
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
, m_needWidgetUpdate(false)
#endif
@@ -178,6 +185,8 @@ void HTMLMediaElement::parseMappedAttribute(MappedAttribute* attr)
setAttributeEventListener(eventNames().loadeddataEvent, createAttributeEventListener(this, attr));
else if (attrName == onloadedmetadataAttr)
setAttributeEventListener(eventNames().loadedmetadataEvent, createAttributeEventListener(this, attr));
+ else if (attrName == onloadendAttr)
+ setAttributeEventListener(eventNames().loadendEvent, createAttributeEventListener(this, attr));
else if (attrName == onloadstartAttr)
setAttributeEventListener(eventNames().loadstartEvent, createAttributeEventListener(this, attr));
else if (attrName == onpauseAttr)
@@ -238,6 +247,12 @@ void HTMLMediaElement::insertedIntoDocument()
scheduleLoad();
}
+void HTMLMediaElement::willRemove()
+{
+ if (m_isFullscreen)
+ exitFullscreen();
+ HTMLElement::willRemove();
+}
void HTMLMediaElement::removedFromDocument()
{
if (m_networkState > NETWORK_EMPTY)
@@ -269,6 +284,15 @@ void HTMLMediaElement::recalcStyle(StyleChange change)
void HTMLMediaElement::scheduleLoad()
{
+ if (m_loadTimer.isActive())
+ return;
+ prepareForLoad();
+ m_loadTimer.startOneShot(0);
+}
+
+void HTMLMediaElement::scheduleNextSourceChild()
+{
+ // Schedule the timer to try the next <source> element WITHOUT resetting state ala prepareForLoad.
m_loadTimer.startOneShot(0);
}
@@ -408,17 +432,15 @@ void HTMLMediaElement::load(ExceptionCode& ec)
{
if (m_restrictions & RequireUserGestureForLoadRestriction && !processingUserGesture())
ec = INVALID_STATE_ERR;
- else
+ else {
+ prepareForLoad();
loadInternal();
+ }
}
-void HTMLMediaElement::loadInternal()
+void HTMLMediaElement::prepareForLoad()
{
- // 1 - If the load() method for this element is already being invoked, then abort these steps.
- if (m_processingLoad)
- return;
- m_processingLoad = true;
-
+ // Perform the cleanup required for the resource load algorithm to run.
stopPeriodicTimers();
m_loadTimer.stop();
m_sentStalledEvent = false;
@@ -430,21 +452,34 @@ void HTMLMediaElement::loadInternal()
// 3 - If there are any tasks from the media element's media element event task source in
// one of the task queues, then remove those tasks.
cancelPendingEventsAndCallbacks();
+}
+
+void HTMLMediaElement::loadInternal()
+{
+ // 1 - If the load() method for this element is already being invoked, then abort these steps.
+ if (m_processingLoad)
+ return;
+ m_processingLoad = true;
+
+ // Steps 2 and 3 were done in prepareForLoad()
- // 4 - If the media element's networkState is set to NETWORK_LOADING or NETWORK_IDLE, set the
- // error attribute to a new MediaError object whose code attribute is set to MEDIA_ERR_ABORTED,
- // and fire a progress event called abort at the media element.
+ // 4 - If the media element's networkState is set to NETWORK_LOADING or NETWORK_IDLE, set
+ // the error attribute to a new MediaError object whose code attribute is set to
+ // MEDIA_ERR_ABORTED, fire a progress event called abort at the media element, in the
+ // context of the fetching process that is in progress for the element, and fire a progress
+ // event called loadend at the media element, in the context of the same fetching process.
if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) {
m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED);
-
- // fire synchronous 'abort'
+
+ // fire synchronous 'abort' and 'loadend'
bool totalKnown = m_player && m_player->totalBytesKnown();
unsigned loaded = m_player ? m_player->bytesLoaded() : 0;
unsigned total = m_player ? m_player->totalBytes() : 0;
- dispatchProgressEvent(eventNames().abortEvent, totalKnown, loaded, total);
+ dispatchEvent(ProgressEvent::create(eventNames().abortEvent, totalKnown, loaded, total));
+ dispatchEvent(ProgressEvent::create(eventNames().loadendEvent, totalKnown, loaded, total));
}
-
- // 5
+
+ // 5
m_error = 0;
m_autoplaying = true;
m_playedTimeRanges = TimeRanges::create();
@@ -452,7 +487,7 @@ void HTMLMediaElement::loadInternal()
// 6
setPlaybackRate(defaultPlaybackRate());
-
+
// 7
if (m_networkState != NETWORK_EMPTY) {
m_networkState = NETWORK_EMPTY;
@@ -464,9 +499,9 @@ void HTMLMediaElement::loadInternal()
m_playing = false;
m_player->seek(0);
}
- dispatchEvent(eventNames().emptiedEvent, false, true);
+ dispatchEvent(Event::create(eventNames().emptiedEvent, false, true));
}
-
+
selectMediaResource();
m_processingLoad = false;
}
@@ -530,9 +565,20 @@ void HTMLMediaElement::loadNextSourceChild()
loadResource(mediaURL, contentType);
}
-void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType)
+void HTMLMediaElement::loadResource(const KURL& initialURL, ContentType& contentType)
{
- ASSERT(isSafeToLoadURL(url, Complain));
+ ASSERT(isSafeToLoadURL(initialURL, Complain));
+
+ Frame* frame = document()->frame();
+ if (!frame)
+ return;
+ FrameLoader* loader = frame->loader();
+ if (!loader)
+ return;
+
+ KURL url(initialURL);
+ if (!loader->willLoadMediaElementURL(url))
+ return;
// The resource fetch algorithm
m_networkState = NETWORK_LOADING;
@@ -570,8 +616,8 @@ bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidSourceAction acti
Frame* frame = document()->frame();
FrameLoader* loader = frame ? frame->loader() : 0;
- // don't allow remote to local urls
- if (!loader || !loader->canLoad(url, String(), document())) {
+ // don't allow remote to local urls, and check with the frame loader client.
+ if (!loader || !SecurityOrigin::canLoad(url, String(), document())) {
if (actionIfInvalid == Complain)
FrameLoader::reportLocalLoadFailed(frame, url.string());
return false;
@@ -597,22 +643,29 @@ void HTMLMediaElement::noneSupported()
m_loadState = WaitingForSource;
m_currentSourceNode = 0;
- // 3 - Reaching this step indicates that either the URL failed to resolve, or the media
- // resource failed to load. Set the error attribute to a new MediaError object whose
+ // 4 - Reaching this step indicates that either the URL failed to resolve, or the media
+ // resource failed to load. Set the error attribute to a new MediaError object whose
// code attribute is set to MEDIA_ERR_SRC_NOT_SUPPORTED.
m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED);
- // 4- Set the element's networkState attribute to the NETWORK_NO_SOURCE value.
+ // 5 - Set the element's networkState attribute to the NETWORK_NO_SOURCE value.
m_networkState = NETWORK_NO_SOURCE;
- // 5 - Queue a task to fire a progress event called error at the media element.
- scheduleProgressEvent(eventNames().errorEvent);
+ // 6 - Queue a task to fire a progress event called error at the media element, in
+ // the context of the fetching process that was used to try to obtain the media
+ // resource in the resource fetch algorithm.
+ scheduleProgressEvent(eventNames().errorEvent);
- // 6 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event.
+ // 7 - Queue a task to fire a progress event called loadend at the media element, in
+ // the context of the fetching process that was used to try to obtain the media
+ // resource in the resource fetch algorithm.
+ scheduleProgressEvent(eventNames().loadendEvent);
+
+ // 8 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event.
m_delayingTheLoadEvent = false;
- // Abort these steps. Until the load() method is invoked, the element won't attempt to load another resource.
-
+ // 9 -Abort these steps. Until the load() method is invoked, the element won't attempt to load another resource.
+
if (isVideo())
static_cast<HTMLVideoElement*>(this)->updatePosterImage();
if (renderer())
@@ -629,20 +682,24 @@ void HTMLMediaElement::mediaEngineError(PassRefPtr<MediaError> err)
// set to MEDIA_ERR_NETWORK/MEDIA_ERR_DECODE.
m_error = err;
- // 3 - Queue a task to fire a progress event called error at the media element.
- scheduleProgressEvent(eventNames().errorEvent);
+ // 3 - Queue a task to fire a progress event called error at the media element, in
+ // the context of the fetching process started by this instance of this algorithm.
+ scheduleProgressEvent(eventNames().errorEvent);
- // 3 - Set the element's networkState attribute to the NETWORK_EMPTY value and queue a
+ // 4 - Queue a task to fire a progress event called loadend at the media element, in
+ // the context of the fetching process started by this instance of this algorithm.
+ scheduleProgressEvent(eventNames().loadendEvent);
+
+ // 5 - Set the element's networkState attribute to the NETWORK_EMPTY value and queue a
// task to fire a simple event called emptied at the element.
m_networkState = NETWORK_EMPTY;
scheduleEvent(eventNames().emptiedEvent);
- // 4 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event.
+ // 6 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event.
m_delayingTheLoadEvent = false;
- // 5 - Abort the overall resource selection algorithm.
+ // 7 - Abort the overall resource selection algorithm.
m_currentSourceNode = 0;
-
}
void HTMLMediaElement::cancelPendingEventsAndCallbacks()
@@ -678,7 +735,7 @@ void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement) {
m_currentSourceNode->scheduleErrorEvent();
if (havePotentialSourceChild())
- scheduleLoad();
+ scheduleNextSourceChild();
return;
}
@@ -716,6 +773,10 @@ void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
if (oldState < NETWORK_LOADED || oldState == NETWORK_NO_SOURCE) {
m_progressEventTimer.stop();
+ // Schedule one last progress event so we guarantee that at least one is fired
+ // for files that load very quickly.
+ scheduleProgressEvent(eventNames().progressEvent);
+
// Check to see if readyState changes need to be dealt with before sending the
// 'load' event so we report 'canplaythrough' first. This is necessary because a
// media engine reports readyState and networkState changes separately
@@ -723,7 +784,8 @@ void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
if (static_cast<ReadyState>(currentState) != m_readyState)
setReadyState(currentState);
- scheduleProgressEvent(eventNames().loadEvent);
+ scheduleProgressEvent(eventNames().loadEvent);
+ scheduleProgressEvent(eventNames().loadendEvent);
}
}
}
@@ -748,21 +810,29 @@ void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state)
if (m_readyState == oldState)
return;
- if (m_readyState >= HAVE_CURRENT_DATA)
- m_seeking = false;
-
if (m_networkState == NETWORK_EMPTY)
return;
- if (m_seeking && m_readyState < HAVE_CURRENT_DATA) {
+ if (m_seeking) {
+ // 4.8.10.10, step 8
+ if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA)
+ scheduleEvent(eventNames().waitingEvent);
+
// 4.8.10.10, step 9
- scheduleEvent(eventNames().seekingEvent);
- }
+ if (m_readyState < HAVE_CURRENT_DATA) {
+ if (oldState >= HAVE_CURRENT_DATA)
+ scheduleEvent(eventNames().seekingEvent);
+ } else {
+ // 4.8.10.10 step 12 & 13.
+ finishSeek();
+ }
- if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) {
- // 4.8.10.9
- scheduleTimeupdateEvent(false);
- scheduleEvent(eventNames().waitingEvent);
+ } else {
+ if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) {
+ // 4.8.10.9
+ scheduleTimeupdateEvent(false);
+ scheduleEvent(eventNames().waitingEvent);
+ }
}
if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) {
@@ -855,6 +925,13 @@ void HTMLMediaElement::returnToRealtime()
setCurrentTime(maxTimeSeekable(), e);
}
+void HTMLMediaElement::addPlayedRange(float start, float end)
+{
+ if (!m_playedTimeRanges)
+ m_playedTimeRanges = TimeRanges::create();
+ m_playedTimeRanges->add(start, end);
+}
+
bool HTMLMediaElement::supportsSave() const
{
return m_player ? m_player->supportsSave() : false;
@@ -890,7 +967,7 @@ void HTMLMediaElement::seek(float time, ExceptionCode& ec)
// 5
if (m_playing) {
if (m_lastSeekTime < now)
- m_playedTimeRanges->add(m_lastSeekTime, now);
+ addPlayedRange(m_lastSeekTime, now);
}
m_lastSeekTime = time;
@@ -907,6 +984,15 @@ void HTMLMediaElement::seek(float time, ExceptionCode& ec)
m_sentEndEvent = false;
}
+void HTMLMediaElement::finishSeek()
+{
+ // 4.8.10.10 Seeking step 12
+ m_seeking = false;
+
+ // 4.8.10.10 Seeking step 13
+ scheduleEvent(eventNames().seekedEvent);
+}
+
HTMLMediaElement::ReadyState HTMLMediaElement::readyState() const
{
return m_readyState;
@@ -917,6 +1003,11 @@ MediaPlayer::MovieLoadType HTMLMediaElement::movieLoadType() const
return m_player ? m_player->movieLoadType() : MediaPlayer::Unknown;
}
+bool HTMLMediaElement::hasAudio() const
+{
+ return m_player ? m_player->hasAudio() : false;
+}
+
bool HTMLMediaElement::seeking() const
{
return m_seeking;
@@ -1232,7 +1323,19 @@ float HTMLMediaElement::percentLoaded() const
if (!m_player)
return 0;
float duration = m_player->duration();
- return duration ? m_player->maxTimeBuffered() / duration : 0;
+
+ if (!duration || isinf(duration))
+ return 0;
+
+ float buffered = 0;
+ RefPtr<TimeRanges> timeRanges = m_player->buffered();
+ for (unsigned i = 0; i < timeRanges->length(); ++i) {
+ ExceptionCode ignoredException;
+ float start = timeRanges->start(i, ignoredException);
+ float end = timeRanges->end(i, ignoredException);
+ buffered += end - start;
+ }
+ return buffered / duration;
}
bool HTMLMediaElement::havePotentialSourceChild()
@@ -1304,9 +1407,9 @@ void HTMLMediaElement::mediaPlayerTimeChanged(MediaPlayer*)
{
beginProcessingMediaPlayerCallback();
+ // 4.8.10.10 step 12 & 13. Needed if no ReadyState change is associated with the seek.
if (m_readyState >= HAVE_CURRENT_DATA && m_seeking) {
- scheduleEvent(eventNames().seekedEvent);
- m_seeking = false;
+ finishSeek();
}
float now = currentTime();
@@ -1411,23 +1514,22 @@ GraphicsLayer* HTMLMediaElement::mediaPlayerGraphicsLayer(MediaPlayer*)
PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const
{
- // FIXME real ranges support
- if (!m_player || !m_player->maxTimeBuffered())
+ if (!m_player)
return TimeRanges::create();
- return TimeRanges::create(0, m_player->maxTimeBuffered());
+ return m_player->buffered();
}
-PassRefPtr<TimeRanges> HTMLMediaElement::played() const
+PassRefPtr<TimeRanges> HTMLMediaElement::played()
{
- if (!m_playedTimeRanges) {
- // We are not yet loaded
- return TimeRanges::create();
- }
if (m_playing) {
float time = currentTime();
- if (m_lastSeekTime < time)
- m_playedTimeRanges->add(m_lastSeekTime, time);
+ if (time > m_lastSeekTime)
+ addPlayedRange(m_lastSeekTime, time);
}
+
+ if (!m_playedTimeRanges)
+ m_playedTimeRanges = TimeRanges::create();
+
return m_playedTimeRanges->copy();
}
@@ -1528,11 +1630,20 @@ void HTMLMediaElement::updatePlayState()
m_playbackProgressTimer.stop();
m_playing = false;
float time = currentTime();
+<<<<<<< HEAD:WebCore/html/HTMLMediaElement.cpp
if (m_lastSeekTime < time)
m_playedTimeRanges->add(m_lastSeekTime, time);
+=======
+ if (time > m_lastSeekTime)
+ addPlayedRange(m_lastSeekTime, time);
+>>>>>>> webkit.org at 49305:WebCore/html/HTMLMediaElement.cpp
} else if (couldPlayIfEnoughData() && playerPaused)
m_player->prepareToPlay();
+<<<<<<< HEAD:WebCore/html/HTMLMediaElement.cpp
+=======
+
+>>>>>>> webkit.org at 49305:WebCore/html/HTMLMediaElement.cpp
if (renderer())
renderer()->updateFromElement();
}
@@ -1551,35 +1662,44 @@ void HTMLMediaElement::stopPeriodicTimers()
void HTMLMediaElement::userCancelledLoad()
{
- if (m_networkState != NETWORK_EMPTY) {
+ if (m_networkState == NETWORK_EMPTY || m_networkState >= NETWORK_LOADED)
+ return;
- // If the media data fetching process is aborted by the user:
+ // If the media data fetching process is aborted by the user:
- // 1 - The user agent should cancel the fetching process.
+ // 1 - The user agent should cancel the fetching process.
#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
- m_player.clear();
+ m_player.clear();
#endif
- stopPeriodicTimers();
+ stopPeriodicTimers();
- // 2 - Set the error attribute to a new MediaError object whose code attribute is set to MEDIA_ERR_ABORT.
- m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED);
+ // 2 - Set the error attribute to a new MediaError object whose code attribute is set to MEDIA_ERR_ABORT.
+ m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED);
- // 3 - Queue a task to fire a progress event called abort at the media element.
- scheduleProgressEvent(eventNames().abortEvent);
-
- // 4 - If the media element's readyState attribute has a value equal to HAVE_NOTHING, set the
- // element's networkState attribute to the NETWORK_EMPTY value and queue a task to fire a
- // simple event called emptied at the element. Otherwise, set set the element's networkState
- // attribute to the NETWORK_IDLE value.
- if (m_networkState >= NETWORK_LOADING) {
- m_networkState = NETWORK_EMPTY;
- m_readyState = HAVE_NOTHING;
- scheduleEvent(eventNames().emptiedEvent);
- }
+ // 3 - Queue a task to fire a progress event called abort at the media element, in the context
+ // of the fetching process started by this instance of this algorithm.
+ scheduleProgressEvent(eventNames().abortEvent);
- // 5 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event.
- m_delayingTheLoadEvent = false;
+ // 4 - Queue a task to fire a progress event called loadend at the media element, in the context
+ // of the fetching process started by this instance of this algorithm.
+ scheduleProgressEvent(eventNames().loadendEvent);
+
+ // 5 - If the media element's readyState attribute has a value equal to HAVE_NOTHING, set the
+ // element's networkState attribute to the NETWORK_EMPTY value and queue a task to fire a
+ // simple event called emptied at the element. Otherwise, set set the element's networkState
+ // attribute to the NETWORK_IDLE value.
+ if (m_readyState == HAVE_NOTHING) {
+ m_networkState = NETWORK_EMPTY;
+ scheduleEvent(eventNames().emptiedEvent);
}
+ else
+ m_networkState = NETWORK_IDLE;
+
+ // 6 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event.
+ m_delayingTheLoadEvent = false;
+
+ // 7 - Abort the overall resource selection algorithm.
+ m_currentSourceNode = 0;
}
void HTMLMediaElement::documentWillBecomeInactive()
@@ -1610,7 +1730,7 @@ void HTMLMediaElement::documentDidBecomeActive()
ExceptionCode ec;
load(ec);
}
-
+
if (renderer())
renderer()->updateFromElement();
}
@@ -1620,6 +1740,14 @@ void HTMLMediaElement::mediaVolumeDidChange()
updateVolume();
}
+const IntRect HTMLMediaElement::screenRect()
+{
+ IntRect elementRect;
+ if (renderer())
+ elementRect = renderer()->view()->frameView()->contentsToScreen(renderer()->absoluteBoundingBoxRect());
+ return elementRect;
+}
+
void HTMLMediaElement::defaultEventHandler(Event* event)
{
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
@@ -1692,6 +1820,28 @@ void HTMLMediaElement::finishParsingChildren()
#endif
+void HTMLMediaElement::enterFullscreen()
+{
+ ASSERT(!m_isFullscreen);
+ if (!renderer())
+ return;
+ if (document() && document()->page())
+ document()->page()->chrome()->client()->enterFullscreenForNode(this);
+ m_isFullscreen = true;
+}
+
+void HTMLMediaElement::exitFullscreen()
+{
+ ASSERT(m_isFullscreen);
+ if (document() && document()->page())
+ document()->page()->chrome()->client()->exitFullscreenForNode(this);
+ m_isFullscreen = false;
+}
+
+PlatformMedia HTMLMediaElement::platformMedia() const
+{
+ return m_player ? m_player->platformMedia() : NoPlatformMedia;
+}
}
#endif
diff --git a/WebCore/html/HTMLMediaElement.h b/WebCore/html/HTMLMediaElement.h
index 9218ad6..0005e07 100644
--- a/WebCore/html/HTMLMediaElement.h
+++ b/WebCore/html/HTMLMediaElement.h
@@ -43,7 +43,7 @@ class HTMLSourceElement;
class MediaError;
class KURL;
class TimeRanges;
-
+
class HTMLMediaElement : public HTMLElement, public MediaPlayerClient {
public:
HTMLMediaElement(const QualifiedName&, Document*);
@@ -57,6 +57,7 @@ public:
virtual bool rendererIsNeeded(RenderStyle*);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual void insertedIntoDocument();
+ virtual void willRemove();
virtual void removedFromDocument();
virtual void attach();
virtual void recalcStyle(StyleChange);
@@ -65,6 +66,7 @@ public:
virtual bool isVideo() const { return false; }
virtual bool hasVideo() const { return false; }
+ virtual bool hasAudio() const;
void rewind(float timeDelta);
void returnToRealtime();
@@ -72,6 +74,8 @@ public:
// Eventually overloaded in HTMLVideoElement
virtual bool supportsFullscreen() const { return false; };
virtual bool supportsSave() const;
+
+ PlatformMedia platformMedia() const;
void scheduleLoad();
@@ -119,7 +123,7 @@ public:
void setPlaybackRate(float);
bool webkitPreservesPitch() const;
void setWebkitPreservesPitch(bool);
- PassRefPtr<TimeRanges> played() const;
+ PassRefPtr<TimeRanges> played();
PassRefPtr<TimeRanges> seekable() const;
bool ended() const;
bool autoplay() const;
@@ -140,6 +144,8 @@ public:
void beginScrubbing();
void endScrubbing();
+ const IntRect screenRect();
+
bool canPlay() const;
float percentLoaded() const;
@@ -153,6 +159,9 @@ public:
#endif
bool hasSingleSecurityOrigin() const { return !m_player || m_player->hasSingleSecurityOrigin(); }
+
+ void enterFullscreen();
+ void exitFullscreen();
protected:
float getTimeOffsetAttribute(const QualifiedName&, float valueOnError) const;
@@ -190,7 +199,9 @@ private:
void stopPeriodicTimers();
void seek(float time, ExceptionCode&);
+ void finishSeek();
void checkIfSeekNeeded();
+ void addPlayedRange(float start, float end);
void scheduleTimeupdateEvent(bool periodicEvent);
void scheduleProgressEvent(const AtomicString& eventName);
@@ -200,6 +211,7 @@ private:
// loading
void selectMediaResource();
void loadResource(const KURL&, ContentType&);
+ void scheduleNextSourceChild();
void loadNextSourceChild();
void userCancelledLoad();
bool havePotentialSourceChild();
@@ -215,6 +227,8 @@ private:
void loadInternal();
void playInternal();
void pauseInternal();
+
+ void prepareForLoad();
bool processingUserGesture() const;
bool processingMediaPlayerCallback() const { return m_processingMediaPlayerCallback > 0; }
@@ -305,6 +319,8 @@ protected:
// support progress events so setting m_sendProgressEvents disables them
bool m_sendProgressEvents : 1;
+ bool m_isFullscreen : 1;
+
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
bool m_needWidgetUpdate : 1;
#endif
diff --git a/WebCore/html/HTMLObjectElement.cpp b/WebCore/html/HTMLObjectElement.cpp
index 76a9c5a..d3ccfa4 100644
--- a/WebCore/html/HTMLObjectElement.cpp
+++ b/WebCore/html/HTMLObjectElement.cpp
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Stefan Schimanski (1Stein@gmx.de)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
*
* This library is free software; you can redistribute it and/or
@@ -45,8 +45,8 @@ namespace WebCore {
using namespace HTMLNames;
-HTMLObjectElement::HTMLObjectElement(const QualifiedName& tagName, Document* doc, bool createdByParser)
- : HTMLPlugInImageElement(tagName, doc)
+inline HTMLObjectElement::HTMLObjectElement(const QualifiedName& tagName, Document* document, bool createdByParser)
+ : HTMLPlugInImageElement(tagName, document)
, m_docNamedItem(true)
, m_needWidgetUpdate(!createdByParser)
, m_useFallbackContent(false)
@@ -54,8 +54,9 @@ HTMLObjectElement::HTMLObjectElement(const QualifiedName& tagName, Document* doc
ASSERT(hasTagName(objectTag));
}
-HTMLObjectElement::~HTMLObjectElement()
+PassRefPtr<HTMLObjectElement> HTMLObjectElement::create(const QualifiedName& tagName, Document* document, bool createdByParser)
{
+ return adoptRef(new HTMLObjectElement(tagName, document, createdByParser));
}
RenderWidget* HTMLObjectElement::renderWidgetForJSBindings() const
@@ -94,9 +95,11 @@ void HTMLObjectElement::parseMappedAttribute(MappedAttribute *attr)
m_classId = val;
if (renderer())
m_needWidgetUpdate = true;
- } else if (attr->name() == onloadAttr) {
+ } else if (attr->name() == onloadAttr)
setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
- } else if (attr->name() == nameAttr) {
+ else if (attr->name() == onbeforeloadAttr)
+ setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
+ else if (attr->name() == nameAttr) {
const AtomicString& newName = attr->value();
if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
@@ -297,66 +300,6 @@ void HTMLObjectElement::updateDocNamedItem()
m_docNamedItem = isNamedItem;
}
-String HTMLObjectElement::code() const
-{
- return getAttribute(codeAttr);
-}
-
-void HTMLObjectElement::setCode(const String& value)
-{
- setAttribute(codeAttr, value);
-}
-
-String HTMLObjectElement::archive() const
-{
- return getAttribute(archiveAttr);
-}
-
-void HTMLObjectElement::setArchive(const String& value)
-{
- setAttribute(archiveAttr, value);
-}
-
-String HTMLObjectElement::border() const
-{
- return getAttribute(borderAttr);
-}
-
-void HTMLObjectElement::setBorder(const String& value)
-{
- setAttribute(borderAttr, value);
-}
-
-String HTMLObjectElement::codeBase() const
-{
- return getAttribute(codebaseAttr);
-}
-
-void HTMLObjectElement::setCodeBase(const String& value)
-{
- setAttribute(codebaseAttr, value);
-}
-
-String HTMLObjectElement::codeType() const
-{
- return getAttribute(codetypeAttr);
-}
-
-void HTMLObjectElement::setCodeType(const String& value)
-{
- setAttribute(codetypeAttr, value);
-}
-
-KURL HTMLObjectElement::data() const
-{
- return document()->completeURL(getAttribute(dataAttr));
-}
-
-void HTMLObjectElement::setData(const String& value)
-{
- setAttribute(dataAttr, value);
-}
-
bool HTMLObjectElement::declare() const
{
return !getAttribute(declareAttr).isNull();
@@ -377,36 +320,6 @@ void HTMLObjectElement::setHspace(int value)
setAttribute(hspaceAttr, String::number(value));
}
-String HTMLObjectElement::standby() const
-{
- return getAttribute(standbyAttr);
-}
-
-void HTMLObjectElement::setStandby(const String& value)
-{
- setAttribute(standbyAttr, value);
-}
-
-String HTMLObjectElement::type() const
-{
- return getAttribute(typeAttr);
-}
-
-void HTMLObjectElement::setType(const String& value)
-{
- setAttribute(typeAttr, value);
-}
-
-String HTMLObjectElement::useMap() const
-{
- return getAttribute(usemapAttr);
-}
-
-void HTMLObjectElement::setUseMap(const String& value)
-{
- setAttribute(usemapAttr, value);
-}
-
int HTMLObjectElement::vspace() const
{
return getAttribute(vspaceAttr).toInt();
@@ -419,21 +332,19 @@ void HTMLObjectElement::setVspace(int value)
bool HTMLObjectElement::containsJavaApplet() const
{
- if (MIMETypeRegistry::isJavaAppletMIMEType(type()))
+ if (MIMETypeRegistry::isJavaAppletMIMEType(getAttribute(typeAttr)))
return true;
- Node* child = firstChild();
- while (child) {
- if (child->isElementNode()) {
- Element* e = static_cast<Element*>(child);
- if (e->hasTagName(paramTag) && equalIgnoringCase(e->getAttribute(nameAttr), "type") && MIMETypeRegistry::isJavaAppletMIMEType(e->getAttribute(valueAttr).string()))
- return true;
- else if (e->hasTagName(objectTag) && static_cast<HTMLObjectElement*>(e)->containsJavaApplet())
- return true;
- else if (e->hasTagName(appletTag))
- return true;
- }
- child = child->nextSibling();
+ for (Element* child = firstElementChild(); child; child = child->nextElementSibling()) {
+ if (child->hasTagName(paramTag)
+ && equalIgnoringCase(child->getAttribute(nameAttr), "type")
+ && MIMETypeRegistry::isJavaAppletMIMEType(child->getAttribute(valueAttr).string()))
+ return true;
+ if (child->hasTagName(objectTag)
+ && static_cast<HTMLObjectElement*>(child)->containsJavaApplet())
+ return true;
+ if (child->hasTagName(appletTag))
+ return true;
}
return false;
@@ -443,9 +354,13 @@ void HTMLObjectElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) con
{
HTMLPlugInImageElement::addSubresourceAttributeURLs(urls);
- addSubresourceURL(urls, data());
- if (useMap().startsWith("#"))
- addSubresourceURL(urls, document()->completeURL(useMap()));
+ addSubresourceURL(urls, document()->completeURL(getAttribute(dataAttr)));
+
+ // FIXME: Passing a string that starts with "#" to the completeURL function does
+ // not seem like it would work. The image element has similar but not identical code.
+ const AtomicString& useMap = getAttribute(usemapAttr);
+ if (useMap.startsWith("#"))
+ addSubresourceURL(urls, document()->completeURL(useMap));
}
}
diff --git a/WebCore/html/HTMLObjectElement.h b/WebCore/html/HTMLObjectElement.h
index 8f31bda..ec1132f 100644
--- a/WebCore/html/HTMLObjectElement.h
+++ b/WebCore/html/HTMLObjectElement.h
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -27,12 +27,31 @@
namespace WebCore {
-class KURL;
-
class HTMLObjectElement : public HTMLPlugInImageElement {
public:
+ static PassRefPtr<HTMLObjectElement> create(const QualifiedName&, Document*, bool createdByParser);
+
+ void setNeedWidgetUpdate(bool needWidgetUpdate) { m_needWidgetUpdate = needWidgetUpdate; }
+
+ void renderFallbackContent();
+
+ bool declare() const;
+ void setDeclare(bool);
+
+ int hspace() const;
+ void setHspace(int);
+
+ int vspace() const;
+ void setVspace(int);
+
+ bool isDocNamedItem() const { return m_docNamedItem; }
+
+ const String& classId() const { return m_classId; }
+
+ bool containsJavaApplet() const;
+
+private:
HTMLObjectElement(const QualifiedName&, Document*, bool createdByParser);
- ~HTMLObjectElement();
virtual int tagPriority() const { return 5; }
@@ -54,57 +73,11 @@ public:
virtual const QualifiedName& imageSourceAttributeName() const;
virtual void updateWidget();
- void setNeedWidgetUpdate(bool needWidgetUpdate) { m_needWidgetUpdate = needWidgetUpdate; }
-
- void renderFallbackContent();
virtual RenderWidget* renderWidgetForJSBindings() const;
- String archive() const;
- void setArchive(const String&);
-
- String border() const;
- void setBorder(const String&);
-
- String code() const;
- void setCode(const String&);
-
- String codeBase() const;
- void setCodeBase(const String&);
-
- String codeType() const;
- void setCodeType(const String&);
-
- KURL data() const;
- void setData(const String&);
-
- bool declare() const;
- void setDeclare(bool);
-
- int hspace() const;
- void setHspace(int);
-
- String standby() const;
- void setStandby(const String&);
-
- String type() const;
- void setType(const String&);
-
- String useMap() const;
- void setUseMap(const String&);
-
- int vspace() const;
- void setVspace(int);
-
- bool isDocNamedItem() const { return m_docNamedItem; }
-
- const String& classId() const { return m_classId; }
-
- bool containsJavaApplet() const;
-
virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
-private:
void updateDocNamedItem();
AtomicString m_id;
diff --git a/WebCore/html/HTMLObjectElement.idl b/WebCore/html/HTMLObjectElement.idl
index 1880836..b51c568 100644
--- a/WebCore/html/HTMLObjectElement.idl
+++ b/WebCore/html/HTMLObjectElement.idl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* This library is free software; you can redistribute it and/or
@@ -30,22 +30,23 @@ module html {
ImplementationUUID=2dd24554-6784-4ef9-9713-179f3d37b2f9
] HTMLObjectElement : HTMLElement {
readonly attribute HTMLFormElement form;
- attribute [ConvertNullToNullString] DOMString code;
- attribute [ConvertNullToNullString] DOMString align;
- attribute [ConvertNullToNullString] DOMString archive;
- attribute [ConvertNullToNullString] DOMString border;
- attribute [ConvertNullToNullString] DOMString codeBase;
- attribute [ConvertNullToNullString] DOMString codeType;
- attribute [ConvertNullToNullString] DOMString data;
+ attribute [ConvertNullToNullString, Reflect] DOMString code;
+ attribute [ConvertNullToNullString, Reflect] DOMString align;
+ attribute [ConvertNullToNullString, Reflect] DOMString archive;
+ attribute [ConvertNullToNullString, Reflect] DOMString border;
+ attribute [ConvertNullToNullString, Reflect=codebase] DOMString codeBase;
+ attribute [ConvertNullToNullString, Reflect=codetype] DOMString codeType;
+ attribute [ConvertNullToNullString, ReflectURL] DOMString data;
attribute boolean declare;
- attribute [ConvertNullToNullString] DOMString height;
+ attribute [ConvertNullToNullString, Reflect] DOMString height;
attribute long hspace;
- attribute [ConvertNullToNullString] DOMString name;
- attribute [ConvertNullToNullString] DOMString standby;
- attribute [ConvertNullToNullString] DOMString type;
- attribute [ConvertNullToNullString] DOMString useMap;
+ attribute [ConvertNullToNullString, Reflect] DOMString name;
+ attribute [ConvertNullToNullString, Reflect] DOMString standby;
+ attribute [ConvertNullToNullString, Reflect] DOMString type;
+ attribute [ConvertNullToNullString, Reflect=usemap] DOMString useMap;
attribute long vspace;
- attribute [ConvertNullToNullString] DOMString width;
+ attribute [ConvertNullToNullString, Reflect] DOMString width;
+ readonly attribute boolean willValidate;
// Introduced in DOM Level 2:
readonly attribute [CheckFrameSecurity] Document contentDocument;
diff --git a/WebCore/html/HTMLOptGroupElement.cpp b/WebCore/html/HTMLOptGroupElement.cpp
index af81b07..90156da 100644
--- a/WebCore/html/HTMLOptGroupElement.cpp
+++ b/WebCore/html/HTMLOptGroupElement.cpp
@@ -44,9 +44,15 @@ HTMLOptGroupElement::HTMLOptGroupElement(const QualifiedName& tagName, Document*
ASSERT(hasTagName(optgroupTag));
}
+bool HTMLOptGroupElement::supportsFocus() const
+{
+ return HTMLElement::supportsFocus();
+}
+
bool HTMLOptGroupElement::isFocusable() const
{
- return HTMLElement::isFocusable();
+ // Optgroup elements do not have a renderer so we check the renderStyle instead.
+ return supportsFocus() && renderStyle() && renderStyle()->display() != NONE;
}
const AtomicString& HTMLOptGroupElement::formControlType() const
diff --git a/WebCore/html/HTMLOptGroupElement.h b/WebCore/html/HTMLOptGroupElement.h
index 13e92ca..6e5b043 100644
--- a/WebCore/html/HTMLOptGroupElement.h
+++ b/WebCore/html/HTMLOptGroupElement.h
@@ -37,6 +37,7 @@ public:
virtual bool checkDTD(const Node*);
virtual const AtomicString& formControlType() const;
+ virtual bool supportsFocus() const;
virtual bool isFocusable() const;
virtual void parseMappedAttribute(MappedAttribute*);
virtual bool rendererIsNeeded(RenderStyle*) { return false; }
diff --git a/WebCore/html/HTMLOptionElement.cpp b/WebCore/html/HTMLOptionElement.cpp
index 009db47..501615f 100644
--- a/WebCore/html/HTMLOptionElement.cpp
+++ b/WebCore/html/HTMLOptionElement.cpp
@@ -66,9 +66,15 @@ void HTMLOptionElement::detach()
HTMLFormControlElement::detach();
}
+bool HTMLOptionElement::supportsFocus() const
+{
+ return HTMLElement::supportsFocus();
+}
+
bool HTMLOptionElement::isFocusable() const
{
- return HTMLElement::isFocusable();
+ // Option elements do not have a renderer so we check the renderStyle instead.
+ return supportsFocus() && renderStyle() && renderStyle()->display() != NONE;
}
const AtomicString& HTMLOptionElement::formControlType() const
@@ -92,7 +98,7 @@ void HTMLOptionElement::setText(const String &text, ExceptionCode& ec)
}
removeChildren();
- appendChild(new Text(document(), text), ec);
+ appendChild(Text::create(document(), text), ec);
}
void HTMLOptionElement::accessKeyAction(bool)
diff --git a/WebCore/html/HTMLOptionElement.h b/WebCore/html/HTMLOptionElement.h
index f13a802..843608f 100644
--- a/WebCore/html/HTMLOptionElement.h
+++ b/WebCore/html/HTMLOptionElement.h
@@ -42,6 +42,7 @@ public:
virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
virtual int tagPriority() const { return 2; }
virtual bool checkDTD(const Node* newChild);
+ virtual bool supportsFocus() const;
virtual bool isFocusable() const;
virtual bool rendererIsNeeded(RenderStyle*) { return false; }
virtual void attach();
diff --git a/WebCore/html/HTMLParser.cpp b/WebCore/html/HTMLParser.cpp
index 722f4e2..1cb47ae 100644
--- a/WebCore/html/HTMLParser.cpp
+++ b/WebCore/html/HTMLParser.cpp
@@ -692,13 +692,13 @@ typedef HashMap<AtomicStringImpl*, CreateErrorCheckFunc> FunctionMap;
bool HTMLParser::textCreateErrorCheck(Token* t, RefPtr<Node>& result)
{
- result = new Text(m_document, t->text.get());
+ result = Text::create(m_document, t->text.get());
return false;
}
bool HTMLParser::commentCreateErrorCheck(Token* t, RefPtr<Node>& result)
{
- result = new Comment(m_document, t->text.get());
+ result = Comment::create(m_document, t->text.get());
return false;
}
@@ -921,6 +921,7 @@ PassRefPtr<Node> HTMLParser::getNode(Token* t)
gFunctionMap.set(listingTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck);
gFunctionMap.set(mapTag.localName().impl(), &HTMLParser::mapCreateErrorCheck);
gFunctionMap.set(menuTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck);
+ gFunctionMap.set(navTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck);
gFunctionMap.set(nobrTag.localName().impl(), &HTMLParser::nestedCreateErrorCheck);
gFunctionMap.set(noembedTag.localName().impl(), &HTMLParser::noembedCreateErrorCheck);
gFunctionMap.set(noframesTag.localName().impl(), &HTMLParser::noframesCreateErrorCheck);
@@ -1093,6 +1094,7 @@ bool HTMLParser::isAffectedByResidualStyle(const AtomicString& tagName)
unaffectedTags.add(selectTag.localName().impl());
unaffectedTags.add(objectTag.localName().impl());
unaffectedTags.add(datagridTag.localName().impl());
+ unaffectedTags.add(datalistTag.localName().impl());
}
return !unaffectedTags.contains(tagName.impl());
@@ -1598,7 +1600,7 @@ PassRefPtr<Node> HTMLParser::handleIsindex(Token* t)
}
n->addChild(new HTMLHRElement(hrTag, m_document));
- n->addChild(new Text(m_document, text));
+ n->addChild(Text::create(m_document, text));
n->addChild(isIndex.release());
n->addChild(new HTMLHRElement(hrTag, m_document));
diff --git a/WebCore/html/HTMLPlugInElement.cpp b/WebCore/html/HTMLPlugInElement.cpp
index 7aa6083..2f429b4 100644
--- a/WebCore/html/HTMLPlugInElement.cpp
+++ b/WebCore/html/HTMLPlugInElement.cpp
@@ -91,16 +91,6 @@ PassScriptInstance HTMLPlugInElement::getInstance() const
return m_instance;
}
-String HTMLPlugInElement::align() const
-{
- return getAttribute(alignAttr);
-}
-
-void HTMLPlugInElement::setAlign(const String& value)
-{
- setAttribute(alignAttr, value);
-}
-
String HTMLPlugInElement::height() const
{
return getAttribute(heightAttr);
@@ -111,16 +101,6 @@ void HTMLPlugInElement::setHeight(const String& value)
setAttribute(heightAttr, value);
}
-String HTMLPlugInElement::name() const
-{
- return getAttribute(nameAttr);
-}
-
-void HTMLPlugInElement::setName(const String& value)
-{
- setAttribute(nameAttr, value);
-}
-
String HTMLPlugInElement::width() const
{
return getAttribute(widthAttr);
diff --git a/WebCore/html/HTMLPlugInElement.h b/WebCore/html/HTMLPlugInElement.h
index a9cbcc9..9d3dc6d 100644
--- a/WebCore/html/HTMLPlugInElement.h
+++ b/WebCore/html/HTMLPlugInElement.h
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -36,43 +36,44 @@ class RenderWidget;
class HTMLPlugInElement : public HTMLFrameOwnerElement {
public:
- HTMLPlugInElement(const QualifiedName& tagName, Document*);
virtual ~HTMLPlugInElement();
- virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
- virtual void parseMappedAttribute(MappedAttribute*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual bool checkDTD(const Node* newChild);
-
- virtual void updateWidget() { }
-
- String align() const;
- void setAlign(const String&);
-
String height() const;
void setHeight(const String&);
- String name() const;
- void setName(const String&);
-
String width() const;
void setWidth(const String&);
- virtual void defaultEventHandler(Event*);
-
- virtual RenderWidget* renderWidgetForJSBindings() const = 0;
- virtual void detach();
PassScriptInstance getInstance() const;
#if ENABLE(NETSCAPE_PLUGIN_API)
- virtual NPObject* getNPObject();
+ NPObject* getNPObject();
#endif
protected:
+ HTMLPlugInElement(const QualifiedName& tagName, Document*);
+
+ virtual void detach();
+
static void updateWidgetCallback(Node*);
+ virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
+ virtual void parseMappedAttribute(MappedAttribute*);
+
+private:
+ virtual void defaultEventHandler(Event*);
+
+ virtual RenderWidget* renderWidgetForJSBindings() const = 0;
+
+ virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
+ virtual bool checkDTD(const Node* newChild);
+
+ virtual void updateWidget() { }
+
+protected:
AtomicString m_name;
+
+private:
mutable ScriptInstance m_instance;
#if ENABLE(NETSCAPE_PLUGIN_API)
NPObject* m_NPObject;
diff --git a/WebCore/html/HTMLPlugInImageElement.h b/WebCore/html/HTMLPlugInImageElement.h
index ec3b258..7725a5a 100644
--- a/WebCore/html/HTMLPlugInImageElement.h
+++ b/WebCore/html/HTMLPlugInImageElement.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -30,15 +30,16 @@ class HTMLImageLoader;
class HTMLPlugInImageElement : public HTMLPlugInElement {
public:
- HTMLPlugInImageElement(const QualifiedName& tagName, Document*);
virtual ~HTMLPlugInImageElement();
- bool isImageType();
-
const String& serviceType() const { return m_serviceType; }
const String& url() const { return m_url; }
protected:
+ HTMLPlugInImageElement(const QualifiedName& tagName, Document*);
+
+ bool isImageType();
+
OwnPtr<HTMLImageLoader> m_imageLoader;
String m_serviceType;
String m_url;
diff --git a/WebCore/html/HTMLScriptElement.cpp b/WebCore/html/HTMLScriptElement.cpp
index 86cc3a2..636c579 100644
--- a/WebCore/html/HTMLScriptElement.cpp
+++ b/WebCore/html/HTMLScriptElement.cpp
@@ -24,6 +24,7 @@
#include "HTMLScriptElement.h"
#include "Document.h"
+#include "Event.h"
#include "EventNames.h"
#include "HTMLNames.h"
#include "MappedAttribute.h"
@@ -70,6 +71,8 @@ void HTMLScriptElement::parseMappedAttribute(MappedAttribute* attr)
handleSourceAttribute(m_data, attr->value());
else if (attrName == onloadAttr)
setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
+ else if (attrName == onbeforeloadAttr)
+ setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
else
HTMLElement::parseMappedAttribute(attr);
}
@@ -216,18 +219,18 @@ String HTMLScriptElement::forAttributeValue() const
{
return getAttribute(forAttr).string();
}
-
+
void HTMLScriptElement::dispatchLoadEvent()
{
ASSERT(!m_data.haveFiredLoadEvent());
m_data.setHaveFiredLoadEvent(true);
- dispatchEvent(eventNames().loadEvent, false, false);
+ dispatchEvent(Event::create(eventNames().loadEvent, false, false));
}
void HTMLScriptElement::dispatchErrorEvent()
{
- dispatchEvent(eventNames().errorEvent, true, false);
+ dispatchEvent(Event::create(eventNames().errorEvent, true, false));
}
}
diff --git a/WebCore/html/HTMLSelectElement.idl b/WebCore/html/HTMLSelectElement.idl
index 177895e..53fe848 100644
--- a/WebCore/html/HTMLSelectElement.idl
+++ b/WebCore/html/HTMLSelectElement.idl
@@ -45,6 +45,7 @@ module html {
readonly attribute ValidityState validity;
#endif
readonly attribute boolean willValidate;
+ boolean checkValidity();
void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error);
// Modified in DOM Level 2:
diff --git a/WebCore/html/HTMLSourceElement.cpp b/WebCore/html/HTMLSourceElement.cpp
index 2f09997..4b9401d 100644
--- a/WebCore/html/HTMLSourceElement.cpp
+++ b/WebCore/html/HTMLSourceElement.cpp
@@ -28,6 +28,7 @@
#if ENABLE(VIDEO)
#include "HTMLSourceElement.h"
+#include "Event.h"
#include "EventNames.h"
#include "HTMLDocument.h"
#include "HTMLMediaElement.h"
@@ -105,7 +106,7 @@ void HTMLSourceElement::cancelPendingErrorEvent()
void HTMLSourceElement::errorEventTimerFired(Timer<HTMLSourceElement>*)
{
- dispatchEvent(eventNames().errorEvent, false, true);
+ dispatchEvent(Event::create(eventNames().errorEvent, false, true));
}
}
diff --git a/WebCore/html/HTMLTagNames.in b/WebCore/html/HTMLTagNames.in
index c066e3c..8842b23 100644
--- a/WebCore/html/HTMLTagNames.in
+++ b/WebCore/html/HTMLTagNames.in
@@ -8,115 +8,118 @@ acronym interfaceName=HTMLElement
address interfaceName=HTMLElement
applet
area
-audio wrapperOnlyIfMediaIsAvailable,conditional=VIDEO
+audio wrapperOnlyIfMediaIsAvailable, conditional=VIDEO, createWithNew
b interfaceName=HTMLElement
-base
-basefont interfaceName=HTMLBaseFontElement
+base createWithNew
+basefont interfaceName=HTMLBaseFontElement, createWithNew
bdo interfaceName=HTMLElement
big interfaceName=HTMLElement
-blockquote
-body
-br interfaceName=HTMLBRElement
-button constructorNeedsFormElement
-canvas
-caption interfaceName=HTMLTableCaptionElement
+blockquote createWithNew
+body createWithNew
+br interfaceName=HTMLBRElement, createWithNew
+button constructorNeedsFormElement, createWithNew
+canvas createWithNew
+caption interfaceName=HTMLTableCaptionElement, createWithNew
center interfaceName=HTMLElement
cite interfaceName=HTMLElement
code interfaceName=HTMLElement
-col interfaceName=HTMLTableColElement
-colgroup interfaceName=HTMLTableColElement
-datagrid interfaceName=HTMLDataGridElement,conditional=DATAGRID
-dcell interfaceName=HTMLDataGridCellElement,conditional=DATAGRID
-dcol interfaceName=HTMLDataGridColElement,conditional=DATAGRID
-drow interfaceName=HTMLDataGridRowElement,conditional=DATAGRID
+col interfaceName=HTMLTableColElement, createWithNew
+colgroup interfaceName=HTMLTableColElement, createWithNew
+datagrid interfaceName=HTMLDataGridElement, conditional=DATAGRID, createWithNew
+datalist interfaceName=HTMLDataListElement, conditional=DATALIST, createWithNew
+dcell interfaceName=HTMLDataGridCellElement, conditional=DATAGRID, createWithNew
+dcol interfaceName=HTMLDataGridColElement, conditional=DATAGRID, createWithNew
+drow interfaceName=HTMLDataGridRowElement, conditional=DATAGRID, createWithNew
dd interfaceName=HTMLElement
-del interfaceName=HTMLModElement
+del interfaceName=HTMLModElement, createWithNew
dfn interfaceName=HTMLElement
-dir interfaceName=HTMLDirectoryElement
-div
-dl interfaceName=HTMLDListElement
+dir interfaceName=HTMLDirectoryElement, createWithNew
+div createWithNew
+dl interfaceName=HTMLDListElement, createWithNew, createWithNew
dt interfaceName=HTMLElement
em interfaceName=HTMLElement
embed
-fieldset interfaceName=HTMLFieldSetElement, constructorNeedsFormElement
-font
-form
+fieldset interfaceName=HTMLFieldSetElement, constructorNeedsFormElement, createWithNew
+font createWithNew
+form createWithNew
frame
-frameset interfaceName=HTMLFrameSetElement
-head
-h1 interfaceName=HTMLHeadingElement
-h2 interfaceName=HTMLHeadingElement
-h3 interfaceName=HTMLHeadingElement
-h4 interfaceName=HTMLHeadingElement
-h5 interfaceName=HTMLHeadingElement
-h6 interfaceName=HTMLHeadingElement
-hr interfaceName=HTMLHRElement
-html
+frameset interfaceName=HTMLFrameSetElement, createWithNew
+h1 interfaceName=HTMLHeadingElement, createWithNew
+h2 interfaceName=HTMLHeadingElement, createWithNew
+h3 interfaceName=HTMLHeadingElement, createWithNew
+h4 interfaceName=HTMLHeadingElement, createWithNew
+h5 interfaceName=HTMLHeadingElement, createWithNew
+h6 interfaceName=HTMLHeadingElement, createWithNew
+head createWithNew
+hr interfaceName=HTMLHRElement, createWithNew
+html createWithNew
i interfaceName=HTMLElement
iframe interfaceName=HTMLIFrameElement
-image mapToTagName=img
-img interfaceName=HTMLImageElement, constructorNeedsFormElement
-input constructorNeedsFormElement
-ins interfaceName=HTMLModElement
-isindex interfaceName=HTMLIsIndexElement, constructorNeedsFormElement
+image mapToTagName=img, createWithNew
+img interfaceName=HTMLImageElement, constructorNeedsFormElement, createWithNew
+input constructorNeedsFormElement, createWithNew
+ins interfaceName=HTMLModElement, createWithNew
+isindex interfaceName=HTMLIsIndexElement, constructorNeedsFormElement, createWithNew
kbd interfaceName=HTMLElement
-keygen JSInterfaceName=HTMLSelectElement, constructorNeedsFormElement
-label
+keygen JSInterfaceName=HTMLSelectElement, constructorNeedsFormElement, createWithNew
+label createWithNew
layer interfaceName=HTMLElement
-legend constructorNeedsFormElement
-li interfaceName=HTMLLIElement
-link constructorNeedsCreatedByParser
-listing interfaceName=HTMLPreElement
-map
-marquee
-menu
-meta
+legend constructorNeedsFormElement, createWithNew
+li interfaceName=HTMLLIElement, createWithNew
+link constructorNeedsCreatedByParser, createWithNew
+listing interfaceName=HTMLPreElement, createWithNew
+map createWithNew
+marquee createWithNew
+menu createWithNew
+meta createWithNew
+nav interfaceName=HTMLElement
nobr interfaceName=HTMLElement
noembed interfaceName=HTMLElement
noframes interfaceName=HTMLElement
nolayer interfaceName=HTMLElement
-#if ENABLE_XHTMLMP
-noscript interfaceName=HTMLNoScriptElement
-#else
-noscript interfaceName=HTMLElement
-#endif
object constructorNeedsCreatedByParser
-ol interfaceName=HTMLOListElement
-optgroup interfaceName=HTMLOptGroupElement, constructorNeedsFormElement
-option constructorNeedsFormElement
-p interfaceName=HTMLParagraphElement
-param
+ol interfaceName=HTMLOListElement, createWithNew
+optgroup interfaceName=HTMLOptGroupElement, constructorNeedsFormElement, createWithNew
+option constructorNeedsFormElement, createWithNew
+p interfaceName=HTMLParagraphElement, createWithNew
+param createWithNew
plaintext interfaceName=HTMLElement
-pre
-q interfaceName=HTMLQuoteElement
+pre createWithNew
+q interfaceName=HTMLQuoteElement, createWithNew
rp interfaceName=HTMLElement
rt interfaceName=HTMLElement
ruby interfaceName=HTMLElement
s interfaceName=HTMLElement
samp interfaceName=HTMLElement
-script constructorNeedsCreatedByParser
-select constructorNeedsFormElement
+script constructorNeedsCreatedByParser, createWithNew
+select constructorNeedsFormElement, createWithNew
small interfaceName=HTMLElement
-source wrapperOnlyIfMediaIsAvailable,conditional=VIDEO
+source wrapperOnlyIfMediaIsAvailable, conditional=VIDEO, createWithNew
span interfaceName=HTMLElement
strike interfaceName=HTMLElement
strong interfaceName=HTMLElement
-style constructorNeedsCreatedByParser
+style constructorNeedsCreatedByParser, createWithNew
sub interfaceName=HTMLElement
sup interfaceName=HTMLElement
-table
-tbody interfaceName=HTMLTableSectionElement
-td interfaceName=HTMLTableCellElement
-textarea interfaceName=HTMLTextAreaElement, constructorNeedsFormElement
-tfoot interfaceName=HTMLTableSectionElement
-th interfaceName=HTMLTableCellElement
-thead interfaceName=HTMLTableSectionElement
-title
-tr interfaceName=HTMLTableRowElement
+table createWithNew
+tbody interfaceName=HTMLTableSectionElement, createWithNew
+td interfaceName=HTMLTableCellElement, createWithNew
+textarea interfaceName=HTMLTextAreaElement, constructorNeedsFormElement, createWithNew
+tfoot interfaceName=HTMLTableSectionElement, createWithNew
+th interfaceName=HTMLTableCellElement, createWithNew
+thead interfaceName=HTMLTableSectionElement, createWithNew
+title createWithNew
+tr interfaceName=HTMLTableRowElement, createWithNew
tt interfaceName=HTMLElement
u interfaceName=HTMLElement
-ul interfaceName=HTMLUListElement
+ul interfaceName=HTMLUListElement, createWithNew
var interfaceName=HTMLElement
-video wrapperOnlyIfMediaIsAvailable,conditional=VIDEO
+video wrapperOnlyIfMediaIsAvailable, conditional=VIDEO, createWithNew
wbr interfaceName=HTMLElement
-xmp interfaceName=HTMLPreElement
+xmp interfaceName=HTMLPreElement, createWithNew
+
+#if ENABLE_XHTMLMP
+noscript interfaceName=HTMLNoScriptElement, createWithNew
+#else
+noscript interfaceName=HTMLElement
+#endif
diff --git a/WebCore/html/HTMLTextAreaElement.cpp b/WebCore/html/HTMLTextAreaElement.cpp
index 884cf3f..8d8208d 100644
--- a/WebCore/html/HTMLTextAreaElement.cpp
+++ b/WebCore/html/HTMLTextAreaElement.cpp
@@ -26,21 +26,25 @@
#include "config.h"
#include "HTMLTextAreaElement.h"
+#include "BeforeTextInsertedEvent.h"
#include "ChromeClient.h"
#include "CSSValueKeywords.h"
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
+#include "ExceptionCode.h"
#include "FocusController.h"
#include "FormDataList.h"
#include "Frame.h"
#include "HTMLNames.h"
+#include "InputElement.h"
#include "MappedAttribute.h"
#include "Page.h"
#include "RenderStyle.h"
#include "RenderTextControlMultiLine.h"
#include "ScriptEventListener.h"
#include "Text.h"
+#include "TextIterator.h"
#include "VisibleSelection.h"
#include <wtf/StdLibExtras.h>
@@ -64,12 +68,13 @@ static inline void notifyFormStateChanged(const HTMLTextAreaElement* element)
}
HTMLTextAreaElement::HTMLTextAreaElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
- : HTMLFormControlElementWithState(tagName, document, form)
+ : HTMLTextFormControlElement(tagName, document, form)
, m_rows(defaultRows)
, m_cols(defaultCols)
, m_wrap(SoftWrap)
, m_cachedSelectionStart(-1)
, m_cachedSelectionEnd(-1)
+ , m_isDirty(false)
{
ASSERT(hasTagName(textareaTag));
setFormControlValueMatchesRenderer(true);
@@ -93,54 +98,6 @@ void HTMLTextAreaElement::restoreFormControlState(const String& state)
setDefaultValue(state);
}
-int HTMLTextAreaElement::selectionStart()
-{
- if (!renderer())
- return 0;
- if (document()->focusedNode() != this && m_cachedSelectionStart >= 0)
- return m_cachedSelectionStart;
- return toRenderTextControl(renderer())->selectionStart();
-}
-
-int HTMLTextAreaElement::selectionEnd()
-{
- if (!renderer())
- return 0;
- if (document()->focusedNode() != this && m_cachedSelectionEnd >= 0)
- return m_cachedSelectionEnd;
- return toRenderTextControl(renderer())->selectionEnd();
-}
-
-static RenderTextControl* rendererAfterUpdateLayout(HTMLTextAreaElement* element)
-{
- element->document()->updateLayoutIgnorePendingStylesheets();
- return toRenderTextControl(element->renderer());
-}
-
-void HTMLTextAreaElement::setSelectionStart(int start)
-{
- if (RenderTextControl* renderer = rendererAfterUpdateLayout(this))
- renderer->setSelectionStart(start);
-}
-
-void HTMLTextAreaElement::setSelectionEnd(int end)
-{
- if (RenderTextControl* renderer = rendererAfterUpdateLayout(this))
- renderer->setSelectionEnd(end);
-}
-
-void HTMLTextAreaElement::select()
-{
- if (RenderTextControl* renderer = rendererAfterUpdateLayout(this))
- renderer->select();
-}
-
-void HTMLTextAreaElement::setSelectionRange(int start, int end)
-{
- if (RenderTextControl* renderer = rendererAfterUpdateLayout(this))
- renderer->setSelectionRange(start, end);
-}
-
void HTMLTextAreaElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
setValue(defaultValue());
@@ -196,21 +153,13 @@ void HTMLTextAreaElement::parseMappedAttribute(MappedAttribute* attr)
} else if (attr->name() == alignAttr) {
// Don't map 'align' attribute. This matches what Firefox, Opera and IE do.
// See http://bugs.webkit.org/show_bug.cgi?id=7075
- } else if (attr->name() == onfocusAttr)
- setAttributeEventListener(eventNames().focusEvent, createAttributeEventListener(this, attr));
- else if (attr->name() == onblurAttr)
- setAttributeEventListener(eventNames().blurEvent, createAttributeEventListener(this, attr));
- else if (attr->name() == onselectAttr)
- setAttributeEventListener(eventNames().selectEvent, createAttributeEventListener(this, attr));
- else if (attr->name() == onchangeAttr)
- setAttributeEventListener(eventNames().changeEvent, createAttributeEventListener(this, attr));
- else
- HTMLFormControlElementWithState::parseMappedAttribute(attr);
+ } else
+ HTMLTextFormControlElement::parseMappedAttribute(attr);
}
RenderObject* HTMLTextAreaElement::createRenderer(RenderArena* arena, RenderStyle*)
{
- return new (arena) RenderTextControlMultiLine(this);
+ return new (arena) RenderTextControlMultiLine(this, placeholderShouldBeVisible());
}
bool HTMLTextAreaElement::appendFormData(FormDataList& encoding, bool)
@@ -229,6 +178,7 @@ bool HTMLTextAreaElement::appendFormData(FormDataList& encoding, bool)
void HTMLTextAreaElement::reset()
{
setValue(defaultValue());
+ m_isDirty = false;
}
bool HTMLTextAreaElement::isKeyboardFocusable(KeyboardEvent*) const
@@ -272,10 +222,34 @@ void HTMLTextAreaElement::defaultEventHandler(Event* event)
{
if (renderer() && (event->isMouseEvent() || event->isDragEvent() || event->isWheelEvent() || event->type() == eventNames().blurEvent))
toRenderTextControlMultiLine(renderer())->forwardEvent(event);
+ else if (renderer() && event->isBeforeTextInsertedEvent())
+ handleBeforeTextInsertedEvent(static_cast<BeforeTextInsertedEvent*>(event));
HTMLFormControlElementWithState::defaultEventHandler(event);
}
+void HTMLTextAreaElement::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event) const
+{
+ ASSERT(event);
+ ASSERT(renderer());
+ int signedMaxLength = maxLength();
+ if (signedMaxLength < 0)
+ return;
+ unsigned unsignedMaxLength = static_cast<unsigned>(signedMaxLength);
+
+ unsigned currentLength = toRenderTextControl(renderer())->text().numGraphemeClusters();
+ unsigned selectionLength = plainText(document()->frame()->selection()->selection().toNormalizedRange().get()).numGraphemeClusters();
+ ASSERT(currentLength >= selectionLength);
+ unsigned baseLength = currentLength - selectionLength;
+ unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLength - baseLength : 0;
+ event->setText(sanitizeUserInputValue(event->text(), appendableLength));
+}
+
+String HTMLTextAreaElement::sanitizeUserInputValue(const String& proposedValue, unsigned maxLength)
+{
+ return proposedValue.left(proposedValue.numCharactersInGraphemeClusters(maxLength));
+}
+
void HTMLTextAreaElement::rendererWillBeDestroyed()
{
updateValue();
@@ -290,6 +264,7 @@ void HTMLTextAreaElement::updateValue() const
m_value = toRenderTextControl(renderer())->text();
const_cast<HTMLTextAreaElement*>(this)->setFormControlValueMatchesRenderer(true);
notifyFormStateChanged(this);
+ m_isDirty = true;
}
String HTMLTextAreaElement::value() const
@@ -313,6 +288,7 @@ void HTMLTextAreaElement::setValue(const String& value)
m_value = normalizedValue;
setFormControlValueMatchesRenderer(true);
+ updatePlaceholderVisibility(false);
if (inDocument())
document()->updateStyleIfNeeded();
if (renderer())
@@ -330,6 +306,7 @@ void HTMLTextAreaElement::setValue(const String& value)
setNeedsStyleRecalc();
notifyFormStateChanged(this);
+ updateValidity();
}
String HTMLTextAreaElement::defaultValue() const
@@ -379,6 +356,33 @@ void HTMLTextAreaElement::setDefaultValue(const String& defaultValue)
setValue(value);
}
+int HTMLTextAreaElement::maxLength() const
+{
+ bool ok;
+ int value = getAttribute(maxlengthAttr).string().toInt(&ok);
+ return ok && value >= 0 ? value : -1;
+}
+
+void HTMLTextAreaElement::setMaxLength(int newValue, ExceptionCode& ec)
+{
+ if (newValue < 0)
+ ec = INDEX_SIZE_ERR;
+ else
+ setAttribute(maxlengthAttr, String::number(newValue));
+}
+
+bool HTMLTextAreaElement::tooLong() const
+{
+ // Return false for the default value even if it is longer than maxLength.
+ if (!m_isDirty)
+ return false;
+
+ int max = maxLength();
+ if (max < 0)
+ return false;
+ return value().length() > static_cast<unsigned>(max);
+}
+
void HTMLTextAreaElement::accessKeyAction(bool)
{
focus();
@@ -404,13 +408,6 @@ void HTMLTextAreaElement::setRows(int rows)
setAttribute(rowsAttr, String::number(rows));
}
-VisibleSelection HTMLTextAreaElement::selection() const
-{
- if (!renderer() || m_cachedSelectionStart < 0 || m_cachedSelectionEnd < 0)
- return VisibleSelection();
- return toRenderTextControl(renderer())->selection(m_cachedSelectionStart, m_cachedSelectionEnd);
-}
-
bool HTMLTextAreaElement::shouldUseInputMethod() const
{
return true;
diff --git a/WebCore/html/HTMLTextAreaElement.h b/WebCore/html/HTMLTextAreaElement.h
index 5ef8e55..23f61d3 100644
--- a/WebCore/html/HTMLTextAreaElement.h
+++ b/WebCore/html/HTMLTextAreaElement.h
@@ -28,9 +28,10 @@
namespace WebCore {
+class BeforeTextInsertedEvent;
class VisibleSelection;
-class HTMLTextAreaElement : public HTMLFormControlElementWithState {
+class HTMLTextAreaElement : public HTMLTextFormControlElement {
public:
HTMLTextAreaElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
@@ -54,15 +55,6 @@ public:
virtual bool valueMissing() const { return isRequiredFormControl() && !disabled() && !readOnly() && value().isEmpty(); }
- int selectionStart();
- int selectionEnd();
-
- void setSelectionStart(int);
- void setSelectionEnd(int);
-
- void select();
- void setSelectionRange(int, int);
-
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
virtual void parseMappedAttribute(MappedAttribute*);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
@@ -77,6 +69,10 @@ public:
void setValue(const String&);
String defaultValue() const;
void setDefaultValue(const String&);
+ int textLength() const { return value().length(); }
+ int maxLength() const;
+ void setMaxLength(int, ExceptionCode&);
+ virtual bool tooLong() const;
void rendererWillBeDestroyed();
@@ -89,15 +85,21 @@ public:
void setRows(int);
void cacheSelection(int s, int e) { m_cachedSelectionStart = s; m_cachedSelectionEnd = e; };
- VisibleSelection selection() const;
virtual bool shouldUseInputMethod() const;
private:
enum WrapMethod { NoWrap, SoftWrap, HardWrap };
+ void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*) const;
+ static String sanitizeUserInputValue(const String&, unsigned maxLength);
void updateValue() const;
+ virtual bool supportsPlaceholder() const { return true; }
+ virtual bool isEmptyValue() const { return value().isEmpty(); }
+ virtual int cachedSelectionStart() const { return m_cachedSelectionStart; }
+ virtual int cachedSelectionEnd() const { return m_cachedSelectionEnd; }
+
virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); }
virtual bool isRequiredFormControl() const { return required(); }
@@ -107,6 +109,7 @@ private:
mutable String m_value;
int m_cachedSelectionStart;
int m_cachedSelectionEnd;
+ mutable bool m_isDirty;
};
} //namespace
diff --git a/WebCore/html/HTMLTextAreaElement.idl b/WebCore/html/HTMLTextAreaElement.idl
index 5d2853e..db5154e 100644
--- a/WebCore/html/HTMLTextAreaElement.idl
+++ b/WebCore/html/HTMLTextAreaElement.idl
@@ -34,16 +34,21 @@ module html {
attribute long cols;
attribute boolean disabled;
attribute boolean autofocus;
+ attribute long maxLength
+ setter raises(DOMException);
attribute [ConvertNullToNullString] DOMString name;
+ attribute [ConvertNullToNullString, Reflect] DOMString placeholder;
attribute boolean readOnly;
attribute boolean required;
attribute long rows;
readonly attribute DOMString type;
attribute [ConvertNullToNullString] DOMString value;
+ readonly attribute unsigned long textLength;
void select();
readonly attribute boolean willValidate;
+ boolean checkValidity();
void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error);
// WinIE & FireFox extension:
diff --git a/WebCore/html/HTMLTokenizer.cpp b/WebCore/html/HTMLTokenizer.cpp
index 2850aec..9215dc3 100644
--- a/WebCore/html/HTMLTokenizer.cpp
+++ b/WebCore/html/HTMLTokenizer.cpp
@@ -32,6 +32,7 @@
#include "CachedScript.h"
#include "DocLoader.h"
#include "DocumentFragment.h"
+#include "Event.h"
#include "EventNames.h"
#include "Frame.h"
#include "FrameLoader.h"
@@ -41,6 +42,7 @@
#include "HTMLParser.h"
#include "HTMLScriptElement.h"
#include "HTMLViewSourceDocument.h"
+#include "InspectorTimelineAgent.h"
#include "MappedAttribute.h"
#include "Page.h"
#include "PreloadScanner.h"
@@ -442,7 +444,8 @@ HTMLTokenizer::State HTMLTokenizer::scriptHandler(State state)
#endif
// The parser might have been stopped by for example a window.close call in an earlier script.
// If so, we don't want to load scripts.
- if (!m_parserStopped && (cs = m_doc->docLoader()->requestScript(m_scriptTagSrcAttrValue, m_scriptTagCharsetAttrValue)))
+ if (!m_parserStopped && m_scriptNode->dispatchBeforeLoadEvent(m_scriptTagSrcAttrValue) &&
+ (cs = m_doc->docLoader()->requestScript(m_scriptTagSrcAttrValue, m_scriptTagCharsetAttrValue)))
m_pendingScripts.append(cs);
else
m_scriptNode = 0;
@@ -1670,18 +1673,24 @@ void HTMLTokenizer::write(const SegmentedString& str, bool appendData)
if (!m_doc->ownerElement())
printf("Beginning write at time %d\n", m_doc->elapsedTime());
#endif
-
+
int processedCount = 0;
double startTime = currentTime();
#ifdef ANDROID_INSTRUMENT
android::TimeCounter::start(android::TimeCounter::ParsingTimeCounter);
#endif
+#if ENABLE(INSPECTOR)
+ InspectorTimelineAgent* timelineAgent = m_doc->inspectorTimelineAgent();
+ if (timelineAgent)
+ timelineAgent->willWriteHTML();
+#endif
+
Frame* frame = m_doc->frame();
State state = m_state;
- while (!m_src.isEmpty() && (!frame || !frame->loader()->isScheduledLocationChangePending())) {
+ while (!m_src.isEmpty() && (!frame || !frame->redirectScheduler()->locationChangePending())) {
if (!continueProcessing(processedCount, startTime, state))
break;
@@ -1797,7 +1806,12 @@ void HTMLTokenizer::write(const SegmentedString& str, bool appendData)
if (!m_doc->ownerElement())
printf("Ending write at time %d\n", m_doc->elapsedTime());
#endif
-
+
+#if ENABLE(INSPECTOR)
+ if (timelineAgent)
+ timelineAgent->didWriteHTML();
+#endif
+
m_inWrite = wasInWrite;
m_state = state;
@@ -2041,7 +2055,7 @@ void HTMLTokenizer::notifyFinished(CachedResource*)
#endif
if (errorOccurred)
- n->dispatchEvent(eventNames().errorEvent, true, false);
+ n->dispatchEvent(Event::create(eventNames().errorEvent, true, false));
else {
if (static_cast<HTMLScriptElement*>(n.get())->shouldExecuteAsJavaScript())
m_state = scriptExecution(sourceCode, m_state);
@@ -2049,7 +2063,7 @@ void HTMLTokenizer::notifyFinished(CachedResource*)
else
m_doc->setShouldProcessNoscriptElement(true);
#endif
- n->dispatchEvent(eventNames().loadEvent, false, false);
+ n->dispatchEvent(Event::create(eventNames().loadEvent, false, false));
}
// The state of m_pendingScripts.isEmpty() can change inside the scriptExecution()
diff --git a/WebCore/html/HTMLVideoElement.cpp b/WebCore/html/HTMLVideoElement.cpp
index ecd74e7..5bbc167 100644
--- a/WebCore/html/HTMLVideoElement.cpp
+++ b/WebCore/html/HTMLVideoElement.cpp
@@ -28,6 +28,7 @@
#if ENABLE(VIDEO)
#include "HTMLVideoElement.h"
+#include "ChromeClient.h"
#include "CSSHelper.h"
#include "CSSPropertyNames.h"
#include "Document.h"
@@ -112,6 +113,18 @@ void HTMLVideoElement::parseMappedAttribute(MappedAttribute* attr)
HTMLMediaElement::parseMappedAttribute(attr);
}
+bool HTMLVideoElement::supportsFullscreen() const
+{
+ Page* page = document() ? document()->page() : 0;
+ if (!page)
+ return false;
+
+ if (!m_player || !m_player->supportsFullscreen())
+ return false;
+
+ return page->chrome()->client()->supportsFullscreenForNode(this);
+}
+
unsigned HTMLVideoElement::videoWidth() const
{
if (!m_player)
diff --git a/WebCore/html/HTMLVideoElement.h b/WebCore/html/HTMLVideoElement.h
index dc9714a..096eb53 100644
--- a/WebCore/html/HTMLVideoElement.h
+++ b/WebCore/html/HTMLVideoElement.h
@@ -49,7 +49,7 @@ public:
virtual void parseMappedAttribute(MappedAttribute* attr);
virtual bool isVideo() const { return true; }
virtual bool hasVideo() const { return player() && player()->hasVideo(); }
- virtual bool supportsFullscreen() const { return player() && player()->supportsFullscreen(); }
+ virtual bool supportsFullscreen() const;
virtual bool isURLAttribute(Attribute*) const;
virtual const QualifiedName& imageSourceAttributeName() const;
diff --git a/WebCore/html/HTMLViewSourceDocument.cpp b/WebCore/html/HTMLViewSourceDocument.cpp
index 13404cc..ba718d1 100644
--- a/WebCore/html/HTMLViewSourceDocument.cpp
+++ b/WebCore/html/HTMLViewSourceDocument.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -47,9 +47,6 @@ using namespace HTMLNames;
HTMLViewSourceDocument::HTMLViewSourceDocument(Frame* frame, const String& mimeType)
: HTMLDocument(frame)
, m_type(mimeType)
- , m_current(0)
- , m_tbody(0)
- , m_td(0)
{
setUsesBeforeAfterRules(true);
}
@@ -70,23 +67,23 @@ Tokenizer* HTMLViewSourceDocument::createTokenizer()
void HTMLViewSourceDocument::createContainingTable()
{
- RefPtr<Element> html = new HTMLHtmlElement(htmlTag, this);
+ RefPtr<HTMLHtmlElement> html = new HTMLHtmlElement(htmlTag, this);
addChild(html);
html->attach();
- RefPtr<Element> body = new HTMLBodyElement(bodyTag, this);
+ RefPtr<HTMLBodyElement> body = new HTMLBodyElement(bodyTag, this);
html->addChild(body);
body->attach();
// Create a line gutter div that can be used to make sure the gutter extends down the height of the whole
// document.
- RefPtr<Element> div = new HTMLDivElement(divTag, this);
+ RefPtr<HTMLDivElement> div = new HTMLDivElement(divTag, this);
RefPtr<NamedMappedAttrMap> attrs = NamedMappedAttrMap::create();
attrs->addAttribute(MappedAttribute::create(classAttr, "webkit-line-gutter-backdrop"));
div->setAttributeMap(attrs.release());
body->addChild(div);
div->attach();
- RefPtr<Element> table = new HTMLTableElement(tableTag, this);
+ RefPtr<HTMLTableElement> table = new HTMLTableElement(tableTag, this);
body->addChild(table);
table->attach();
m_tbody = new HTMLTableSectionElement(tbodyTag, this);
@@ -205,31 +202,31 @@ void HTMLViewSourceDocument::addViewSourceDoctypeToken(DoctypeToken* doctypeToke
addText(text, "webkit-html-doctype");
}
-Element* HTMLViewSourceDocument::addSpanWithClassName(const String& className)
+PassRefPtr<Element> HTMLViewSourceDocument::addSpanWithClassName(const String& className)
{
if (m_current == m_tbody) {
addLine(className);
return m_current;
}
- Element* span = new HTMLElement(spanTag, this);
+ RefPtr<HTMLElement> span = HTMLElement::create(spanTag, this);
RefPtr<NamedMappedAttrMap> attrs = NamedMappedAttrMap::create();
attrs->addAttribute(MappedAttribute::create(classAttr, className));
span->setAttributeMap(attrs.release());
m_current->addChild(span);
span->attach();
- return span;
+ return span.release();
}
void HTMLViewSourceDocument::addLine(const String& className)
{
// Create a table row.
- RefPtr<Element> trow = new HTMLTableRowElement(trTag, this);
+ RefPtr<HTMLTableRowElement> trow = new HTMLTableRowElement(trTag, this);
m_tbody->addChild(trow);
trow->attach();
// Create a cell that will hold the line number (it is generated in the stylesheet using counters).
- Element* td = new HTMLTableCellElement(tdTag, this);
+ RefPtr<HTMLTableCellElement> td = new HTMLTableCellElement(tdTag, this);
RefPtr<NamedMappedAttrMap> attrs = NamedMappedAttrMap::create();
attrs->addAttribute(MappedAttribute::create(classAttr, "webkit-line-number"));
td->setAttributeMap(attrs.release());
@@ -246,7 +243,7 @@ void HTMLViewSourceDocument::addLine(const String& className)
m_current = m_td = td;
#ifdef DEBUG_LINE_NUMBERS
- RefPtr<Text> lineNumberText = new Text(this, String::number(tokenizer()->lineNumber() + 1) + " ");
+ RefPtr<Text> lineNumberText = Text::create(this, String::number(tokenizer()->lineNumber() + 1) + " ");
td->addChild(lineNumberText);
lineNumberText->attach();
#endif
@@ -277,7 +274,7 @@ void HTMLViewSourceDocument::addText(const String& text, const String& className
}
if (m_current == m_tbody)
addLine(className);
- RefPtr<Text> t = new Text(this, substring);
+ RefPtr<Text> t = Text::create(this, substring);
m_current->addChild(t);
t->attach();
if (i < size - 1)
@@ -289,13 +286,13 @@ void HTMLViewSourceDocument::addText(const String& text, const String& className
m_current = m_tbody;
}
-Element* HTMLViewSourceDocument::addLink(const String& url, bool isAnchor)
+PassRefPtr<Element> HTMLViewSourceDocument::addLink(const String& url, bool isAnchor)
{
if (m_current == m_tbody)
addLine("webkit-html-tag");
// Now create a link for the attribute value instead of a span.
- Element* anchor = new HTMLAnchorElement(aTag, this);
+ RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(this);
RefPtr<NamedMappedAttrMap> attrs = NamedMappedAttrMap::create();
const char* classValue;
if (isAnchor)
@@ -308,7 +305,7 @@ Element* HTMLViewSourceDocument::addLink(const String& url, bool isAnchor)
anchor->setAttributeMap(attrs.release());
m_current->addChild(anchor);
anchor->attach();
- return anchor;
+ return anchor.release();
}
}
diff --git a/WebCore/html/HTMLViewSourceDocument.h b/WebCore/html/HTMLViewSourceDocument.h
index 57a8f21..e4eadb0 100644
--- a/WebCore/html/HTMLViewSourceDocument.h
+++ b/WebCore/html/HTMLViewSourceDocument.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,18 +30,18 @@
namespace WebCore {
class DoctypeToken;
+class HTMLTableCellElement;
+class HTMLTableSectionElement;
+
struct Token;
class HTMLViewSourceDocument : public HTMLDocument {
public:
static PassRefPtr<HTMLViewSourceDocument> create(Frame* frame, const String& mimeType)
{
- return new HTMLViewSourceDocument(frame, mimeType);
+ return adoptRef(new HTMLViewSourceDocument(frame, mimeType));
}
- // Returns HTMLTokenizer or TextTokenizer based on m_type.
- virtual Tokenizer* createTokenizer();
-
void addViewSourceToken(Token*); // Used by the HTML tokenizer.
void addViewSourceText(const String&); // Used by the plaintext tokenizer.
void addViewSourceDoctypeToken(DoctypeToken*);
@@ -49,16 +49,19 @@ public:
private:
HTMLViewSourceDocument(Frame*, const String& mimeType);
+ // Returns HTMLTokenizer or TextTokenizer based on m_type.
+ virtual Tokenizer* createTokenizer();
+
void createContainingTable();
- Element* addSpanWithClassName(const String&);
+ PassRefPtr<Element> addSpanWithClassName(const String&);
void addLine(const String& className);
void addText(const String& text, const String& className);
- Element* addLink(const String& url, bool isAnchor);
+ PassRefPtr<Element> addLink(const String& url, bool isAnchor);
String m_type;
- Element* m_current;
- Element* m_tbody;
- Element* m_td;
+ RefPtr<Element> m_current;
+ RefPtr<HTMLTableSectionElement> m_tbody;
+ RefPtr<HTMLTableCellElement> m_td;
};
}
diff --git a/WebCore/html/ValidityState.cpp b/WebCore/html/ValidityState.cpp
index 86227d4..5bf8382 100644
--- a/WebCore/html/ValidityState.cpp
+++ b/WebCore/html/ValidityState.cpp
@@ -23,14 +23,57 @@
#include "config.h"
#include "ValidityState.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "KURL.h"
+
namespace WebCore {
+using namespace HTMLNames;
+
ValidityState::ValidityState(HTMLFormControlElement* parent)
: m_control(parent)
{
ASSERT(parent);
}
+bool ValidityState::typeMismatch()
+{
+ if (!control()->hasTagName(inputTag))
+ return false;
+
+ HTMLInputElement* input = static_cast<HTMLInputElement*>(control());
+ String value = input->value();
+
+ if (value.isEmpty())
+ return false;
+
+ switch (input->inputType()) {
+ case HTMLInputElement::COLOR:
+ return !isValidColorString(value);
+ case HTMLInputElement::NUMBER:
+ return !HTMLInputElement::formStringToDouble(value, 0);
+ case HTMLInputElement::URL:
+ return !KURL(KURL(), value).isValid();
+ default:
+ return false;
+ }
+}
+
+bool ValidityState::rangeUnderflow()
+{
+ if (!control()->hasTagName(inputTag))
+ return false;
+ return static_cast<HTMLInputElement*>(control())->rangeUnderflow();
+}
+
+bool ValidityState::rangeOverflow()
+{
+ if (!control()->hasTagName(inputTag))
+ return false;
+ return static_cast<HTMLInputElement*>(control())->rangeOverflow();
+}
+
bool ValidityState::valid()
{
bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow() ||
@@ -39,4 +82,17 @@ bool ValidityState::valid()
return !someError;
}
+bool ValidityState::isValidColorString(const String& value)
+{
+ if (value.isEmpty())
+ return false;
+ if (value[0] == '#') {
+ // We don't accept #rgb and #aarrggbb formats.
+ if (value.length() != 7)
+ return false;
+ }
+ Color color(value); // This accepts named colors such as "white".
+ return color.isValid() && !color.hasAlpha();
+}
+
} // namespace
diff --git a/WebCore/html/ValidityState.h b/WebCore/html/ValidityState.h
index 794822a..67afa53 100644
--- a/WebCore/html/ValidityState.h
+++ b/WebCore/html/ValidityState.h
@@ -41,11 +41,11 @@ namespace WebCore {
void setCustomErrorMessage(const String& message) { m_customErrorMessage = message; }
bool valueMissing() { return control()->valueMissing(); }
- bool typeMismatch() { return false; }
+ bool typeMismatch();
bool patternMismatch() { return control()->patternMismatch(); }
- bool tooLong() { return false; }
- bool rangeUnderflow() { return false; }
- bool rangeOverflow() { return false; }
+ bool tooLong() { return control()->tooLong(); }
+ bool rangeUnderflow();
+ bool rangeOverflow();
bool stepMismatch() { return false; }
bool customError() { return !m_customErrorMessage.isEmpty(); }
bool valid();
@@ -54,6 +54,8 @@ namespace WebCore {
ValidityState(HTMLFormControlElement*);
HTMLFormControlElement* m_control;
String m_customErrorMessage;
+
+ static bool isValidColorString(const String&);
};
} // namespace WebCore
diff --git a/WebCore/html/canvas/CanvasArray.cpp b/WebCore/html/canvas/CanvasArray.cpp
new file mode 100644
index 0000000..6b5688a
--- /dev/null
+++ b/WebCore/html/canvas/CanvasArray.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArray.h"
+#include "CanvasArrayBuffer.h"
+
+namespace WebCore {
+ CanvasArray::CanvasArray(PassRefPtr<CanvasArrayBuffer> buffer,
+ unsigned offset)
+ : m_offset(offset)
+ , m_buffer(buffer)
+ {
+ m_baseAddress = m_buffer ? (static_cast<char*>(m_buffer->data()) + m_offset) : 0;
+ }
+
+ CanvasArray::~CanvasArray()
+ {
+ }
+
+ unsigned CanvasArray::alignedSizeInBytes() const {
+ // Assume we only need to round up to 4-byte boundaries for alignment.
+ return ((sizeInBytes() + 3) / 4) * 4;
+ }
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasArray.h b/WebCore/html/canvas/CanvasArray.h
new file mode 100644
index 0000000..e34ad8c
--- /dev/null
+++ b/WebCore/html/canvas/CanvasArray.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasArray_h
+#define CanvasArray_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include "CanvasArrayBuffer.h"
+
+namespace WebCore {
+ class CanvasArray : public RefCounted<CanvasArray> {
+ public:
+ PassRefPtr<CanvasArrayBuffer> buffer() {
+ return m_buffer;
+ }
+
+ void* baseAddress() {
+ return m_baseAddress;
+ }
+
+ unsigned offset() const {
+ return m_offset;
+ }
+
+ virtual unsigned length() const = 0;
+ virtual unsigned sizeInBytes() const = 0;
+ virtual unsigned alignedSizeInBytes() const;
+ virtual ~CanvasArray();
+
+ protected:
+ CanvasArray(PassRefPtr<CanvasArrayBuffer> buffer, unsigned offset);
+
+ // This is the address of the CanvasArrayBuffer's storage, plus the offset.
+ void* m_baseAddress;
+ unsigned m_offset;
+
+ private:
+ RefPtr<CanvasArrayBuffer> m_buffer;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasArray_h
diff --git a/WebCore/html/canvas/CanvasArray.idl b/WebCore/html/canvas/CanvasArray.idl
new file mode 100644
index 0000000..01bb37e
--- /dev/null
+++ b/WebCore/html/canvas/CanvasArray.idl
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [Conditional=3D_CANVAS] CanvasArray {
+ readonly attribute long length;
+ int sizeInBytes();
+ int alignedSizeInBytes();
+ };
+}
diff --git a/WebCore/html/canvas/CanvasArrayBuffer.cpp b/WebCore/html/canvas/CanvasArrayBuffer.cpp
new file mode 100644
index 0000000..c8a1397
--- /dev/null
+++ b/WebCore/html/canvas/CanvasArrayBuffer.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+
+namespace WebCore {
+
+ PassRefPtr<CanvasArrayBuffer> CanvasArrayBuffer::create(unsigned sizeInBytes)
+ {
+ return adoptRef(new CanvasArrayBuffer(sizeInBytes));
+ }
+
+ CanvasArrayBuffer::CanvasArrayBuffer(unsigned sizeInBytes) {
+ m_sizeInBytes = sizeInBytes;
+ m_data = WTF::fastZeroedMalloc(sizeInBytes);
+ }
+
+ void* CanvasArrayBuffer::data() {
+ return m_data;
+ }
+
+ unsigned CanvasArrayBuffer::byteLength() const {
+ return m_sizeInBytes;
+ }
+
+ CanvasArrayBuffer::~CanvasArrayBuffer() {
+ WTF::fastFree(m_data);
+ }
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasArrayBuffer.h b/WebCore/html/canvas/CanvasArrayBuffer.h
new file mode 100644
index 0000000..e3ff2b0
--- /dev/null
+++ b/WebCore/html/canvas/CanvasArrayBuffer.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasArrayBuffer_h
+#define CanvasArrayBuffer_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasArrayBuffer : public RefCounted<CanvasArrayBuffer> {
+ public:
+ static PassRefPtr<CanvasArrayBuffer> create(unsigned sizeInBytes);
+
+ void* data();
+ unsigned byteLength() const;
+
+ ~CanvasArrayBuffer();
+
+ private:
+ CanvasArrayBuffer(unsigned sizeInBytes);
+ unsigned m_sizeInBytes;
+ void* m_data;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasArrayBuffer_h
diff --git a/WebCore/html/canvas/CanvasArrayBuffer.idl b/WebCore/html/canvas/CanvasArrayBuffer.idl
new file mode 100644
index 0000000..5dc0f7f
--- /dev/null
+++ b/WebCore/html/canvas/CanvasArrayBuffer.idl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [Conditional=3D_CANVAS] CanvasArrayBuffer {
+ readonly attribute int byteLength;
+ };
+}
diff --git a/WebCore/html/canvas/CanvasBuffer.cpp b/WebCore/html/canvas/CanvasBuffer.cpp
new file mode 100644
index 0000000..009f8ad
--- /dev/null
+++ b/WebCore/html/canvas/CanvasBuffer.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasBuffer.h"
+#include "CanvasRenderingContext3D.h"
+
+namespace WebCore {
+
+PassRefPtr<CanvasBuffer> CanvasBuffer::create(CanvasRenderingContext3D* ctx)
+{
+ return adoptRef(new CanvasBuffer(ctx));
+}
+
+CanvasBuffer::CanvasBuffer(CanvasRenderingContext3D* ctx)
+ : CanvasObject(ctx)
+{
+ setObject(context()->graphicsContext3D()->createBuffer());
+}
+
+void CanvasBuffer::_deleteObject(Platform3DObject object)
+{
+ context()->graphicsContext3D()->deleteBuffer(object);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasBuffer.h b/WebCore/html/canvas/CanvasBuffer.h
new file mode 100644
index 0000000..8fdab82
--- /dev/null
+++ b/WebCore/html/canvas/CanvasBuffer.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasBuffer_h
+#define CanvasBuffer_h
+
+#include "CanvasObject.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasBuffer : public CanvasObject {
+ public:
+ virtual ~CanvasBuffer() { deleteObject(); }
+
+ static PassRefPtr<CanvasBuffer> create(CanvasRenderingContext3D*);
+
+ protected:
+ CanvasBuffer(CanvasRenderingContext3D*);
+
+ virtual void _deleteObject(Platform3DObject o);
+ };
+
+} // namespace WebCore
+
+#endif // CanvasBuffer_h
diff --git a/WebCore/html/canvas/CanvasBuffer.idl b/WebCore/html/canvas/CanvasBuffer.idl
new file mode 100644
index 0000000..9bca42b
--- /dev/null
+++ b/WebCore/html/canvas/CanvasBuffer.idl
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [Conditional=3D_CANVAS] CanvasBuffer {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasByteArray.cpp b/WebCore/html/canvas/CanvasByteArray.cpp
new file mode 100644
index 0000000..0f72ccf
--- /dev/null
+++ b/WebCore/html/canvas/CanvasByteArray.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasByteArray.h"
+
+namespace WebCore {
+
+PassRefPtr<CanvasByteArray> CanvasByteArray::create(unsigned length)
+{
+ RefPtr<CanvasArrayBuffer> buffer = CanvasArrayBuffer::create(length * sizeof(signed char));
+ return create(buffer, 0, length);
+}
+
+PassRefPtr<CanvasByteArray> CanvasByteArray::create(signed char* array, unsigned length)
+{
+ RefPtr<CanvasByteArray> a = CanvasByteArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+}
+
+PassRefPtr<CanvasByteArray> CanvasByteArray::create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length)
+{
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given CanvasArrayBuffer's storage.
+ if ((offset + (length * sizeof(signed char))) > buffer->byteLength())
+ return NULL;
+ }
+
+ return adoptRef(new CanvasByteArray(buffer, offset, length));
+}
+
+CanvasByteArray::CanvasByteArray(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length)
+ : CanvasArray(buffer, offset)
+ , m_size(length)
+{
+}
+
+unsigned CanvasByteArray::length() const {
+ return m_size;
+}
+
+unsigned CanvasByteArray::sizeInBytes() const {
+ return length() * sizeof(signed char);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasByteArray.h b/WebCore/html/canvas/CanvasByteArray.h
new file mode 100644
index 0000000..329f396
--- /dev/null
+++ b/WebCore/html/canvas/CanvasByteArray.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasByteArray_h
+#define CanvasByteArray_h
+
+#include "CanvasArray.h"
+#include <limits>
+#include <wtf/MathExtras.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasArrayBuffer;
+
+ class CanvasByteArray : public CanvasArray {
+ public:
+ static PassRefPtr<CanvasByteArray> create(unsigned length);
+ static PassRefPtr<CanvasByteArray> create(signed char* array, unsigned length);
+ static PassRefPtr<CanvasByteArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length);
+
+ char* data() { return static_cast<char*>(baseAddress()); }
+
+ virtual unsigned length() const;
+ virtual unsigned sizeInBytes() const;
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<signed char>::min())
+ value = std::numeric_limits<signed char>::min();
+ else if (value > std::numeric_limits<signed char>::max())
+ value = std::numeric_limits<signed char>::max();
+ signed char* storage = static_cast<signed char*>(m_baseAddress);
+ storage[index] = static_cast<signed char>(value);
+ }
+
+ bool get(unsigned index, signed char& result) const
+ {
+ if (index >= m_size)
+ return false;
+ signed char* storage = static_cast<signed char*>(m_baseAddress);
+ result = storage[index];
+ return true;
+ }
+
+ signed char item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ signed char* storage = static_cast<signed char*>(m_baseAddress);
+ return storage[index];
+ }
+ private:
+ CanvasByteArray(PassRefPtr<CanvasArrayBuffer> buffer,
+ int offset,
+ unsigned length);
+ unsigned m_size;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasByteArray_h
diff --git a/WebCore/html/canvas/CanvasByteArray.idl b/WebCore/html/canvas/CanvasByteArray.idl
new file mode 100644
index 0000000..ccf49ad
--- /dev/null
+++ b/WebCore/html/canvas/CanvasByteArray.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ Conditional=3D_CANVAS,
+ HasNumericIndexGetter,
+ HasCustomIndexSetter,
+ GenerateNativeConverter,
+ GenerateCustomConstructor,
+ CustomToJS
+ ] CanvasByteArray : CanvasArray {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasFloatArray.cpp b/WebCore/html/canvas/CanvasFloatArray.cpp
new file mode 100644
index 0000000..09561cb
--- /dev/null
+++ b/WebCore/html/canvas/CanvasFloatArray.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasFloatArray.h"
+
+namespace WebCore {
+
+ PassRefPtr<CanvasFloatArray> CanvasFloatArray::create(unsigned length)
+ {
+ RefPtr<CanvasArrayBuffer> buffer = CanvasArrayBuffer::create(length * sizeof(float));
+ return create(buffer, 0, length);
+ }
+
+ PassRefPtr<CanvasFloatArray> CanvasFloatArray::create(float* array, unsigned length)
+ {
+ RefPtr<CanvasFloatArray> a = CanvasFloatArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+ }
+
+ PassRefPtr<CanvasFloatArray> CanvasFloatArray::create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length)
+ {
+ // Make sure the offset results in valid alignment.
+ if ((offset % sizeof(float)) != 0)
+ return NULL;
+
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given CanvasArrayBuffer's storage.
+ if ((offset + (length * sizeof(float))) > buffer->byteLength())
+ return NULL;
+ }
+ return adoptRef(new CanvasFloatArray(buffer, offset, length));
+ }
+
+ CanvasFloatArray::CanvasFloatArray(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length)
+ : CanvasArray(buffer, offset)
+ , m_size(length)
+ {
+ }
+
+ unsigned CanvasFloatArray::length() const {
+ return m_size;
+ }
+
+ unsigned CanvasFloatArray::sizeInBytes() const {
+ return length() * sizeof(float);
+ }
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasFloatArray.h b/WebCore/html/canvas/CanvasFloatArray.h
new file mode 100644
index 0000000..49bd897
--- /dev/null
+++ b/WebCore/html/canvas/CanvasFloatArray.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasFloatArray_h
+#define CanvasFloatArray_h
+
+#include "CanvasArray.h"
+#include <wtf/MathExtras.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasFloatArray : public CanvasArray {
+ public:
+ static PassRefPtr<CanvasFloatArray> create(unsigned length);
+ static PassRefPtr<CanvasFloatArray> create(float* array, unsigned length);
+ static PassRefPtr<CanvasFloatArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length);
+
+ float* data() { return static_cast<float*>(baseAddress()); }
+
+ virtual unsigned length() const;
+
+ virtual unsigned sizeInBytes() const;
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ float* storage = static_cast<float*>(m_baseAddress);
+ storage[index] = static_cast<float>(value);
+ }
+
+ bool get(unsigned index, float& result) const
+ {
+ if (index >= m_size)
+ return false;
+ result = item(index);
+ return true;
+ }
+
+ float item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ float* storage = static_cast<float*>(m_baseAddress);
+ float result = storage[index];
+ if (isnan(result)) {
+ // Clamp NaN to 0
+ result = 0;
+ }
+ return result;
+ }
+ private:
+ CanvasFloatArray(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length);
+ unsigned m_size;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasFloatArray_h
diff --git a/WebCore/html/canvas/CanvasFloatArray.idl b/WebCore/html/canvas/CanvasFloatArray.idl
new file mode 100644
index 0000000..bb236b9
--- /dev/null
+++ b/WebCore/html/canvas/CanvasFloatArray.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ Conditional=3D_CANVAS,
+ HasNumericIndexGetter,
+ HasCustomIndexSetter,
+ GenerateNativeConverter,
+ GenerateCustomConstructor,
+ CustomToJS
+ ] CanvasFloatArray : CanvasArray {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasFramebuffer.cpp b/WebCore/html/canvas/CanvasFramebuffer.cpp
new file mode 100644
index 0000000..9700354
--- /dev/null
+++ b/WebCore/html/canvas/CanvasFramebuffer.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasFramebuffer.h"
+#include "CanvasRenderingContext3D.h"
+
+namespace WebCore {
+
+PassRefPtr<CanvasFramebuffer> CanvasFramebuffer::create(CanvasRenderingContext3D* ctx)
+{
+ return adoptRef(new CanvasFramebuffer(ctx));
+}
+
+CanvasFramebuffer::CanvasFramebuffer(CanvasRenderingContext3D* ctx)
+ : CanvasObject(ctx)
+{
+ setObject(context()->graphicsContext3D()->createFramebuffer());
+}
+
+void CanvasFramebuffer::_deleteObject(Platform3DObject object)
+{
+ context()->graphicsContext3D()->deleteFramebuffer(object);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasFramebuffer.h b/WebCore/html/canvas/CanvasFramebuffer.h
new file mode 100644
index 0000000..ec3cb97
--- /dev/null
+++ b/WebCore/html/canvas/CanvasFramebuffer.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasFramebuffer_h
+#define CanvasFramebuffer_h
+
+#include "CanvasObject.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasFramebuffer : public CanvasObject {
+ public:
+ virtual ~CanvasFramebuffer() { deleteObject(); }
+
+ static PassRefPtr<CanvasFramebuffer> create(CanvasRenderingContext3D*);
+
+ protected:
+ CanvasFramebuffer(CanvasRenderingContext3D*);
+
+ virtual void _deleteObject(Platform3DObject);
+ };
+
+} // namespace WebCore
+
+#endif // CanvasFramebuffer_h
diff --git a/WebCore/html/canvas/CanvasFramebuffer.idl b/WebCore/html/canvas/CanvasFramebuffer.idl
new file mode 100644
index 0000000..0a9b668
--- /dev/null
+++ b/WebCore/html/canvas/CanvasFramebuffer.idl
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [Conditional=3D_CANVAS] CanvasFramebuffer {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasIntArray.cpp b/WebCore/html/canvas/CanvasIntArray.cpp
new file mode 100644
index 0000000..4716d7b
--- /dev/null
+++ b/WebCore/html/canvas/CanvasIntArray.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasIntArray.h"
+
+namespace WebCore {
+
+ PassRefPtr<CanvasIntArray> CanvasIntArray::create(unsigned length)
+ {
+ RefPtr<CanvasArrayBuffer> buffer = CanvasArrayBuffer::create(length * sizeof(int));
+ return create(buffer, 0, length);
+ }
+
+ PassRefPtr<CanvasIntArray> CanvasIntArray::create(int* array, unsigned length)
+ {
+ RefPtr<CanvasIntArray> a = CanvasIntArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+ }
+
+ PassRefPtr<CanvasIntArray> CanvasIntArray::create(PassRefPtr<CanvasArrayBuffer> buffer,
+ int offset,
+ unsigned length)
+ {
+ // Make sure the offset results in valid alignment.
+ if ((offset % sizeof(int)) != 0)
+ return NULL;
+
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given CanvasArrayBuffer's storage.
+ if ((offset + (length * sizeof(int))) > buffer->byteLength())
+ return NULL;
+ }
+
+ return adoptRef(new CanvasIntArray(buffer, offset, length));
+ }
+
+ CanvasIntArray::CanvasIntArray(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length)
+ : CanvasArray(buffer, offset)
+ , m_size(length)
+ {
+ }
+
+ unsigned CanvasIntArray::length() const {
+ return m_size;
+ }
+
+ unsigned CanvasIntArray::sizeInBytes() const {
+ return length() * sizeof(int);
+ }
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasIntArray.h b/WebCore/html/canvas/CanvasIntArray.h
new file mode 100644
index 0000000..8846be7
--- /dev/null
+++ b/WebCore/html/canvas/CanvasIntArray.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasIntArray_h
+#define CanvasIntArray_h
+
+#include "CanvasArray.h"
+#include <limits>
+#include <wtf/MathExtras.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasIntArray : public CanvasArray {
+ public:
+ static PassRefPtr<CanvasIntArray> create(unsigned length);
+ static PassRefPtr<CanvasIntArray> create(int* array, unsigned length);
+ static PassRefPtr<CanvasIntArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length);
+
+ int* data() { return static_cast<int*>(baseAddress()); }
+
+ virtual unsigned length() const;
+ virtual unsigned sizeInBytes() const;
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<int>::min())
+ value = std::numeric_limits<int>::min();
+ else if (value > std::numeric_limits<int>::max())
+ value = std::numeric_limits<int>::max();
+ int* storage = static_cast<int*>(m_baseAddress);
+ storage[index] = static_cast<int>(value);
+ }
+
+ bool get(unsigned index, int& result) const
+ {
+ if (index >= m_size)
+ return false;
+ result = item(index);
+ return true;
+ }
+
+ int item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ int* storage = static_cast<int*>(m_baseAddress);
+ return storage[index];
+ }
+
+ private:
+ CanvasIntArray(PassRefPtr<CanvasArrayBuffer> buffer,
+ int offset,
+ unsigned length);
+ unsigned m_size;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasIntArray_h
diff --git a/WebCore/html/canvas/CanvasIntArray.idl b/WebCore/html/canvas/CanvasIntArray.idl
new file mode 100644
index 0000000..2c81b87
--- /dev/null
+++ b/WebCore/html/canvas/CanvasIntArray.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ Conditional=3D_CANVAS,
+ HasNumericIndexGetter,
+ HasCustomIndexSetter,
+ GenerateNativeConverter,
+ GenerateCustomConstructor,
+ CustomToJS
+ ] CanvasIntArray : CanvasArray {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasNumberArray.cpp b/WebCore/html/canvas/CanvasNumberArray.cpp
new file mode 100644
index 0000000..6cbdfff
--- /dev/null
+++ b/WebCore/html/canvas/CanvasNumberArray.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasNumberArray.h"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+PassRefPtr<CanvasNumberArray> CanvasNumberArray::create(unsigned length)
+{
+ return adoptRef(new CanvasNumberArray(length));
+}
+
+CanvasNumberArray::CanvasNumberArray(unsigned length)
+ : m_data(length)
+{
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasNumberArray.h b/WebCore/html/canvas/CanvasNumberArray.h
new file mode 100644
index 0000000..eb79866
--- /dev/null
+++ b/WebCore/html/canvas/CanvasNumberArray.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasNumberArray_h
+#define CanvasNumberArray_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+#include <limits>
+
+namespace WebCore {
+
+ class String;
+
+ class CanvasNumberArray : public RefCounted<CanvasNumberArray> {
+ public:
+ static PassRefPtr<CanvasNumberArray> create(unsigned length);
+
+ Vector<float>& data() { return m_data; }
+ const Vector<float>& data() const { return m_data; }
+
+ unsigned length() const { return m_data.size(); }
+ float item(unsigned index) const { return (index >= m_data.size()) ? 0 : m_data[index]; }
+
+ private:
+ CanvasNumberArray(unsigned length);
+ Vector<float> m_data;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasNumberArray_h
diff --git a/WebCore/html/canvas/CanvasNumberArray.idl b/WebCore/html/canvas/CanvasNumberArray.idl
new file mode 100644
index 0000000..56e807e
--- /dev/null
+++ b/WebCore/html/canvas/CanvasNumberArray.idl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ Conditional=3D_CANVAS,
+ GenerateConstructor,
+ HasCustomIndexGetter
+ ] CanvasNumberArray {
+ readonly attribute unsigned long length;
+ };
+}
diff --git a/WebCore/html/canvas/CanvasObject.cpp b/WebCore/html/canvas/CanvasObject.cpp
new file mode 100644
index 0000000..8a71a45
--- /dev/null
+++ b/WebCore/html/canvas/CanvasObject.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasObject.h"
+#include "CanvasRenderingContext3D.h"
+
+namespace WebCore {
+
+CanvasObject::CanvasObject(CanvasRenderingContext3D* context)
+ : m_object(0)
+ , m_context(context)
+{
+}
+
+CanvasObject::~CanvasObject()
+{
+ if (m_context)
+ m_context->removeObject(this);
+}
+
+void CanvasObject::setObject(Platform3DObject object)
+{
+ if (object == m_object)
+ return;
+
+ deleteObject();
+ m_object = object;
+}
+
+void CanvasObject::deleteObject()
+{
+ if (m_object) {
+ if (m_context) {
+ m_context->graphicsContext3D()->makeContextCurrent();
+ _deleteObject(m_object);
+ }
+ m_object = 0;
+ }
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasObject.h b/WebCore/html/canvas/CanvasObject.h
new file mode 100644
index 0000000..413da71
--- /dev/null
+++ b/WebCore/html/canvas/CanvasObject.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasObject_h
+#define CanvasObject_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+#include "GraphicsContext3D.h"
+
+namespace WebCore {
+
+ class CanvasRenderingContext3D;
+
+ class CanvasObject : public RefCounted<CanvasObject> {
+ public:
+ virtual ~CanvasObject();
+
+ Platform3DObject object() const { return m_object; }
+ void setObject(Platform3DObject);
+ void deleteObject();
+
+ void detachContext()
+ {
+ deleteObject();
+ m_context = 0;
+ }
+
+ protected:
+ CanvasObject(CanvasRenderingContext3D*);
+ virtual void _deleteObject(Platform3DObject) = 0;
+
+ CanvasRenderingContext3D* context() const { return m_context; }
+
+ private:
+ Platform3DObject m_object;
+ CanvasRenderingContext3D* m_context;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasObject_h
diff --git a/WebCore/html/canvas/CanvasPixelArray.h b/WebCore/html/canvas/CanvasPixelArray.h
index b91a642..8ac5163 100644
--- a/WebCore/html/canvas/CanvasPixelArray.h
+++ b/WebCore/html/canvas/CanvasPixelArray.h
@@ -48,12 +48,22 @@ namespace WebCore {
{
m_data->set(index, value);
}
+
+ void set(unsigned index, unsigned char value)
+ {
+ m_data->set(index, value);
+ }
bool get(unsigned index, unsigned char& result) const
{
return m_data->get(index, result);
}
+ unsigned char get(unsigned index) const
+ {
+ return m_data->get(index);
+ }
+
private:
CanvasPixelArray(unsigned length);
RefPtr<WTF::ByteArray> m_data;
diff --git a/WebCore/html/canvas/CanvasPixelArray.idl b/WebCore/html/canvas/CanvasPixelArray.idl
index c815788..2295af6 100644
--- a/WebCore/html/canvas/CanvasPixelArray.idl
+++ b/WebCore/html/canvas/CanvasPixelArray.idl
@@ -30,7 +30,7 @@ module html {
#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT || defined(V8_BINDING) && V8_BINDING
interface [
CustomHeader,
- HasCustomIndexGetter,
+ HasNumericIndexGetter,
HasCustomIndexSetter
] CanvasPixelArray {
readonly attribute long length;
diff --git a/WebCore/html/canvas/CanvasProgram.cpp b/WebCore/html/canvas/CanvasProgram.cpp
new file mode 100644
index 0000000..83da270
--- /dev/null
+++ b/WebCore/html/canvas/CanvasProgram.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasProgram.h"
+#include "CanvasRenderingContext3D.h"
+
+namespace WebCore {
+
+PassRefPtr<CanvasProgram> CanvasProgram::create(CanvasRenderingContext3D* ctx)
+{
+ return adoptRef(new CanvasProgram(ctx));
+}
+
+CanvasProgram::CanvasProgram(CanvasRenderingContext3D* ctx)
+ : CanvasObject(ctx)
+{
+ setObject(context()->graphicsContext3D()->createProgram());
+}
+
+void CanvasProgram::_deleteObject(Platform3DObject object)
+{
+ context()->graphicsContext3D()->deleteProgram(object);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasProgram.h b/WebCore/html/canvas/CanvasProgram.h
new file mode 100644
index 0000000..af817c8
--- /dev/null
+++ b/WebCore/html/canvas/CanvasProgram.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasProgram_h
+#define CanvasProgram_h
+
+#include "CanvasObject.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasProgram : public CanvasObject {
+ public:
+ virtual ~CanvasProgram() { deleteObject(); }
+
+ static PassRefPtr<CanvasProgram> create(CanvasRenderingContext3D*);
+
+ protected:
+ CanvasProgram(CanvasRenderingContext3D*);
+
+ virtual void _deleteObject(Platform3DObject);
+ };
+
+} // namespace WebCore
+
+#endif // CanvasProgram_h
diff --git a/WebCore/html/canvas/CanvasProgram.idl b/WebCore/html/canvas/CanvasProgram.idl
new file mode 100644
index 0000000..46daaf2
--- /dev/null
+++ b/WebCore/html/canvas/CanvasProgram.idl
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [Conditional=3D_CANVAS] CanvasProgram {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasRenderbuffer.cpp b/WebCore/html/canvas/CanvasRenderbuffer.cpp
new file mode 100644
index 0000000..51054cd
--- /dev/null
+++ b/WebCore/html/canvas/CanvasRenderbuffer.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasRenderbuffer.h"
+#include "CanvasRenderingContext3D.h"
+
+namespace WebCore {
+
+PassRefPtr<CanvasRenderbuffer> CanvasRenderbuffer::create(CanvasRenderingContext3D* ctx)
+{
+ return adoptRef(new CanvasRenderbuffer(ctx));
+}
+
+CanvasRenderbuffer::CanvasRenderbuffer(CanvasRenderingContext3D* ctx)
+ : CanvasObject(ctx)
+{
+ setObject(context()->graphicsContext3D()->createRenderbuffer());
+}
+
+void CanvasRenderbuffer::_deleteObject(Platform3DObject object)
+{
+ context()->graphicsContext3D()->deleteRenderbuffer(object);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasRenderbuffer.h b/WebCore/html/canvas/CanvasRenderbuffer.h
new file mode 100644
index 0000000..3fb99e9
--- /dev/null
+++ b/WebCore/html/canvas/CanvasRenderbuffer.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasRenderbuffer_h
+#define CanvasRenderbuffer_h
+
+#include "CanvasObject.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasRenderbuffer : public CanvasObject {
+ public:
+ virtual ~CanvasRenderbuffer() { deleteObject(); }
+
+ static PassRefPtr<CanvasRenderbuffer> create(CanvasRenderingContext3D*);
+
+ protected:
+ CanvasRenderbuffer(CanvasRenderingContext3D*);
+
+ virtual void _deleteObject(Platform3DObject);
+ };
+
+} // namespace WebCore
+
+#endif // CanvasRenderbuffer_h
diff --git a/WebCore/html/canvas/CanvasRenderbuffer.idl b/WebCore/html/canvas/CanvasRenderbuffer.idl
new file mode 100644
index 0000000..5e47cc3
--- /dev/null
+++ b/WebCore/html/canvas/CanvasRenderbuffer.idl
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [Conditional=3D_CANVAS] CanvasRenderbuffer {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasRenderingContext.cpp b/WebCore/html/canvas/CanvasRenderingContext.cpp
new file mode 100644
index 0000000..fed8cb2
--- /dev/null
+++ b/WebCore/html/canvas/CanvasRenderingContext.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CanvasRenderingContext.h"
+
+#include "HTMLCanvasElement.h"
+
+namespace WebCore {
+
+CanvasRenderingContext::CanvasRenderingContext(HTMLCanvasElement* canvas)
+ : m_canvas(canvas)
+{
+}
+
+void CanvasRenderingContext::ref()
+{
+ m_canvas->ref();
+}
+
+void CanvasRenderingContext::deref()
+{
+ m_canvas->deref();
+}
+
+} // namespace WebCore
diff --git a/WebCore/html/canvas/CanvasRenderingContext.h b/WebCore/html/canvas/CanvasRenderingContext.h
new file mode 100644
index 0000000..9ac9e57
--- /dev/null
+++ b/WebCore/html/canvas/CanvasRenderingContext.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasRenderingContext_h
+#define CanvasRenderingContext_h
+
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+ class CanvasObject;
+ class HTMLCanvasElement;
+
+ class CanvasRenderingContext : public Noncopyable {
+ public:
+ CanvasRenderingContext(HTMLCanvasElement*);
+ virtual ~CanvasRenderingContext() { }
+
+ void ref();
+ void deref();
+
+ HTMLCanvasElement* canvas() const { return m_canvas; }
+
+ virtual bool is2d() const { return false; }
+ virtual bool is3d() const { return false; }
+
+ protected:
+ HTMLCanvasElement* m_canvas;
+ };
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/html/canvas/CanvasRenderingContext.idl b/WebCore/html/canvas/CanvasRenderingContext.idl
new file mode 100644
index 0000000..8701c80
--- /dev/null
+++ b/WebCore/html/canvas/CanvasRenderingContext.idl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+
+ interface [
+ GenerateConstructor,
+ CustomToJS,
+ InterfaceUUID=98fb48ae-7216-489c-862b-8e1217fc4443,
+ ImplementationUUID=ab4f0781-152f-450e-9546-5b3987491a54
+ ] CanvasRenderingContext {
+
+ readonly attribute HTMLCanvasElement canvas;
+ };
+
+}
+
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
index 20718e9..ed462fc 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
@@ -94,7 +94,7 @@ private:
CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas)
- : m_canvas(canvas)
+ : CanvasRenderingContext(canvas)
, m_stateStack(1)
{
// Make sure that even if the drawingContext() has a different default
@@ -102,14 +102,8 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas)
setLineWidth(lineWidth());
}
-void CanvasRenderingContext2D::ref()
+CanvasRenderingContext2D::~CanvasRenderingContext2D()
{
- m_canvas->ref();
-}
-
-void CanvasRenderingContext2D::deref()
-{
- m_canvas->deref();
}
void CanvasRenderingContext2D::reset()
@@ -941,16 +935,13 @@ static inline FloatRect normalizeRect(const FloatRect& rect)
void CanvasRenderingContext2D::checkOrigin(const KURL& url)
{
- RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url);
- if (!m_canvas->document()->securityOrigin()->canAccess(origin.get()))
+ if (m_canvas->document()->securityOrigin()->taintsCanvas(url))
m_canvas->setOriginTainted();
}
void CanvasRenderingContext2D::checkOrigin(const String& url)
{
- RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(url);
- if (!m_canvas->document()->securityOrigin()->canAccess(origin.get()))
- m_canvas->setOriginTainted();
+ checkOrigin(KURL(KURL(), url));
}
void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float y)
@@ -1214,8 +1205,7 @@ PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageEleme
if (!cachedImage || !image->cachedImage()->image())
return CanvasPattern::create(Image::nullImage(), repeatX, repeatY, true);
- RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(cachedImage->url());
- bool originClean = m_canvas->document()->securityOrigin()->canAccess(origin.get());
+ bool originClean = !m_canvas->document()->securityOrigin()->taintsCanvas(KURL(KURL(), cachedImage->url()));
return CanvasPattern::create(cachedImage->image(), repeatX, repeatY, originClean);
}
@@ -1278,8 +1268,13 @@ static PassRefPtr<ImageData> createEmptyImageData(const IntSize& size)
return data.get();
}
-PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(float sw, float sh) const
+PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(float sw, float sh, ExceptionCode& ec) const
{
+ ec = 0;
+ if (!isfinite(sw) || !isfinite(sh)) {
+ ec = NOT_SUPPORTED_ERR;
+ return 0;
+ }
FloatSize unscaledSize(sw, sh);
IntSize scaledSize = m_canvas->convertLogicalToDevice(unscaledSize);
if (scaledSize.width() < 1)
@@ -1306,7 +1301,7 @@ PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(float sx, float sy,
ImageBuffer* buffer = m_canvas ? m_canvas->buffer() : 0;
if (!buffer)
return createEmptyImageData(scaledRect.size());
- return buffer->getImageData(scaledRect);
+ return buffer->getUnmultipliedImageData(scaledRect);
}
void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy, ExceptionCode& ec)
@@ -1357,7 +1352,7 @@ void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
sourceRect.move(-destOffset);
IntPoint destPoint(destOffset.width(), destOffset.height());
- buffer->putImageData(data, sourceRect, destPoint);
+ buffer->putUnmultipliedImageData(data, sourceRect, destPoint);
}
String CanvasRenderingContext2D::font() const
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.h b/WebCore/html/canvas/CanvasRenderingContext2D.h
index 9648ffc..283f92c 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.h
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.h
@@ -26,6 +26,7 @@
#ifndef CanvasRenderingContext2D_h
#define CanvasRenderingContext2D_h
+#include "CanvasRenderingContext.h"
#include "TransformationMatrix.h"
#include "FloatSize.h"
#include "Font.h"
@@ -54,14 +55,13 @@ namespace WebCore {
typedef int ExceptionCode;
- class CanvasRenderingContext2D : public Noncopyable {
+ class CanvasRenderingContext2D : public CanvasRenderingContext {
public:
CanvasRenderingContext2D(HTMLCanvasElement*);
+
+ virtual ~CanvasRenderingContext2D();
- void ref();
- void deref();
-
- HTMLCanvasElement* canvas() const { return m_canvas; }
+ virtual bool is2d() const { return true; }
CanvasStyle* strokeStyle() const;
void setStrokeStyle(PassRefPtr<CanvasStyle>);
@@ -178,7 +178,7 @@ namespace WebCore {
PassRefPtr<CanvasPattern> createPattern(HTMLImageElement*, const String& repetitionType, ExceptionCode&);
PassRefPtr<CanvasPattern> createPattern(HTMLCanvasElement*, const String& repetitionType, ExceptionCode&);
- PassRefPtr<ImageData> createImageData(float width, float height) const;
+ PassRefPtr<ImageData> createImageData(float width, float height, ExceptionCode&) const;
PassRefPtr<ImageData> getImageData(float sx, float sy, float sw, float sh, ExceptionCode&) const;
void putImageData(ImageData*, float dx, float dy, ExceptionCode&);
void putImageData(ImageData*, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&);
@@ -262,7 +262,6 @@ namespace WebCore {
void checkOrigin(const KURL&);
void checkOrigin(const String&);
- HTMLCanvasElement* m_canvas;
Vector<State, 1> m_stateStack;
};
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.idl b/WebCore/html/canvas/CanvasRenderingContext2D.idl
index a86b47d..ef66d1a 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.idl
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.idl
@@ -29,12 +29,10 @@ module html {
GenerateConstructor,
InterfaceUUID=98fb48ae-7216-489c-862b-8e1217fc4443,
ImplementationUUID=ab4f0781-152f-450e-9546-5b3987491a54
- ] CanvasRenderingContext2D {
+ ] CanvasRenderingContext2D : CanvasRenderingContext {
// Web Applications 1.0 draft
- readonly attribute HTMLCanvasElement canvas;
-
void save();
void restore();
@@ -113,7 +111,8 @@ module html {
attribute [Custom] custom fillStyle;
// pixel manipulation
- ImageData createImageData(in float sw, in float sh);
+ ImageData createImageData(in float sw, in float sh)
+ raises (DOMException);
ImageData getImageData(in float sx, in float sy, in float sw, in float sh)
raises(DOMException);
[Custom] void putImageData(/* in ImageData imagedata, in float dx, in float dy [, in float dirtyX, in float dirtyY, in float dirtyWidth, in float dirtyHeight] */);
diff --git a/WebCore/html/canvas/CanvasRenderingContext3D.cpp b/WebCore/html/canvas/CanvasRenderingContext3D.cpp
new file mode 100644
index 0000000..b810500
--- /dev/null
+++ b/WebCore/html/canvas/CanvasRenderingContext3D.cpp
@@ -0,0 +1,1401 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasRenderingContext3D.h"
+#include "CanvasBuffer.h"
+#include "CanvasFramebuffer.h"
+#include "CanvasProgram.h"
+#include "CanvasRenderbuffer.h"
+#include "CanvasTexture.h"
+#include "CanvasShader.h"
+#include "HTMLCanvasElement.h"
+#include "RenderBox.h"
+#include "RenderLayer.h"
+
+namespace WebCore {
+
+CanvasRenderingContext3D::CanvasRenderingContext3D(HTMLCanvasElement* canvas)
+ : CanvasRenderingContext(canvas)
+ , m_needsUpdate(true)
+ , m_markedCanvasDirty(false)
+{
+ m_context.reshape(m_canvas->width(), m_canvas->height());
+}
+
+CanvasRenderingContext3D::~CanvasRenderingContext3D()
+{
+ detachAndRemoveAllObjects();
+}
+
+void CanvasRenderingContext3D::markContextChanged()
+{
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_canvas->renderBox() && m_canvas->renderBox()->hasLayer()) {
+ m_canvas->renderBox()->layer()->rendererContentChanged();
+ } else {
+#endif
+ if (!m_markedCanvasDirty) {
+ // Make sure the canvas's image buffer is allocated.
+ m_canvas->buffer();
+ m_canvas->willDraw(FloatRect(0, 0, m_canvas->width(), m_canvas->height()));
+ m_markedCanvasDirty = true;
+ }
+#if USE(ACCELERATED_COMPOSITING)
+ }
+#endif
+}
+
+void CanvasRenderingContext3D::beginPaint()
+{
+ if (m_markedCanvasDirty) {
+ m_context.beginPaint(this);
+ }
+}
+
+void CanvasRenderingContext3D::endPaint()
+{
+ if (m_markedCanvasDirty) {
+ m_markedCanvasDirty = false;
+ m_context.endPaint();
+ }
+}
+
+void CanvasRenderingContext3D::reshape(int width, int height)
+{
+ if (m_needsUpdate) {
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_canvas->renderBox() && m_canvas->renderBox()->hasLayer())
+ m_canvas->renderBox()->layer()->rendererContentChanged();
+#endif
+ m_needsUpdate = false;
+ }
+
+ m_context.reshape(width, height);
+}
+
+int CanvasRenderingContext3D::sizeInBytes(int type, ExceptionCode& ec)
+{
+ int result = m_context.sizeInBytes(type);
+ if (result <= 0) {
+ ec = SYNTAX_ERR;
+ }
+ return result;
+}
+
+void CanvasRenderingContext3D::activeTexture(unsigned long texture)
+{
+ m_context.activeTexture(texture);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::attachShader(CanvasProgram* program, CanvasShader* shader)
+{
+ if (!program || !shader)
+ return;
+ m_context.attachShader(program, shader);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::bindAttribLocation(CanvasProgram* program, unsigned long index, const String& name)
+{
+ if (!program)
+ return;
+ m_context.bindAttribLocation(program, index, name);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::bindBuffer(unsigned long target, CanvasBuffer* buffer)
+{
+ m_context.bindBuffer(target, buffer);
+ cleanupAfterGraphicsCall(false);
+}
+
+
+void CanvasRenderingContext3D::bindFramebuffer(unsigned long target, CanvasFramebuffer* buffer)
+{
+ m_context.bindFramebuffer(target, buffer);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::bindRenderbuffer(unsigned long target, CanvasRenderbuffer* renderbuffer)
+{
+ m_context.bindRenderbuffer(target, renderbuffer);
+ cleanupAfterGraphicsCall(false);
+}
+
+
+void CanvasRenderingContext3D::bindTexture(unsigned long target, CanvasTexture* texture)
+{
+ m_context.bindTexture(target, texture);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::blendColor(double red, double green, double blue, double alpha)
+{
+ m_context.blendColor(red, green, blue, alpha);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::blendEquation( unsigned long mode )
+{
+ m_context.blendEquation(mode);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha)
+{
+ m_context.blendEquationSeparate(modeRGB, modeAlpha);
+ cleanupAfterGraphicsCall(false);
+}
+
+
+void CanvasRenderingContext3D::blendFunc(unsigned long sfactor, unsigned long dfactor)
+{
+ m_context.blendFunc(sfactor, dfactor);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha)
+{
+ m_context.blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::bufferData(unsigned long target, int size, unsigned long usage)
+{
+ m_context.bufferData(target, size, usage);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::bufferData(unsigned long target, CanvasArray* data, unsigned long usage)
+{
+ m_context.bufferData(target, data, usage);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::bufferSubData(unsigned long target, long offset, CanvasArray* data)
+{
+ m_context.bufferSubData(target, offset, data);
+ cleanupAfterGraphicsCall(false);
+}
+
+unsigned long CanvasRenderingContext3D::checkFramebufferStatus(unsigned long target)
+{
+ return m_context.checkFramebufferStatus(target);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::clear(unsigned long mask)
+{
+ m_context.clear(mask);
+ cleanupAfterGraphicsCall(true);
+}
+
+void CanvasRenderingContext3D::clearColor(double r, double g, double b, double a)
+{
+ if (isnan(r))
+ r = 0;
+ if (isnan(g))
+ g = 0;
+ if (isnan(b))
+ b = 0;
+ if (isnan(a))
+ a = 1;
+ m_context.clearColor(r, g, b, a);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::clearDepth(double depth)
+{
+ m_context.clearDepth(depth);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::clearStencil(long s)
+{
+ m_context.clearStencil(s);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::colorMask(bool red, bool green, bool blue, bool alpha)
+{
+ m_context.colorMask(red, green, blue, alpha);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::compileShader(CanvasShader* shader)
+{
+ m_context.compileShader(shader);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border)
+{
+ m_context.copyTexImage2D(target, level, internalformat, x, y, width, height, border);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height)
+{
+ m_context.copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+ cleanupAfterGraphicsCall(false);
+}
+
+PassRefPtr<CanvasBuffer> CanvasRenderingContext3D::createBuffer()
+{
+ RefPtr<CanvasBuffer> o = CanvasBuffer::create(this);
+ addObject(o.get());
+ return o;
+}
+
+PassRefPtr<CanvasFramebuffer> CanvasRenderingContext3D::createFramebuffer()
+{
+ RefPtr<CanvasFramebuffer> o = CanvasFramebuffer::create(this);
+ addObject(o.get());
+ return o;
+}
+
+PassRefPtr<CanvasTexture> CanvasRenderingContext3D::createTexture()
+{
+ RefPtr<CanvasTexture> o = CanvasTexture::create(this);
+ addObject(o.get());
+ return o;
+}
+
+PassRefPtr<CanvasProgram> CanvasRenderingContext3D::createProgram()
+{
+ RefPtr<CanvasProgram> o = CanvasProgram::create(this);
+ addObject(o.get());
+ return o;
+}
+
+PassRefPtr<CanvasRenderbuffer> CanvasRenderingContext3D::createRenderbuffer()
+{
+ RefPtr<CanvasRenderbuffer> o = CanvasRenderbuffer::create(this);
+ addObject(o.get());
+ return o;
+}
+
+PassRefPtr<CanvasShader> CanvasRenderingContext3D::createShader(unsigned long type)
+{
+ // FIXME: Need to include GL_ constants for internal use
+ // FIXME: Need to do param checking and throw exception if an illegal value is passed in
+ GraphicsContext3D::ShaderType shaderType = GraphicsContext3D::VERTEX_SHADER;
+ if (type == 0x8B30) // GL_FRAGMENT_SHADER
+ shaderType = GraphicsContext3D::FRAGMENT_SHADER;
+
+ RefPtr<CanvasShader> o = CanvasShader::create(this, shaderType);
+ addObject(o.get());
+ return o;
+}
+
+void CanvasRenderingContext3D::cullFace(unsigned long mode)
+{
+ m_context.cullFace(mode);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::deleteBuffer(CanvasBuffer* buffer)
+{
+ if (!buffer)
+ return;
+
+ buffer->deleteObject();
+}
+
+void CanvasRenderingContext3D::deleteFramebuffer(CanvasFramebuffer* framebuffer)
+{
+ if (!framebuffer)
+ return;
+
+ framebuffer->deleteObject();
+}
+
+void CanvasRenderingContext3D::deleteProgram(CanvasProgram* program)
+{
+ if (!program)
+ return;
+
+ program->deleteObject();
+}
+
+void CanvasRenderingContext3D::deleteRenderbuffer(CanvasRenderbuffer* renderbuffer)
+{
+ if (!renderbuffer)
+ return;
+
+ renderbuffer->deleteObject();
+}
+
+void CanvasRenderingContext3D::deleteShader(CanvasShader* shader)
+{
+ if (!shader)
+ return;
+
+ shader->deleteObject();
+}
+
+void CanvasRenderingContext3D::deleteTexture(CanvasTexture* texture)
+{
+ if (!texture)
+ return;
+
+ texture->deleteObject();
+}
+
+void CanvasRenderingContext3D::depthFunc(unsigned long func)
+{
+ m_context.depthFunc(func);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::depthMask(bool flag)
+{
+ m_context.depthMask(flag);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::depthRange(double zNear, double zFar)
+{
+ m_context.depthRange(zNear, zFar);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::detachShader(CanvasProgram* program, CanvasShader* shader)
+{
+ if (!program || !shader)
+ return;
+
+ m_context.detachShader(program, shader);
+ cleanupAfterGraphicsCall(false);
+}
+
+
+void CanvasRenderingContext3D::disable(unsigned long cap)
+{
+ m_context.disable(cap);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::disableVertexAttribArray(unsigned long index)
+{
+ m_context.disableVertexAttribArray(index);
+ cleanupAfterGraphicsCall(false);
+}
+
+
+void CanvasRenderingContext3D::drawArrays(unsigned long mode, long first, long count)
+{
+ m_context.drawArrays(mode, first, count);
+ cleanupAfterGraphicsCall(true);
+}
+
+void CanvasRenderingContext3D::drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset)
+{
+ m_context.drawElements(mode, count, type, offset);
+ cleanupAfterGraphicsCall(true);
+}
+
+void CanvasRenderingContext3D::enable(unsigned long cap)
+{
+ m_context.enable(cap);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::enableVertexAttribArray(unsigned long index)
+{
+ m_context.enableVertexAttribArray(index);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::finish()
+{
+ m_context.finish();
+ cleanupAfterGraphicsCall(true);
+}
+
+
+void CanvasRenderingContext3D::flush()
+{
+ m_context.flush();
+ cleanupAfterGraphicsCall(true);
+}
+
+void CanvasRenderingContext3D::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, CanvasRenderbuffer* buffer)
+{
+ if (!buffer)
+ return;
+
+ m_context.framebufferRenderbuffer(target, attachment, renderbuffertarget, buffer);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, CanvasTexture* texture, long level)
+{
+ if (!texture)
+ return;
+
+ m_context.framebufferTexture2D(target, attachment, textarget, texture, level);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::frontFace(unsigned long mode)
+{
+ m_context.frontFace(mode);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::generateMipmap(unsigned long target)
+{
+ m_context.generateMipmap(target);
+ cleanupAfterGraphicsCall(false);
+}
+
+int CanvasRenderingContext3D::getAttribLocation(CanvasProgram* program, const String& name)
+{
+ return m_context.getAttribLocation(program, name);
+}
+
+bool CanvasRenderingContext3D::getBoolean(unsigned long pname)
+{
+ bool result = m_context.getBoolean(pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasUnsignedByteArray> CanvasRenderingContext3D::getBooleanv(unsigned long pname)
+{
+ RefPtr<CanvasUnsignedByteArray> array = m_context.getBooleanv(pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+int CanvasRenderingContext3D::getBufferParameteri(unsigned long target, unsigned long pname)
+{
+ int result = m_context.getBufferParameteri(target, pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getBufferParameteriv(unsigned long target, unsigned long pname)
+{
+ RefPtr<CanvasIntArray> array = m_context.getBufferParameteriv(target, pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+unsigned long CanvasRenderingContext3D::getError()
+{
+ return m_context.getError();
+}
+
+float CanvasRenderingContext3D::getFloat(unsigned long pname)
+{
+ float result = m_context.getFloat(pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasFloatArray> CanvasRenderingContext3D::getFloatv(unsigned long pname)
+{
+ RefPtr<CanvasFloatArray> array = m_context.getFloatv(pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+int CanvasRenderingContext3D::getFramebufferAttachmentParameteri(unsigned long target, unsigned long attachment, unsigned long pname)
+{
+ int result = m_context.getFramebufferAttachmentParameteri(target, attachment, pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getFramebufferAttachmentParameteriv(unsigned long target, unsigned long attachment, unsigned long pname)
+{
+ RefPtr<CanvasIntArray> array = m_context.getFramebufferAttachmentParameteriv(target, attachment, pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+int CanvasRenderingContext3D::getInteger(unsigned long pname)
+{
+ float result = m_context.getInteger(pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getIntegerv(unsigned long pname)
+{
+ RefPtr<CanvasIntArray> array = m_context.getIntegerv(pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+int CanvasRenderingContext3D::getProgrami(CanvasProgram* program, unsigned long pname)
+{
+ int result = m_context.getProgrami(program, pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getProgramiv(CanvasProgram* program, unsigned long pname)
+{
+ RefPtr<CanvasIntArray> array = m_context.getProgramiv(program, pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+String CanvasRenderingContext3D::getProgramInfoLog(CanvasProgram* program)
+{
+ String s = m_context.getProgramInfoLog(program);
+ cleanupAfterGraphicsCall(false);
+ return s;
+}
+
+int CanvasRenderingContext3D::getRenderbufferParameteri(unsigned long target, unsigned long pname)
+{
+ int result = m_context.getRenderbufferParameteri(target, pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getRenderbufferParameteriv(unsigned long target, unsigned long pname)
+{
+ RefPtr<CanvasIntArray> array = m_context.getRenderbufferParameteriv(target, pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+int CanvasRenderingContext3D::getShaderi(CanvasShader* shader, unsigned long pname)
+{
+ int result = m_context.getShaderi(shader, pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getShaderiv(CanvasShader* shader, unsigned long pname)
+{
+ RefPtr<CanvasIntArray> array = m_context.getShaderiv(shader, pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+String CanvasRenderingContext3D::getShaderInfoLog(CanvasShader* shader)
+{
+ String s = m_context.getShaderInfoLog(shader);
+ cleanupAfterGraphicsCall(false);
+ return s;
+}
+
+String CanvasRenderingContext3D::getShaderSource(CanvasShader* shader)
+{
+ String s = m_context.getShaderSource(shader);
+ cleanupAfterGraphicsCall(false);
+ return s;
+}
+
+String CanvasRenderingContext3D::getString(unsigned long name)
+{
+ return m_context.getString(name);
+}
+
+float CanvasRenderingContext3D::getTexParameterf(unsigned long target, unsigned long pname)
+{
+ float result = m_context.getTexParameterf(target, pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasFloatArray> CanvasRenderingContext3D::getTexParameterfv(unsigned long target, unsigned long pname)
+{
+ RefPtr<CanvasFloatArray> array = m_context.getTexParameterfv(target, pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+int CanvasRenderingContext3D::getTexParameteri(unsigned long target, unsigned long pname)
+{
+ int result = m_context.getTexParameteri(target, pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getTexParameteriv(unsigned long target, unsigned long pname)
+{
+ RefPtr<CanvasIntArray> array = m_context.getTexParameteriv(target, pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+float CanvasRenderingContext3D::getUniformf(CanvasProgram* program, long location)
+{
+ float result = m_context.getUniformf(program, location);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasFloatArray> CanvasRenderingContext3D::getUniformfv(CanvasProgram* program, long location)
+{
+ RefPtr<CanvasFloatArray> array = m_context.getUniformfv(program, location);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+long CanvasRenderingContext3D::getUniformi(CanvasProgram* program, long location)
+{
+ long result = m_context.getUniformi(program, location);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getUniformiv(CanvasProgram* program, long location)
+{
+ RefPtr<CanvasIntArray> array = m_context.getUniformiv(program, location);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+long CanvasRenderingContext3D::getUniformLocation(CanvasProgram* program, const String& name)
+{
+ return m_context.getUniformLocation(program, name);
+}
+
+float CanvasRenderingContext3D::getVertexAttribf(unsigned long index, unsigned long pname)
+{
+ float result = m_context.getVertexAttribf(index, pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasFloatArray> CanvasRenderingContext3D::getVertexAttribfv(unsigned long index, unsigned long pname)
+{
+ RefPtr<CanvasFloatArray> array = m_context.getVertexAttribfv(index, pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+long CanvasRenderingContext3D::getVertexAttribi(unsigned long index, unsigned long pname)
+{
+ long result = m_context.getVertexAttribi(index, pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+PassRefPtr<CanvasIntArray> CanvasRenderingContext3D::getVertexAttribiv(unsigned long index, unsigned long pname)
+{
+ RefPtr<CanvasIntArray> array = m_context.getVertexAttribiv(index, pname);
+ cleanupAfterGraphicsCall(false);
+ return array;
+}
+
+long CanvasRenderingContext3D::getVertexAttribOffset(unsigned long index, unsigned long pname)
+{
+ long result = m_context.getVertexAttribOffset(index, pname);
+ cleanupAfterGraphicsCall(false);
+ return result;
+}
+
+void CanvasRenderingContext3D::hint(unsigned long target, unsigned long mode)
+{
+ m_context.hint(target, mode);
+ cleanupAfterGraphicsCall(false);
+}
+
+bool CanvasRenderingContext3D::isBuffer(CanvasBuffer* buffer)
+{
+ if (!buffer)
+ return false;
+
+ return m_context.isBuffer(buffer);
+}
+
+bool CanvasRenderingContext3D::isEnabled(unsigned long cap)
+{
+ return m_context.isEnabled(cap);
+}
+
+bool CanvasRenderingContext3D::isFramebuffer(CanvasFramebuffer* framebuffer)
+{
+ return m_context.isFramebuffer(framebuffer);
+}
+
+bool CanvasRenderingContext3D::isProgram(CanvasProgram* program)
+{
+ return m_context.isProgram(program);
+}
+
+bool CanvasRenderingContext3D::isRenderbuffer(CanvasRenderbuffer* renderbuffer)
+{
+ return m_context.isRenderbuffer(renderbuffer);
+}
+
+bool CanvasRenderingContext3D::isShader(CanvasShader* shader)
+{
+ return m_context.isShader(shader);
+}
+
+bool CanvasRenderingContext3D::isTexture(CanvasTexture* texture)
+{
+ return m_context.isTexture(texture);
+}
+
+void CanvasRenderingContext3D::lineWidth(double width)
+{
+ m_context.lineWidth((float) width);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::linkProgram(CanvasProgram* program)
+{
+ if (!program)
+ return;
+
+ m_context.linkProgram(program);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::pixelStorei(unsigned long pname, long param)
+{
+ m_context.pixelStorei(pname, param);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::polygonOffset(double factor, double units)
+{
+ m_context.polygonOffset((float) factor, (float) units);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::releaseShaderCompiler()
+{
+ m_context.releaseShaderCompiler();
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height)
+{
+ m_context.renderbufferStorage(target, internalformat, width, height);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::sampleCoverage(double value, bool invert)
+{
+ m_context.sampleCoverage((float) value, invert);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::scissor(long x, long y, unsigned long width, unsigned long height)
+{
+ m_context.scissor(x, y, width, height);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::shaderSource(CanvasShader* shader, const String& string)
+{
+ m_context.shaderSource(shader, string);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::stencilFunc(unsigned long func, long ref, unsigned long mask)
+{
+ m_context.stencilFunc(func, ref, mask);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask)
+{
+ m_context.stencilFuncSeparate(face, func, ref, mask);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::stencilMask(unsigned long mask)
+{
+ m_context.stencilMask(mask);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::stencilMaskSeparate(unsigned long face, unsigned long mask)
+{
+ m_context.stencilMaskSeparate(face, mask);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass)
+{
+ m_context.stencilOp(fail, zfail, zpass);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass)
+{
+ m_context.stencilOpSeparate(face, fail, zfail, zpass);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned width, unsigned height, unsigned border,
+ unsigned format, unsigned type, CanvasArray* pixels, ExceptionCode& ec)
+{
+ // FIXME: For now we ignore any errors returned
+ ec = 0;
+ m_context.texImage2D(target, level, internalformat, width, height,
+ border, format, type, pixels);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned width, unsigned height, unsigned border,
+ unsigned format, unsigned type, ImageData* pixels, ExceptionCode& ec)
+{
+ // FIXME: For now we ignore any errors returned
+ ec = 0;
+ m_context.texImage2D(target, level, internalformat, width, height,
+ border, format, type, pixels);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, HTMLImageElement* image,
+ bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
+{
+ // FIXME: For now we ignore any errors returned
+ ec = 0;
+ m_context.texImage2D(target, level, image, flipY, premultiplyAlpha);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas,
+ bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
+{
+ // FIXME: For now we ignore any errors returned
+ ec = 0;
+ m_context.texImage2D(target, level, canvas, flipY, premultiplyAlpha);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, HTMLVideoElement* video,
+ bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
+{
+ // FIXME: For now we ignore any errors returned
+ ec = 0;
+ m_context.texImage2D(target, level, video, flipY, premultiplyAlpha);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texParameterf(unsigned target, unsigned pname, float param)
+{
+ m_context.texParameterf(target, pname, param);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texParameteri(unsigned target, unsigned pname, int param)
+{
+ m_context.texParameteri(target, pname, param);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned width, unsigned height,
+ unsigned format, unsigned type, CanvasArray* pixels, ExceptionCode& ec)
+{
+ // FIXME: For now we ignore any errors returned
+ ec = 0;
+ m_context.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned width, unsigned height,
+ unsigned format, unsigned type, ImageData* pixels, ExceptionCode& ec)
+{
+ // FIXME: For now we ignore any errors returned
+ ec = 0;
+ m_context.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned width, unsigned height, HTMLImageElement* image,
+ bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
+{
+ // FIXME: For now we ignore any errors returned
+ ec = 0;
+ m_context.texSubImage2D(target, level, xoffset, yoffset, width, height, image, flipY, premultiplyAlpha);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned width, unsigned height, HTMLCanvasElement* canvas,
+ bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
+{
+ // FIXME: For now we ignore any errors returned
+ ec = 0;
+ m_context.texSubImage2D(target, level, xoffset, yoffset, width, height, canvas, flipY, premultiplyAlpha);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned width, unsigned height, HTMLVideoElement* video,
+ bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
+{
+ // FIXME: For now we ignore any errors returned
+ ec = 0;
+ m_context.texSubImage2D(target, level, xoffset, yoffset, width, height, video, flipY, premultiplyAlpha);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform1f(long location, float x)
+{
+ m_context.uniform1f(location, x);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform1fv(long location, CanvasFloatArray* v)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ m_context.uniform1fv(location, v->data(), v->length());
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform1fv(long location, float* v, int size)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ m_context.uniform1fv(location, v, size);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform1i(long location, int x)
+{
+ m_context.uniform1i(location, x);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform1iv(long location, CanvasIntArray* v)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ m_context.uniform1iv(location, v->data(), v->length());
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform1iv(long location, int* v, int size)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ m_context.uniform1iv(location, v, size);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform2f(long location, float x, float y)
+{
+ m_context.uniform2f(location, x, y);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform2fv(long location, CanvasFloatArray* v)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 2
+ m_context.uniform2fv(location, v->data(), v->length() / 2);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform2fv(long location, float* v, int size)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 2
+ m_context.uniform2fv(location, v, size / 2);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform2i(long location, int x, int y)
+{
+ m_context.uniform2i(location, x, y);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform2iv(long location, CanvasIntArray* v)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 2
+ m_context.uniform2iv(location, v->data(), v->length() / 2);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform2iv(long location, int* v, int size)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 2
+ m_context.uniform2iv(location, v, size / 2);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform3f(long location, float x, float y, float z)
+{
+ m_context.uniform3f(location, x, y, z);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform3fv(long location, CanvasFloatArray* v)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 3
+ m_context.uniform3fv(location, v->data(), v->length() / 3);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform3fv(long location, float* v, int size)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 3
+ m_context.uniform3fv(location, v, size / 3);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform3i(long location, int x, int y, int z)
+{
+ m_context.uniform3i(location, x, y, z);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform3iv(long location, CanvasIntArray* v)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 3
+ m_context.uniform3iv(location, v->data(), v->length() / 3);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform3iv(long location, int* v, int size)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 3
+ m_context.uniform3iv(location, v, size / 3);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform4f(long location, float x, float y, float z, float w)
+{
+ m_context.uniform4f(location, x, y, z, w);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform4fv(long location, CanvasFloatArray* v)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 4
+ m_context.uniform4fv(location, v->data(), v->length() / 4);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform4fv(long location, float* v, int size)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 4
+ m_context.uniform4fv(location, v, size / 4);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform4i(long location, int x, int y, int z, int w)
+{
+ m_context.uniform4i(location, x, y, z, w);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform4iv(long location, CanvasIntArray* v)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 4
+ m_context.uniform4iv(location, v->data(), v->length() / 4);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniform4iv(long location, int* v, int size)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 4
+ m_context.uniform4iv(location, v, size / 4);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniformMatrix2fv(long location, bool transpose, CanvasFloatArray* v)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 4
+ m_context.uniformMatrix2fv(location, transpose, v->data(), v->length() / 4);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniformMatrix2fv(long location, bool transpose, float* v, int size)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 4
+ m_context.uniformMatrix2fv(location, transpose, v, size / 4);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniformMatrix3fv(long location, bool transpose, CanvasFloatArray* v)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 9
+ m_context.uniformMatrix3fv(location, transpose, v->data(), v->length() / 9);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniformMatrix3fv(long location, bool transpose, float* v, int size)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 9
+ m_context.uniformMatrix3fv(location, transpose, v, size / 9);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniformMatrix4fv(long location, bool transpose, CanvasFloatArray* v)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 16
+ m_context.uniformMatrix4fv(location, transpose, v->data(), v->length() / 16);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::uniformMatrix4fv(long location, bool transpose, float* v, int size)
+{
+ // FIXME: we need to throw if no array passed in
+ if (!v)
+ return;
+
+ // FIXME: length needs to be a multiple of 16
+ m_context.uniformMatrix4fv(location, transpose, v, size / 16);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::useProgram(CanvasProgram* program)
+{
+ m_context.useProgram(program);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::validateProgram(CanvasProgram* program)
+{
+ m_context.validateProgram(program);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib1f(unsigned long indx, float v0)
+{
+ m_context.vertexAttrib1f(indx, v0);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib1fv(unsigned long indx, CanvasFloatArray* v)
+{
+ // FIXME: Need to make sure array is big enough for attribute being set
+ m_context.vertexAttrib1fv(indx, v->data());
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib1fv(unsigned long indx, float* v, int size)
+{
+ // FIXME: Need to make sure array is big enough for attribute being set
+ UNUSED_PARAM(size);
+
+ m_context.vertexAttrib1fv(indx, v);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib2f(unsigned long indx, float v0, float v1)
+{
+ m_context.vertexAttrib2f(indx, v0, v1);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib2fv(unsigned long indx, CanvasFloatArray* v)
+{
+ // FIXME: Need to make sure array is big enough for attribute being set
+ m_context.vertexAttrib2fv(indx, v->data());
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib2fv(unsigned long indx, float* v, int size)
+{
+ // FIXME: Need to make sure array is big enough for attribute being set
+ UNUSED_PARAM(size);
+
+ m_context.vertexAttrib2fv(indx, v);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib3f(unsigned long indx, float v0, float v1, float v2)
+{
+ m_context.vertexAttrib3f(indx, v0, v1, v2);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib3fv(unsigned long indx, CanvasFloatArray* v)
+{
+ // FIXME: Need to make sure array is big enough for attribute being set
+ m_context.vertexAttrib3fv(indx, v->data());
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib3fv(unsigned long indx, float* v, int size)
+{
+ // FIXME: Need to make sure array is big enough for attribute being set
+ UNUSED_PARAM(size);
+
+ m_context.vertexAttrib3fv(indx, v);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib4f(unsigned long indx, float v0, float v1, float v2, float v3)
+{
+ m_context.vertexAttrib4f(indx, v0, v1, v2, v3);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib4fv(unsigned long indx, CanvasFloatArray* v)
+{
+ // FIXME: Need to make sure array is big enough for attribute being set
+ m_context.vertexAttrib4fv(indx, v->data());
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttrib4fv(unsigned long indx, float* v, int size)
+{
+ // FIXME: Need to make sure array is big enough for attribute being set
+ UNUSED_PARAM(size);
+
+ m_context.vertexAttrib4fv(indx, v);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::vertexAttribPointer(unsigned long indx, long size, unsigned long type, bool normalized, unsigned long stride, unsigned long offset)
+{
+ m_context.vertexAttribPointer(indx, size, type, normalized, stride, offset);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::viewport(long x, long y, unsigned long width, unsigned long height)
+{
+ if (isnan(x))
+ x = 0;
+ if (isnan(y))
+ y = 0;
+ if (isnan(width))
+ width = 100;
+ if (isnan(height))
+ height = 100;
+ m_context.viewport(x, y, width, height);
+ cleanupAfterGraphicsCall(false);
+}
+
+void CanvasRenderingContext3D::removeObject(CanvasObject* object)
+{
+ m_canvasObjects.remove(object);
+}
+
+void CanvasRenderingContext3D::addObject(CanvasObject* object)
+{
+ removeObject(object);
+ m_canvasObjects.add(object);
+}
+
+void CanvasRenderingContext3D::detachAndRemoveAllObjects()
+{
+ HashSet<CanvasObject*>::iterator pend = m_canvasObjects.end();
+ for (HashSet<CanvasObject*>::iterator it = m_canvasObjects.begin(); it != pend; ++it)
+ (*it)->detachContext();
+
+ m_canvasObjects.clear();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
+
diff --git a/WebCore/html/canvas/CanvasRenderingContext3D.h b/WebCore/html/canvas/CanvasRenderingContext3D.h
new file mode 100644
index 0000000..a4a68fc
--- /dev/null
+++ b/WebCore/html/canvas/CanvasRenderingContext3D.h
@@ -0,0 +1,321 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasRenderingContext3D_h
+#define CanvasRenderingContext3D_h
+
+#include "CanvasRenderingContext.h"
+#include "ExceptionCode.h"
+#include "CanvasFloatArray.h"
+#include "CanvasIntArray.h"
+#include "CanvasUnsignedByteArray.h"
+#include "GraphicsContext3D.h"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+class CanvasBuffer;
+class CanvasFramebuffer;
+class CanvasObject;
+class CanvasProgram;
+class CanvasRenderbuffer;
+class CanvasShader;
+class CanvasTexture;
+class HTMLImageElement;
+class HTMLVideoElement;
+class ImageData;
+class WebKitCSSMatrix;
+
+ class CanvasRenderingContext3D : public CanvasRenderingContext {
+ public:
+ CanvasRenderingContext3D(HTMLCanvasElement*);
+ ~CanvasRenderingContext3D();
+
+ virtual bool is3d() const { return true; }
+
+ // Helper to return the size in bytes of OpenGL data types
+ // like GL_FLOAT, GL_INT, etc.
+ int sizeInBytes(int type, ExceptionCode& ec);
+
+ void activeTexture(unsigned long texture);
+ void attachShader(CanvasProgram*, CanvasShader*);
+ void bindAttribLocation(CanvasProgram*, unsigned long index, const String& name);
+ void bindBuffer(unsigned long target, CanvasBuffer*);
+ void bindFramebuffer(unsigned long target, CanvasFramebuffer*);
+ void bindRenderbuffer(unsigned long target, CanvasRenderbuffer*);
+ void bindTexture(unsigned long target, CanvasTexture*);
+ void blendColor(double red, double green, double blue, double alpha);
+ void blendEquation(unsigned long mode);
+ void blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha);
+ void blendFunc(unsigned long sfactor, unsigned long dfactor);
+ void blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha);
+
+ void bufferData(unsigned long target, int size, unsigned long usage);
+ void bufferData(unsigned long target, CanvasArray* data, unsigned long usage);
+ void bufferSubData(unsigned long target, long offset, CanvasArray* data);
+
+ unsigned long checkFramebufferStatus(unsigned long target);
+ void clear(unsigned long mask);
+ void clearColor(double red, double green, double blue, double alpha);
+ void clearDepth(double);
+ void clearStencil(long);
+ void colorMask(bool red, bool green, bool blue, bool alpha);
+ void compileShader(CanvasShader*);
+
+ //void compressedTexImage2D(unsigned long target, long level, unsigned long internalformat, unsigned long width, unsigned long height, long border, unsigned long imageSize, const void* data);
+ //void compressedTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, unsigned long width, unsigned long height, unsigned long format, unsigned long imageSize, const void* data);
+
+ void copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border);
+ void copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height);
+
+ PassRefPtr<CanvasBuffer> createBuffer();
+ PassRefPtr<CanvasFramebuffer> createFramebuffer();
+ PassRefPtr<CanvasProgram> createProgram();
+ PassRefPtr<CanvasRenderbuffer> createRenderbuffer();
+ PassRefPtr<CanvasShader> createShader(unsigned long type);
+ PassRefPtr<CanvasTexture> createTexture();
+
+ void cullFace(unsigned long mode);
+
+ void deleteBuffer(CanvasBuffer*);
+ void deleteFramebuffer(CanvasFramebuffer*);
+ void deleteProgram(CanvasProgram*);
+ void deleteRenderbuffer(CanvasRenderbuffer*);
+ void deleteShader(CanvasShader*);
+ void deleteTexture(CanvasTexture*);
+
+ void depthFunc(unsigned long);
+ void depthMask(bool);
+ void depthRange(double zNear, double zFar);
+ void detachShader(CanvasProgram*, CanvasShader*);
+ void disable(unsigned long cap);
+ void disableVertexAttribArray(unsigned long index);
+ void drawArrays(unsigned long mode, long first, long count);
+ void drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset);
+
+ void enable(unsigned long cap);
+ void enableVertexAttribArray(unsigned long index);
+ void finish();
+ void flush();
+ void framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, CanvasRenderbuffer*);
+ void framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, CanvasTexture*, long level);
+ void frontFace(unsigned long mode);
+ void generateMipmap(unsigned long target);
+
+ int getAttribLocation(CanvasProgram*, const String& name);
+
+ bool getBoolean(unsigned long pname);
+ PassRefPtr<CanvasUnsignedByteArray> getBooleanv(unsigned long pname);
+ int getBufferParameteri(unsigned long target, unsigned long pname);
+ PassRefPtr<CanvasIntArray> getBufferParameteriv(unsigned long target, unsigned long pname);
+
+ unsigned long getError();
+
+ float getFloat(unsigned long pname);
+ PassRefPtr<CanvasFloatArray> getFloatv(unsigned long pname);
+ int getFramebufferAttachmentParameteri(unsigned long target, unsigned long attachment, unsigned long pname);
+ PassRefPtr<CanvasIntArray> getFramebufferAttachmentParameteriv(unsigned long target, unsigned long attachment, unsigned long pname);
+ int getInteger(unsigned long pname);
+ PassRefPtr<CanvasIntArray> getIntegerv(unsigned long pname);
+ int getProgrami(CanvasProgram*, unsigned long pname);
+ PassRefPtr<CanvasIntArray> getProgramiv(CanvasProgram*, unsigned long pname);
+ String getProgramInfoLog(CanvasProgram*);
+ int getRenderbufferParameteri(unsigned long target, unsigned long pname);
+ PassRefPtr<CanvasIntArray> getRenderbufferParameteriv(unsigned long target, unsigned long pname);
+ int getShaderi(CanvasShader*, unsigned long pname);
+ PassRefPtr<CanvasIntArray> getShaderiv(CanvasShader*, unsigned long pname);
+
+ String getShaderInfoLog(CanvasShader*);
+
+ // TBD
+ // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+
+ String getShaderSource(CanvasShader*);
+ String getString(unsigned long name);
+
+ float getTexParameterf(unsigned long target, unsigned long pname);
+ PassRefPtr<CanvasFloatArray> getTexParameterfv(unsigned long target, unsigned long pname);
+ int getTexParameteri(unsigned long target, unsigned long pname);
+ PassRefPtr<CanvasIntArray> getTexParameteriv(unsigned long target, unsigned long pname);
+
+ float getUniformf(CanvasProgram* program, long location);
+ PassRefPtr<CanvasFloatArray> getUniformfv(CanvasProgram* program, long location);
+ long getUniformi(CanvasProgram* program, long location);
+ PassRefPtr<CanvasIntArray> getUniformiv(CanvasProgram* program, long location);
+
+ long getUniformLocation(CanvasProgram*, const String& name);
+
+ float getVertexAttribf(unsigned long index, unsigned long pname);
+ PassRefPtr<CanvasFloatArray> getVertexAttribfv(unsigned long index, unsigned long pname);
+ long getVertexAttribi(unsigned long index, unsigned long pname);
+ PassRefPtr<CanvasIntArray> getVertexAttribiv(unsigned long index, unsigned long pname);
+
+ long getVertexAttribOffset(unsigned long index, unsigned long pname);
+
+ void hint(unsigned long target, unsigned long mode);
+ bool isBuffer(CanvasBuffer*);
+ bool isEnabled(unsigned long cap);
+ bool isFramebuffer(CanvasFramebuffer*);
+ bool isProgram(CanvasProgram*);
+ bool isRenderbuffer(CanvasRenderbuffer*);
+ bool isShader(CanvasShader*);
+ bool isTexture(CanvasTexture*);
+ void lineWidth(double);
+ void linkProgram(CanvasProgram*);
+ void pixelStorei(unsigned long pname, long param);
+ void polygonOffset(double factor, double units);
+
+ // TBD
+ //void readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type, void* pixels);
+
+ void releaseShaderCompiler();
+ void renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height);
+ void sampleCoverage(double value, bool invert);
+ void scissor(long x, long y, unsigned long width, unsigned long height);
+ void shaderSource(CanvasShader*, const String&);
+ void stencilFunc(unsigned long func, long ref, unsigned long mask);
+ void stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask);
+ void stencilMask(unsigned long);
+ void stencilMaskSeparate(unsigned long face, unsigned long mask);
+ void stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass);
+ void stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass);
+
+ void texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned width, unsigned height, unsigned border,
+ unsigned format, unsigned type, CanvasArray* pixels, ExceptionCode&);
+ void texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned width, unsigned height, unsigned border,
+ unsigned format, unsigned type, ImageData* pixels, ExceptionCode&);
+ void texImage2D(unsigned target, unsigned level, HTMLImageElement* image,
+ bool flipY, bool premultiplyAlpha, ExceptionCode&);
+ void texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas,
+ bool flipY, bool premultiplyAlpha, ExceptionCode&);
+ void texImage2D(unsigned target, unsigned level, HTMLVideoElement* video,
+ bool flipY, bool premultiplyAlpha, ExceptionCode&);
+
+ void texParameterf(unsigned target, unsigned pname, float param);
+ void texParameteri(unsigned target, unsigned pname, int param);
+
+ void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned width, unsigned height,
+ unsigned format, unsigned type, CanvasArray* pixels, ExceptionCode&);
+ void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned width, unsigned height,
+ unsigned format, unsigned type, ImageData* pixels, ExceptionCode&);
+ void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned width, unsigned height, HTMLImageElement* image,
+ bool flipY, bool premultiplyAlpha, ExceptionCode&);
+ void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned width, unsigned height, HTMLCanvasElement* canvas,
+ bool flipY, bool premultiplyAlpha, ExceptionCode&);
+ void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned width, unsigned height, HTMLVideoElement* video,
+ bool flipY, bool premultiplyAlpha, ExceptionCode&);
+
+ void uniform1f(long location, float x);
+ void uniform1fv(long location, CanvasFloatArray* v);
+ void uniform1fv(long location, float* v, int size);
+ void uniform1i(long location, int x);
+ void uniform1iv(long location, CanvasIntArray* v);
+ void uniform1iv(long location, int* v, int size);
+ void uniform2f(long location, float x, float y);
+ void uniform2fv(long location, CanvasFloatArray* v);
+ void uniform2fv(long location, float* v, int size);
+ void uniform2i(long location, int x, int y);
+ void uniform2iv(long location, CanvasIntArray* v);
+ void uniform2iv(long location, int* v, int size);
+ void uniform3f(long location, float x, float y, float z);
+ void uniform3fv(long location, CanvasFloatArray* v);
+ void uniform3fv(long location, float* v, int size);
+ void uniform3i(long location, int x, int y, int z);
+ void uniform3iv(long location, CanvasIntArray* v);
+ void uniform3iv(long location, int* v, int size);
+ void uniform4f(long location, float x, float y, float z, float w);
+ void uniform4fv(long location, CanvasFloatArray* v);
+ void uniform4fv(long location, float* v, int size);
+ void uniform4i(long location, int x, int y, int z, int w);
+ void uniform4iv(long location, CanvasIntArray* v);
+ void uniform4iv(long location, int* v, int size);
+ void uniformMatrix2fv(long location, bool transpose, CanvasFloatArray* value);
+ void uniformMatrix2fv(long location, bool transpose, float* value, int size);
+ void uniformMatrix3fv(long location, bool transpose, CanvasFloatArray* value);
+ void uniformMatrix3fv(long location, bool transpose, float* value, int size);
+ void uniformMatrix4fv(long location, bool transpose, CanvasFloatArray* value);
+ void uniformMatrix4fv(long location, bool transpose, float* value, int size);
+
+ void useProgram(CanvasProgram*);
+ void validateProgram(CanvasProgram*);
+
+ void vertexAttrib1f(unsigned long indx, float x);
+ void vertexAttrib1fv(unsigned long indx, CanvasFloatArray* values);
+ void vertexAttrib1fv(unsigned long indx, float* values, int size);
+ void vertexAttrib2f(unsigned long indx, float x, float y);
+ void vertexAttrib2fv(unsigned long indx, CanvasFloatArray* values);
+ void vertexAttrib2fv(unsigned long indx, float* values, int size);
+ void vertexAttrib3f(unsigned long indx, float x, float y, float z);
+ void vertexAttrib3fv(unsigned long indx, CanvasFloatArray* values);
+ void vertexAttrib3fv(unsigned long indx, float* values, int size);
+ void vertexAttrib4f(unsigned long indx, float x, float y, float z, float w);
+ void vertexAttrib4fv(unsigned long indx, CanvasFloatArray* values);
+ void vertexAttrib4fv(unsigned long indx, float* values, int size);
+ void vertexAttribPointer(unsigned long indx, long size, unsigned long type, bool normalized,
+ unsigned long stride, unsigned long offset);
+
+ void viewport(long x, long y, unsigned long width, unsigned long height);
+
+ GraphicsContext3D* graphicsContext3D() { return &m_context; }
+
+ void reshape(int width, int height);
+
+ // Helpers for notification about paint events.
+ void beginPaint();
+ void endPaint();
+
+ void removeObject(CanvasObject*);
+
+ private:
+ friend class CanvasObject;
+ void addObject(CanvasObject*);
+ void detachAndRemoveAllObjects();
+
+ void markContextChanged();
+ void cleanupAfterGraphicsCall(bool changed)
+ {
+ m_context.checkError();
+ if (changed)
+ markContextChanged();
+ }
+
+ GraphicsContext3D m_context;
+ bool m_needsUpdate;
+ bool m_markedCanvasDirty;
+ // FIXME: I think this is broken -- it does not increment any
+ // reference counts, so may refer to destroyed objects.
+ HashSet<CanvasObject*> m_canvasObjects;
+ };
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/html/canvas/CanvasRenderingContext3D.idl b/WebCore/html/canvas/CanvasRenderingContext3D.idl
new file mode 100644
index 0000000..4b9a889
--- /dev/null
+++ b/WebCore/html/canvas/CanvasRenderingContext3D.idl
@@ -0,0 +1,687 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+
+ interface [
+ Conditional=3D_CANVAS,
+ GenerateConstructor,
+ InterfaceUUID=98fb48ae-7216-489c-862b-8e1217fc4443,
+ ImplementationUUID=ab4f0781-152f-450e-9546-5b3987491a54
+ ] CanvasRenderingContext3D : CanvasRenderingContext {
+
+ /* ClearBufferMask */
+ const unsigned int DEPTH_BUFFER_BIT = 0x00000100;
+ const unsigned int STENCIL_BUFFER_BIT = 0x00000400;
+ const unsigned int COLOR_BUFFER_BIT = 0x00004000;
+
+ /* Boolean */
+ const unsigned int FALSE = 0;
+ const unsigned int TRUE = 1;
+
+ /* BeginMode */
+ const unsigned int POINTS = 0x0000;
+ const unsigned int LINES = 0x0001;
+ const unsigned int LINE_LOOP = 0x0002;
+ const unsigned int LINE_STRIP = 0x0003;
+ const unsigned int TRIANGLES = 0x0004;
+ const unsigned int TRIANGLE_STRIP = 0x0005;
+ const unsigned int TRIANGLE_FAN = 0x0006;
+
+ /* AlphaFunction (not supported in ES20) */
+ /* NEVER */
+ /* LESS */
+ /* EQUAL */
+ /* LEQUAL */
+ /* GREATER */
+ /* NOTEQUAL */
+ /* GEQUAL */
+ /* ALWAYS */
+
+ /* BlendingFactorDest */
+ const unsigned int ZERO = 0;
+ const unsigned int ONE = 1;
+ const unsigned int SRC_COLOR = 0x0300;
+ const unsigned int ONE_MINUS_SRC_COLOR = 0x0301;
+ const unsigned int SRC_ALPHA = 0x0302;
+ const unsigned int ONE_MINUS_SRC_ALPHA = 0x0303;
+ const unsigned int DST_ALPHA = 0x0304;
+ const unsigned int ONE_MINUS_DST_ALPHA = 0x0305;
+
+ /* BlendingFactorSrc */
+ /* ZERO */
+ /* ONE */
+ const unsigned int DST_COLOR = 0x0306;
+ const unsigned int ONE_MINUS_DST_COLOR = 0x0307;
+ const unsigned int SRC_ALPHA_SATURATE = 0x0308;
+ /* SRC_ALPHA */
+ /* ONE_MINUS_SRC_ALPHA */
+ /* DST_ALPHA */
+ /* ONE_MINUS_DST_ALPHA */
+
+ /* BlendEquationSeparate */
+ const unsigned int FUNC_ADD = 0x8006;
+ const unsigned int BLEND_EQUATION = 0x8009;
+ const unsigned int BLEND_EQUATION_RGB = 0x8009; /* same as BLEND_EQUATION */
+ const unsigned int BLEND_EQUATION_ALPHA = 0x883D;
+
+ /* BlendSubtract */
+ const unsigned int FUNC_SUBTRACT = 0x800A;
+ const unsigned int FUNC_REVERSE_SUBTRACT = 0x800B;
+
+ /* Separate Blend Functions */
+ const unsigned int BLEND_DST_RGB = 0x80C8;
+ const unsigned int BLEND_SRC_RGB = 0x80C9;
+ const unsigned int BLEND_DST_ALPHA = 0x80CA;
+ const unsigned int BLEND_SRC_ALPHA = 0x80CB;
+ const unsigned int CONSTANT_COLOR = 0x8001;
+ const unsigned int ONE_MINUS_CONSTANT_COLOR = 0x8002;
+ const unsigned int CONSTANT_ALPHA = 0x8003;
+ const unsigned int ONE_MINUS_CONSTANT_ALPHA = 0x8004;
+ const unsigned int BLEND_COLOR = 0x8005;
+
+ /* Buffer Objects */
+ const unsigned int ARRAY_BUFFER = 0x8892;
+ const unsigned int ELEMENT_ARRAY_BUFFER = 0x8893;
+ const unsigned int ARRAY_BUFFER_BINDING = 0x8894;
+ const unsigned int ELEMENT_ARRAY_BUFFER_BINDING = 0x8895;
+
+ const unsigned int STREAM_DRAW = 0x88E0;
+ const unsigned int STATIC_DRAW = 0x88E4;
+ const unsigned int DYNAMIC_DRAW = 0x88E8;
+
+ const unsigned int BUFFER_SIZE = 0x8764;
+ const unsigned int BUFFER_USAGE = 0x8765;
+
+ const unsigned int CURRENT_VERTEX_ATTRIB = 0x8626;
+
+ /* CullFaceMode */
+ const unsigned int FRONT = 0x0404;
+ const unsigned int BACK = 0x0405;
+ const unsigned int FRONT_AND_BACK = 0x0408;
+
+ /* DepthFunction */
+ /* NEVER */
+ /* LESS */
+ /* EQUAL */
+ /* LEQUAL */
+ /* GREATER */
+ /* NOTEQUAL */
+ /* GEQUAL */
+ /* ALWAYS */
+
+ /* EnableCap */
+ const unsigned int TEXTURE_2D = 0x0DE1;
+ const unsigned int CULL_FACE = 0x0B44;
+ const unsigned int BLEND = 0x0BE2;
+ const unsigned int DITHER = 0x0BD0;
+ const unsigned int STENCIL_TEST = 0x0B90;
+ const unsigned int DEPTH_TEST = 0x0B71;
+ const unsigned int SCISSOR_TEST = 0x0C11;
+ const unsigned int POLYGON_OFFSET_FILL = 0x8037;
+ const unsigned int SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
+ const unsigned int SAMPLE_COVERAGE = 0x80A0;
+
+ /* ErrorCode */
+ const unsigned int NO_ERROR = 0;
+ const unsigned int INVALID_ENUM = 0x0500;
+ const unsigned int INVALID_VALUE = 0x0501;
+ const unsigned int INVALID_OPERATION = 0x0502;
+ const unsigned int OUT_OF_MEMORY = 0x0505;
+
+ /* FrontFaceDirection */
+ const unsigned int CW = 0x0900;
+ const unsigned int CCW = 0x0901;
+
+ /* GetPName */
+ const unsigned int LINE_WIDTH = 0x0B21;
+ const unsigned int ALIASED_POINT_SIZE_RANGE = 0x846D;
+ const unsigned int ALIASED_LINE_WIDTH_RANGE = 0x846E;
+ const unsigned int CULL_FACE_MODE = 0x0B45;
+ const unsigned int FRONT_FACE = 0x0B46;
+ const unsigned int DEPTH_RANGE = 0x0B70;
+ const unsigned int DEPTH_WRITEMASK = 0x0B72;
+ const unsigned int DEPTH_CLEAR_VALUE = 0x0B73;
+ const unsigned int DEPTH_FUNC = 0x0B74;
+ const unsigned int STENCIL_CLEAR_VALUE = 0x0B91;
+ const unsigned int STENCIL_FUNC = 0x0B92;
+ const unsigned int STENCIL_FAIL = 0x0B94;
+ const unsigned int STENCIL_PASS_DEPTH_FAIL = 0x0B95;
+ const unsigned int STENCIL_PASS_DEPTH_PASS = 0x0B96;
+ const unsigned int STENCIL_REF = 0x0B97;
+ const unsigned int STENCIL_VALUE_MASK = 0x0B93;
+ const unsigned int STENCIL_WRITEMASK = 0x0B98;
+ const unsigned int STENCIL_BACK_FUNC = 0x8800;
+ const unsigned int STENCIL_BACK_FAIL = 0x8801;
+ const unsigned int STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802;
+ const unsigned int STENCIL_BACK_PASS_DEPTH_PASS = 0x8803;
+ const unsigned int STENCIL_BACK_REF = 0x8CA3;
+ const unsigned int STENCIL_BACK_VALUE_MASK = 0x8CA4;
+ const unsigned int STENCIL_BACK_WRITEMASK = 0x8CA5;
+ const unsigned int VIEWPORT = 0x0BA2;
+ const unsigned int SCISSOR_BOX = 0x0C10;
+ /* SCISSOR_TEST */
+ const unsigned int COLOR_CLEAR_VALUE = 0x0C22;
+ const unsigned int COLOR_WRITEMASK = 0x0C23;
+ const unsigned int UNPACK_ALIGNMENT = 0x0CF5;
+ const unsigned int PACK_ALIGNMENT = 0x0D05;
+ const unsigned int MAX_TEXTURE_SIZE = 0x0D33;
+ const unsigned int MAX_VIEWPORT_DIMS = 0x0D3A;
+ const unsigned int SUBPIXEL_BITS = 0x0D50;
+ const unsigned int RED_BITS = 0x0D52;
+ const unsigned int GREEN_BITS = 0x0D53;
+ const unsigned int BLUE_BITS = 0x0D54;
+ const unsigned int ALPHA_BITS = 0x0D55;
+ const unsigned int DEPTH_BITS = 0x0D56;
+ const unsigned int STENCIL_BITS = 0x0D57;
+ const unsigned int POLYGON_OFFSET_UNITS = 0x2A00;
+ /* POLYGON_OFFSET_FILL */
+ const unsigned int POLYGON_OFFSET_FACTOR = 0x8038;
+ const unsigned int TEXTURE_BINDING_2D = 0x8069;
+ const unsigned int SAMPLE_BUFFERS = 0x80A8;
+ const unsigned int SAMPLES = 0x80A9;
+ const unsigned int SAMPLE_COVERAGE_VALUE = 0x80AA;
+ const unsigned int SAMPLE_COVERAGE_INVERT = 0x80AB;
+
+ /* GetTextureParameter */
+ /* TEXTURE_MAG_FILTER */
+ /* TEXTURE_MIN_FILTER */
+ /* TEXTURE_WRAP_S */
+ /* TEXTURE_WRAP_T */
+
+ const unsigned int NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2;
+ const unsigned int COMPRESSED_TEXTURE_FORMATS = 0x86A3;
+
+ /* HintMode */
+ const unsigned int DONT_CARE = 0x1100;
+ const unsigned int FASTEST = 0x1101;
+ const unsigned int NICEST = 0x1102;
+
+ /* HintTarget */
+ const unsigned int GENERATE_MIPMAP_HINT = 0x8192;
+
+ /* DataType */
+ const unsigned int BYTE = 0x1400;
+ const unsigned int UNSIGNED_BYTE = 0x1401;
+ const unsigned int SHORT = 0x1402;
+ const unsigned int UNSIGNED_SHORT = 0x1403;
+ const unsigned int INT = 0x1404;
+ const unsigned int UNSIGNED_INT = 0x1405;
+ const unsigned int FLOAT = 0x1406;
+ const unsigned int FIXED = 0x140C;
+
+ /* PixelFormat */
+ const unsigned int DEPTH_COMPONENT = 0x1902;
+ const unsigned int ALPHA = 0x1906;
+ const unsigned int RGB = 0x1907;
+ const unsigned int RGBA = 0x1908;
+ const unsigned int LUMINANCE = 0x1909;
+ const unsigned int LUMINANCE_ALPHA = 0x190A;
+
+ /* PixelType */
+ /* UNSIGNED_BYTE */
+ const unsigned int UNSIGNED_SHORT_4_4_4_4 = 0x8033;
+ const unsigned int UNSIGNED_SHORT_5_5_5_1 = 0x8034;
+ const unsigned int UNSIGNED_SHORT_5_6_5 = 0x8363;
+
+ /* Shaders */
+ const unsigned int FRAGMENT_SHADER = 0x8B30;
+ const unsigned int VERTEX_SHADER = 0x8B31;
+ const unsigned int MAX_VERTEX_ATTRIBS = 0x8869;
+ const unsigned int MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB;
+ const unsigned int MAX_VARYING_VECTORS = 0x8DFC;
+ const unsigned int MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
+ const unsigned int MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C;
+ const unsigned int MAX_TEXTURE_IMAGE_UNITS = 0x8872;
+ const unsigned int MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD;
+ const unsigned int SHADER_TYPE = 0x8B4F;
+ const unsigned int DELETE_STATUS = 0x8B80;
+ const unsigned int LINK_STATUS = 0x8B82;
+ const unsigned int VALIDATE_STATUS = 0x8B83;
+ const unsigned int ATTACHED_SHADERS = 0x8B85;
+ const unsigned int ACTIVE_UNIFORMS = 0x8B86;
+ const unsigned int ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87;
+ const unsigned int ACTIVE_ATTRIBUTES = 0x8B89;
+ const unsigned int ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A;
+ const unsigned int SHADING_LANGUAGE_VERSION = 0x8B8C;
+ const unsigned int CURRENT_PROGRAM = 0x8B8D;
+
+ /* StencilFunction */
+ const unsigned int NEVER = 0x0200;
+ const unsigned int LESS = 0x0201;
+ const unsigned int EQUAL = 0x0202;
+ const unsigned int LEQUAL = 0x0203;
+ const unsigned int GREATER = 0x0204;
+ const unsigned int NOTEQUAL = 0x0205;
+ const unsigned int GEQUAL = 0x0206;
+ const unsigned int ALWAYS = 0x0207;
+
+ /* StencilOp */
+ /* ZERO */
+ const unsigned int KEEP = 0x1E00;
+ const unsigned int REPLACE = 0x1E01;
+ const unsigned int INCR = 0x1E02;
+ const unsigned int DECR = 0x1E03;
+ const unsigned int INVERT = 0x150A;
+ const unsigned int INCR_WRAP = 0x8507;
+ const unsigned int DECR_WRAP = 0x8508;
+
+ /* StringName */
+ const unsigned int VENDOR = 0x1F00;
+ const unsigned int RENDERER = 0x1F01;
+ const unsigned int VERSION = 0x1F02;
+ const unsigned int EXTENSIONS = 0x1F03;
+
+ /* TextureMagFilter */
+ const unsigned int NEAREST = 0x2600;
+ const unsigned int LINEAR = 0x2601;
+
+ /* TextureMinFilter */
+ /* NEAREST */
+ /* LINEAR */
+ const unsigned int NEAREST_MIPMAP_NEAREST = 0x2700;
+ const unsigned int LINEAR_MIPMAP_NEAREST = 0x2701;
+ const unsigned int NEAREST_MIPMAP_LINEAR = 0x2702;
+ const unsigned int LINEAR_MIPMAP_LINEAR = 0x2703;
+
+ /* TextureParameterName */
+ const unsigned int TEXTURE_MAG_FILTER = 0x2800;
+ const unsigned int TEXTURE_MIN_FILTER = 0x2801;
+ const unsigned int TEXTURE_WRAP_S = 0x2802;
+ const unsigned int TEXTURE_WRAP_T = 0x2803;
+
+ /* TextureTarget */
+ /* TEXTURE_2D */
+ const unsigned int TEXTURE = 0x1702;
+
+ const unsigned int TEXTURE_CUBE_MAP = 0x8513;
+ const unsigned int TEXTURE_BINDING_CUBE_MAP = 0x8514;
+ const unsigned int TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
+ const unsigned int TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
+ const unsigned int TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
+ const unsigned int TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
+ const unsigned int TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
+ const unsigned int TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
+ const unsigned int MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
+
+ /* TextureUnit */
+ const unsigned int TEXTURE0 = 0x84C0;
+ const unsigned int TEXTURE1 = 0x84C1;
+ const unsigned int TEXTURE2 = 0x84C2;
+ const unsigned int TEXTURE3 = 0x84C3;
+ const unsigned int TEXTURE4 = 0x84C4;
+ const unsigned int TEXTURE5 = 0x84C5;
+ const unsigned int TEXTURE6 = 0x84C6;
+ const unsigned int TEXTURE7 = 0x84C7;
+ const unsigned int TEXTURE8 = 0x84C8;
+ const unsigned int TEXTURE9 = 0x84C9;
+ const unsigned int TEXTURE10 = 0x84CA;
+ const unsigned int TEXTURE11 = 0x84CB;
+ const unsigned int TEXTURE12 = 0x84CC;
+ const unsigned int TEXTURE13 = 0x84CD;
+ const unsigned int TEXTURE14 = 0x84CE;
+ const unsigned int TEXTURE15 = 0x84CF;
+ const unsigned int TEXTURE16 = 0x84D0;
+ const unsigned int TEXTURE17 = 0x84D1;
+ const unsigned int TEXTURE18 = 0x84D2;
+ const unsigned int TEXTURE19 = 0x84D3;
+ const unsigned int TEXTURE20 = 0x84D4;
+ const unsigned int TEXTURE21 = 0x84D5;
+ const unsigned int TEXTURE22 = 0x84D6;
+ const unsigned int TEXTURE23 = 0x84D7;
+ const unsigned int TEXTURE24 = 0x84D8;
+ const unsigned int TEXTURE25 = 0x84D9;
+ const unsigned int TEXTURE26 = 0x84DA;
+ const unsigned int TEXTURE27 = 0x84DB;
+ const unsigned int TEXTURE28 = 0x84DC;
+ const unsigned int TEXTURE29 = 0x84DD;
+ const unsigned int TEXTURE30 = 0x84DE;
+ const unsigned int TEXTURE31 = 0x84DF;
+ const unsigned int ACTIVE_TEXTURE = 0x84E0;
+
+ /* TextureWrapMode */
+ const unsigned int REPEAT = 0x2901;
+ const unsigned int CLAMP_TO_EDGE = 0x812F;
+ const unsigned int MIRRORED_REPEAT = 0x8370;
+
+ /* Uniform Types */
+ const unsigned int FLOAT_VEC2 = 0x8B50;
+ const unsigned int FLOAT_VEC3 = 0x8B51;
+ const unsigned int FLOAT_VEC4 = 0x8B52;
+ const unsigned int INT_VEC2 = 0x8B53;
+ const unsigned int INT_VEC3 = 0x8B54;
+ const unsigned int INT_VEC4 = 0x8B55;
+ const unsigned int BOOL = 0x8B56;
+ const unsigned int BOOL_VEC2 = 0x8B57;
+ const unsigned int BOOL_VEC3 = 0x8B58;
+ const unsigned int BOOL_VEC4 = 0x8B59;
+ const unsigned int FLOAT_MAT2 = 0x8B5A;
+ const unsigned int FLOAT_MAT3 = 0x8B5B;
+ const unsigned int FLOAT_MAT4 = 0x8B5C;
+ const unsigned int SAMPLER_2D = 0x8B5E;
+ const unsigned int SAMPLER_CUBE = 0x8B60;
+
+ /* Vertex Arrays */
+ const unsigned int VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622;
+ const unsigned int VERTEX_ATTRIB_ARRAY_SIZE = 0x8623;
+ const unsigned int VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624;
+ const unsigned int VERTEX_ATTRIB_ARRAY_TYPE = 0x8625;
+ const unsigned int VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A;
+ const unsigned int VERTEX_ATTRIB_ARRAY_POINTER = 0x8645;
+ const unsigned int VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;
+
+ /* Read Format */
+ const unsigned int IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A;
+ const unsigned int IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B;
+
+ /* Shader Source */
+ const unsigned int COMPILE_STATUS = 0x8B81;
+ const unsigned int INFO_LOG_LENGTH = 0x8B84;
+ const unsigned int SHADER_SOURCE_LENGTH = 0x8B88;
+ const unsigned int SHADER_COMPILER = 0x8DFA;
+
+ /* Shader Binary */
+ const unsigned int SHADER_BINARY_FORMATS = 0x8DF8;
+ const unsigned int NUM_SHADER_BINARY_FORMATS = 0x8DF9;
+
+ /* Shader Precision-Specified Types */
+ const unsigned int LOW_FLOAT = 0x8DF0;
+ const unsigned int MEDIUM_FLOAT = 0x8DF1;
+ const unsigned int HIGH_FLOAT = 0x8DF2;
+ const unsigned int LOW_INT = 0x8DF3;
+ const unsigned int MEDIUM_INT = 0x8DF4;
+ const unsigned int HIGH_INT = 0x8DF5;
+
+ /* Framebuffer Object. */
+ const unsigned int FRAMEBUFFER = 0x8D40;
+ const unsigned int RENDERBUFFER = 0x8D41;
+
+ const unsigned int RGBA4 = 0x8056;
+ const unsigned int RGB5_A1 = 0x8057;
+ const unsigned int RGB565 = 0x8D62;
+ const unsigned int DEPTH_COMPONENT16 = 0x81A5;
+ const unsigned int STENCIL_INDEX = 0x1901;
+ const unsigned int STENCIL_INDEX8 = 0x8D48;
+
+ const unsigned int RENDERBUFFER_WIDTH = 0x8D42;
+ const unsigned int RENDERBUFFER_HEIGHT = 0x8D43;
+ const unsigned int RENDERBUFFER_INTERNAL_FORMAT = 0x8D44;
+ const unsigned int RENDERBUFFER_RED_SIZE = 0x8D50;
+ const unsigned int RENDERBUFFER_GREEN_SIZE = 0x8D51;
+ const unsigned int RENDERBUFFER_BLUE_SIZE = 0x8D52;
+ const unsigned int RENDERBUFFER_ALPHA_SIZE = 0x8D53;
+ const unsigned int RENDERBUFFER_DEPTH_SIZE = 0x8D54;
+ const unsigned int RENDERBUFFER_STENCIL_SIZE = 0x8D55;
+
+ const unsigned int FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0;
+ const unsigned int FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1;
+ const unsigned int FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2;
+ const unsigned int FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;
+
+ const unsigned int COLOR_ATTACHMENT0 = 0x8CE0;
+ const unsigned int DEPTH_ATTACHMENT = 0x8D00;
+ const unsigned int STENCIL_ATTACHMENT = 0x8D20;
+
+ const unsigned int NONE = 0;
+
+ const unsigned int FRAMEBUFFER_COMPLETE = 0x8CD5;
+ const unsigned int FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6;
+ const unsigned int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
+ const unsigned int FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9;
+ const unsigned int FRAMEBUFFER_UNSUPPORTED = 0x8CDD;
+
+ const unsigned int FRAMEBUFFER_BINDING = 0x8CA6;
+ const unsigned int RENDERBUFFER_BINDING = 0x8CA7;
+ const unsigned int MAX_RENDERBUFFER_SIZE = 0x84E8;
+
+ const unsigned int INVALID_FRAMEBUFFER_OPERATION = 0x0506;
+
+ long sizeInBytes(in unsigned long type) raises(DOMException);
+
+ void activeTexture(in unsigned long texture);
+ void attachShader(in CanvasProgram program, in CanvasShader shader);
+ void bindAttribLocation(in CanvasProgram program, in unsigned long index, in DOMString name);
+ void bindBuffer(in unsigned long target, in CanvasBuffer buffer);
+ void bindFramebuffer(in unsigned long target, in CanvasFramebuffer framebuffer);
+ void bindRenderbuffer(in unsigned long target, in CanvasRenderbuffer renderbuffer);
+ void bindTexture(in unsigned long target, in CanvasTexture texture);
+ void blendColor(in double red, in double green, in double blue, in double alpha);
+ void blendEquation( in unsigned long mode );
+ void blendEquationSeparate(in unsigned long modeRGB, in unsigned long modeAlpha);
+ void blendFunc(in unsigned long sfactor, in unsigned long dfactor);
+ void blendFuncSeparate(in unsigned long srcRGB, in unsigned long dstRGB, in unsigned long srcAlpha, in unsigned long dstAlpha);
+ // Supported forms:
+ // void bufferData (in GLenum target, in GLsizei size, in GLenum usage);
+ // void bufferData (in GLenum target, in CanvasArray data, in GLenum usage);
+ [Custom] void bufferData();
+ // Supported forms:
+ // void bufferSubData (in GLenum target, in GLsizeiptr offset, in CanvasArray data);
+ [Custom] void bufferSubData();
+
+ unsigned long checkFramebufferStatus(in unsigned long target);
+ void clear(in unsigned long mask);
+ void clearColor(in double red, in double green, in double blue, in double alpha);
+ void clearDepth(in double depth);
+ void clearStencil(in long s);
+ void colorMask(in boolean red, in boolean green, in boolean blue, in boolean alpha);
+ void compileShader(in CanvasShader shader);
+
+ //void compressedTexImage2D(in unsigned long target, in long level, in unsigned long internalformat, in unsigned long width, in unsigned long height, in long border, in unsigned long imageSize, const void* data);
+ //void compressedTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset, in unsigned long width, in unsigned long height, in unsigned long format, in unsigned long imageSize, const void* data);
+
+ void copyTexImage2D(in unsigned long target, in long level, in unsigned long internalformat, in long x, in long y, in unsigned long width, in unsigned long height, in long border);
+ void copyTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset, in long x, in long y, in unsigned long width, in unsigned long height);
+
+ CanvasBuffer createBuffer();
+ CanvasFramebuffer createFramebuffer();
+ CanvasProgram createProgram();
+ CanvasRenderbuffer createRenderbuffer();
+ CanvasShader createShader(in unsigned long type);
+ CanvasTexture createTexture();
+
+ void cullFace(in unsigned long mode);
+
+ void deleteBuffer(in CanvasBuffer buffer);
+ void deleteFramebuffer(in CanvasFramebuffer framebuffer);
+ void deleteProgram(in CanvasProgram program);
+ void deleteRenderbuffer(in CanvasRenderbuffer renderbuffer);
+ void deleteShader(in CanvasShader shader);
+ void deleteTexture(in CanvasTexture texture);
+
+ void depthFunc(in unsigned long func);
+ void depthMask(in boolean flag);
+ // FIXME: this differs from the current WebGL spec (depthRangef)
+ void depthRange(in double zNear, in double zFar);
+ void detachShader(in CanvasProgram program, in CanvasShader shader);
+ void disable(in unsigned long cap);
+ void disableVertexAttribArray(in unsigned long index);
+ void drawArrays(in unsigned long mode, in long first, in unsigned long count);
+ void drawElements (in unsigned long mode, in long count, in unsigned long type, in unsigned long offset);
+
+ void enable(in unsigned long cap);
+ void enableVertexAttribArray(in unsigned long index);
+ void finish();
+ void flush();
+ void framebufferRenderbuffer(in unsigned long target, in unsigned long attachment, in unsigned long renderbuffertarget, in CanvasRenderbuffer renderbuffer);
+ void framebufferTexture2D(in unsigned long target, in unsigned long attachment, in unsigned long textarget, in CanvasTexture texture, in long level);
+ void frontFace(in unsigned long mode);
+ void generateMipmap(in unsigned long target);
+
+ // FIXME: these need to be added per the WebGL spec
+ // CanvasActiveInfo getActiveAttrib(GLuint program, GLuint index);
+ // CanvasActiveInfo getActiveUniform(GLuint program, GLuint index);
+ // CanvasShaderArray glGetAttachedShaders(GLuint program);
+
+ int getAttribLocation(in CanvasProgram program, in DOMString name);
+
+ boolean getBoolean(in unsigned long pname);
+ CanvasUnsignedByteArray getBooleanv(in unsigned long pname);
+ long getBufferParameteri(in unsigned long target, in unsigned long pname);
+ CanvasIntArray getBufferParameteriv(in unsigned long target, in unsigned long pname);
+
+ unsigned long getError();
+
+ float getFloat(in unsigned long pname);
+ CanvasFloatArray getFloatv(in unsigned long pname);
+ long getFramebufferAttachmentParameteri(in unsigned long target, in unsigned long attachment, in unsigned long pname);
+ CanvasIntArray getFramebufferAttachmentParameteriv(in unsigned long target, in unsigned long attachment, in unsigned long pname);
+ long getInteger(in unsigned long pname);
+ CanvasIntArray getIntegerv(in unsigned long pname);
+ long getProgrami(in CanvasProgram program, in unsigned long pname);
+ CanvasIntArray getProgramiv(in CanvasProgram program, in unsigned long pname);
+ DOMString getProgramInfoLog(in CanvasProgram program);
+ long getRenderbufferParameteri(in unsigned long target, in unsigned long pname);
+ CanvasIntArray getRenderbufferParameteriv(in unsigned long target, in unsigned long pname);
+ long getShaderi(in CanvasShader shader, in unsigned long pname);
+ CanvasIntArray getShaderiv(in CanvasShader shader, in unsigned long pname);
+
+ DOMString getShaderInfoLog(in CanvasShader shader);
+
+ // TBD
+ // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+
+ DOMString getShaderSource(in CanvasShader shader);
+ DOMString getString(in unsigned long name);
+
+ float getTexParameterf(in unsigned long target, in unsigned long pname);
+ CanvasFloatArray getTexParameterfv(in unsigned long target, in unsigned long pname);
+ long getTexParameteri(in unsigned long target, in unsigned long pname);
+ CanvasIntArray getTexParameteriv(in unsigned long target, in unsigned long pname);
+
+ float getUniformf(in CanvasProgram program, in long location);
+ CanvasFloatArray getUniformfv(in CanvasProgram program, in long location);
+ long getUniformi(in CanvasProgram program, in long location);
+ CanvasIntArray getUniformiv(in CanvasProgram program, in long location);
+
+ long getUniformLocation(in CanvasProgram program, in DOMString name);
+
+ float getVertexAttribf(in unsigned long index, in unsigned long pname);
+ CanvasFloatArray getVertexAttribfv(in unsigned long index, in unsigned long pname);
+ long getVertexAttribi(in unsigned long index, in unsigned long pname);
+ CanvasIntArray getVertexAttribiv(in unsigned long index, in unsigned long pname);
+
+ long getVertexAttribOffset(in unsigned long index, in unsigned long pname);
+
+ void hint(in unsigned long target, in unsigned long mode);
+ boolean isBuffer(in CanvasBuffer buffer);
+ boolean isEnabled(in unsigned long cap);
+ boolean isFramebuffer(in CanvasFramebuffer framebuffer);
+ boolean isProgram(in CanvasProgram program);
+ boolean isRenderbuffer(in CanvasRenderbuffer renderbuffer);
+ boolean isShader(in CanvasShader shader);
+ boolean isTexture(in CanvasTexture texture);
+ void lineWidth(in double width);
+ void linkProgram(in CanvasProgram program);
+ void pixelStorei(in unsigned long pname, in long param);
+ void polygonOffset(in double factor, in double units);
+
+ // FIXME
+ //void readPixels(in long x, in long y, in unsigned long width, in unsigned long height, in unsigned long format, in unsigned long type, void* pixels);
+
+ void releaseShaderCompiler();
+ void renderbufferStorage(in unsigned long target, in unsigned long internalformat, in unsigned long width, in unsigned long height);
+ void sampleCoverage(in double value, in boolean invert);
+ void scissor(in long x, in long y, in unsigned long width, in unsigned long height);
+ void shaderSource(in CanvasShader shader, in DOMString string);
+ void stencilFunc(in unsigned long func, in long ref, in unsigned long mask);
+ void stencilFuncSeparate(in unsigned long face, in unsigned long func, in long ref, in unsigned long mask);
+ void stencilMask(in unsigned long mask);
+ void stencilMaskSeparate(in unsigned long face, in unsigned long mask);
+ void stencilOp(in unsigned long fail, in unsigned long zfail, in unsigned long zpass);
+ void stencilOpSeparate(in unsigned long face, in unsigned long fail, in unsigned long zfail, in unsigned long zpass);
+
+ void texParameterf(in unsigned long target, in unsigned long pname, in float param);
+ void texParameteri(in unsigned long target, in unsigned long pname, in long param);
+
+ // Supported forms:
+ // void texImage2D(in GLenum target, in GLint level, in GLenum internalformat, in GLsizei width, in GLsizei height,
+ // in GLint border, in GLenum format, in GLenum type, in CanvasArray pixels);
+ // void texImage2D(in GLenum target, in GLint level, in GLenum internalformat, in GLsizei width, in GLsizei height,
+ // in GLint border, in GLenum format, in GLenum type, in ImageData pixels);
+ // void texImage2D(in GLenum target, in GLint level, in HTMLImageElement image,
+ // [Optional] in GLboolean flipY, [Optional] in premultiplyAlpha);
+ // void texImage2D(in GLenum target, in GLint level, in HTMLCanvasElement canvas,
+ // [Optional] in GLboolean flipY, [Optional] in premultiplyAlpha);
+ // void texImage2D(in GLenum target, in GLint level, in HTMLVideoElement video,
+ // [Optional] in GLboolean flipY, [Optional] in premultiplyAlpha);
+ [Custom] void texImage2D();
+
+ // Supported forms:
+ // void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset,
+ // in GLsizei width, in GLsizei height,
+ // in GLenum format, in GLenum type, in CanvasArray pixels);
+ // void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset,
+ // in GLsizei width, in GLsizei height,
+ // in GLenum format, in GLenum type, in ImageData pixels);
+ // void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset,
+ // in GLsizei width, in GLsizei height, in HTMLImageElement image,
+ // [Optional] GLboolean flipY, [Optional] in premultiplyAlpha);
+ // void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset,
+ // in GLsizei width, in GLsizei height, in HTMLCanvasElement canvas,
+ // [Optional] GLboolean flipY, [Optional] in premultiplyAlpha);
+ // void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset,
+ // in GLsizei width, in GLsizei height, in HTMLVideoElement video,
+ // [Optional] GLboolean flipY, [Optional] in premultiplyAlpha);
+ [Custom] void texSubImage2D();
+
+ void uniform1f(in long location, in float x);
+ [Custom] void uniform1fv(in long location, in CanvasFloatArray v);
+ void uniform1i(in long location, in long x);
+ [Custom] void uniform1iv(in long location, in CanvasIntArray v);
+ void uniform2f(in long location, in float x, in float y);
+ [Custom] void uniform2fv(in long location, in CanvasFloatArray v);
+ void uniform2i(in long location, in long x, in long y);
+ [Custom] void uniform2iv(in long location, in CanvasIntArray v);
+ void uniform3f(in long location, in float x, in float y, in float z);
+ [Custom] void uniform3fv(in long location, in CanvasFloatArray v);
+ void uniform3i(in long location, in long x, in long y, in long z);
+ [Custom] void uniform3iv(in long location, in CanvasIntArray v);
+ void uniform4f(in long location, in float x, in float y, in float z, in float w);
+ [Custom] void uniform4fv(in long location, in CanvasFloatArray v);
+ void uniform4i(in long location, in long x, in long y, in long z, in long w);
+ [Custom] void uniform4iv(in long location, in CanvasIntArray v);
+
+ [Custom] void uniformMatrix2fv(in long location, in boolean transpose, in CanvasFloatArray array);
+ [Custom] void uniformMatrix3fv(in long location, in boolean transpose, in CanvasFloatArray array);
+ [Custom] void uniformMatrix4fv(in long location, in boolean transpose, in CanvasFloatArray array);
+
+ void useProgram(in CanvasProgram program);
+ void validateProgram(in CanvasProgram program);
+
+ void vertexAttrib1f(in unsigned long indx, in float x);
+ [Custom] void vertexAttrib1fv(in unsigned long indx, in CanvasFloatArray values);
+ void vertexAttrib2f(in unsigned long indx, in float x, in float y);
+ [Custom] void vertexAttrib2fv(in unsigned long indx, in CanvasFloatArray values);
+ void vertexAttrib3f(in unsigned long indx, in float x, in float y, in float z);
+ [Custom] void vertexAttrib3fv(in unsigned long indx, in CanvasFloatArray values);
+ void vertexAttrib4f(in unsigned long indx, in float x, in float y, in float z, in float w);
+ [Custom] void vertexAttrib4fv(in unsigned long indx, in CanvasFloatArray values);
+ void vertexAttribPointer(in unsigned long indx, in long size, in unsigned long type, in boolean normalized,
+ in long stride, in unsigned long offset);
+
+ void viewport(in long x, in long y, in unsigned long width, in unsigned long height);
+ };
+}
+
diff --git a/WebCore/html/canvas/CanvasShader.cpp b/WebCore/html/canvas/CanvasShader.cpp
new file mode 100644
index 0000000..7f134fa
--- /dev/null
+++ b/WebCore/html/canvas/CanvasShader.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasShader.h"
+#include "CanvasRenderingContext3D.h"
+
+namespace WebCore {
+
+PassRefPtr<CanvasShader> CanvasShader::create(CanvasRenderingContext3D* ctx, GraphicsContext3D::ShaderType type)
+{
+ return adoptRef(new CanvasShader(ctx, type));
+}
+
+CanvasShader::CanvasShader(CanvasRenderingContext3D* ctx, GraphicsContext3D::ShaderType type)
+ : CanvasObject(ctx)
+{
+ setObject(context()->graphicsContext3D()->createShader(type));
+}
+
+void CanvasShader::_deleteObject(Platform3DObject object)
+{
+ context()->graphicsContext3D()->deleteShader(object);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasShader.h b/WebCore/html/canvas/CanvasShader.h
new file mode 100644
index 0000000..bb7980e
--- /dev/null
+++ b/WebCore/html/canvas/CanvasShader.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasShader_h
+#define CanvasShader_h
+
+#include "CanvasObject.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasShader : public CanvasObject {
+ public:
+ virtual ~CanvasShader() { deleteObject(); }
+
+ static PassRefPtr<CanvasShader> create(CanvasRenderingContext3D*, GraphicsContext3D::ShaderType);
+
+ private:
+ CanvasShader(CanvasRenderingContext3D*, GraphicsContext3D::ShaderType);
+
+ virtual void _deleteObject(Platform3DObject);
+ };
+
+} // namespace WebCore
+
+#endif // CanvasShader_h
diff --git a/WebCore/html/canvas/CanvasShader.idl b/WebCore/html/canvas/CanvasShader.idl
new file mode 100644
index 0000000..7474c3a
--- /dev/null
+++ b/WebCore/html/canvas/CanvasShader.idl
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [Conditional=3D_CANVAS] CanvasShader {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasShortArray.cpp b/WebCore/html/canvas/CanvasShortArray.cpp
new file mode 100644
index 0000000..d0cf135
--- /dev/null
+++ b/WebCore/html/canvas/CanvasShortArray.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasShortArray.h"
+
+namespace WebCore {
+
+ PassRefPtr<CanvasShortArray> CanvasShortArray::create(unsigned length)
+ {
+ RefPtr<CanvasArrayBuffer> buffer = CanvasArrayBuffer::create(length * sizeof(short));
+ return create(buffer, 0, length);
+ }
+
+ PassRefPtr<CanvasShortArray> CanvasShortArray::create(short* array, unsigned length)
+ {
+ RefPtr<CanvasShortArray> a = CanvasShortArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+ }
+
+ PassRefPtr<CanvasShortArray> CanvasShortArray::create(PassRefPtr<CanvasArrayBuffer> buffer,
+ int offset,
+ unsigned length)
+ {
+ // Make sure the offset results in valid alignment.
+ if ((offset % sizeof(short)) != 0)
+ return NULL;
+
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given CanvasArrayBuffer's storage.
+ if ((offset + (length * sizeof(short))) > buffer->byteLength())
+ return NULL;
+ }
+
+ return adoptRef(new CanvasShortArray(buffer, offset, length));
+ }
+
+ CanvasShortArray::CanvasShortArray(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length)
+ : CanvasArray(buffer, offset)
+ , m_size(length)
+ {
+ }
+
+ unsigned CanvasShortArray::length() const {
+ return m_size;
+ }
+
+ unsigned CanvasShortArray::sizeInBytes() const {
+ return length() * sizeof(short);
+ }
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasShortArray.h b/WebCore/html/canvas/CanvasShortArray.h
new file mode 100644
index 0000000..00a170f
--- /dev/null
+++ b/WebCore/html/canvas/CanvasShortArray.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasShortArray_h
+#define CanvasShortArray_h
+
+#include "CanvasArray.h"
+#include <limits>
+#include <wtf/MathExtras.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasShortArray : public CanvasArray {
+ public:
+ static PassRefPtr<CanvasShortArray> create(unsigned length);
+ static PassRefPtr<CanvasShortArray> create(short* array, unsigned length);
+ static PassRefPtr<CanvasShortArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length);
+
+ short* data() { return static_cast<short*>(baseAddress()); }
+
+ virtual unsigned length() const;
+ virtual unsigned sizeInBytes() const;
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<short>::min())
+ value = std::numeric_limits<short>::min();
+ else if (value > std::numeric_limits<short>::max())
+ value = std::numeric_limits<short>::max();
+ short* storage = static_cast<short*>(m_baseAddress);
+ storage[index] = static_cast<short>(value);
+ }
+
+ bool get(unsigned index, short& result) const
+ {
+ if (index >= m_size)
+ return false;
+ result = item(index);
+ return true;
+ }
+
+ short item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ short* storage = static_cast<short*>(m_baseAddress);
+ return storage[index];
+ }
+
+ private:
+ CanvasShortArray(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length);
+ unsigned m_size;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasShortArray_h
diff --git a/WebCore/html/canvas/CanvasShortArray.idl b/WebCore/html/canvas/CanvasShortArray.idl
new file mode 100644
index 0000000..6d64e1c
--- /dev/null
+++ b/WebCore/html/canvas/CanvasShortArray.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ Conditional=3D_CANVAS,
+ HasNumericIndexGetter,
+ HasCustomIndexSetter,
+ GenerateNativeConverter,
+ GenerateCustomConstructor,
+ CustomToJS
+ ] CanvasShortArray : CanvasArray {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasTexture.cpp b/WebCore/html/canvas/CanvasTexture.cpp
new file mode 100644
index 0000000..624c275
--- /dev/null
+++ b/WebCore/html/canvas/CanvasTexture.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasTexture.h"
+#include "CanvasRenderingContext3D.h"
+
+namespace WebCore {
+
+PassRefPtr<CanvasTexture> CanvasTexture::create(CanvasRenderingContext3D* ctx)
+{
+ return adoptRef(new CanvasTexture(ctx));
+}
+
+CanvasTexture::CanvasTexture(CanvasRenderingContext3D* ctx)
+ : CanvasObject(ctx)
+ , cubeMapRWrapModeInitialized(false)
+{
+ setObject(context()->graphicsContext3D()->createTexture());
+}
+
+void CanvasTexture::_deleteObject(Platform3DObject object)
+{
+ context()->graphicsContext3D()->deleteTexture(object);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasTexture.h b/WebCore/html/canvas/CanvasTexture.h
new file mode 100644
index 0000000..32a669a
--- /dev/null
+++ b/WebCore/html/canvas/CanvasTexture.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasTexture_h
+#define CanvasTexture_h
+
+#include "CanvasObject.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasTexture : public CanvasObject {
+ public:
+ virtual ~CanvasTexture() { deleteObject(); }
+
+ static PassRefPtr<CanvasTexture> create(CanvasRenderingContext3D*);
+
+ bool isCubeMapRWrapModeInitialized() {
+ return cubeMapRWrapModeInitialized;
+ }
+
+ void setCubeMapRWrapModeInitialized(bool initialized) {
+ cubeMapRWrapModeInitialized = initialized;
+ }
+
+ protected:
+ CanvasTexture(CanvasRenderingContext3D*);
+
+ virtual void _deleteObject(Platform3DObject);
+
+ private:
+ bool cubeMapRWrapModeInitialized;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasTexture_h
diff --git a/WebCore/html/canvas/CanvasTexture.idl b/WebCore/html/canvas/CanvasTexture.idl
new file mode 100644
index 0000000..77eedd7
--- /dev/null
+++ b/WebCore/html/canvas/CanvasTexture.idl
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [Conditional=3D_CANVAS] CanvasTexture {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasUnsignedByteArray.cpp b/WebCore/html/canvas/CanvasUnsignedByteArray.cpp
new file mode 100644
index 0000000..a75066c
--- /dev/null
+++ b/WebCore/html/canvas/CanvasUnsignedByteArray.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasUnsignedByteArray.h"
+
+namespace WebCore {
+
+ PassRefPtr<CanvasUnsignedByteArray> CanvasUnsignedByteArray::create(unsigned length)
+ {
+ RefPtr<CanvasArrayBuffer> buffer = CanvasArrayBuffer::create(length * sizeof(unsigned char));
+ return create(buffer, 0, length);
+ }
+
+ PassRefPtr<CanvasUnsignedByteArray> CanvasUnsignedByteArray::create(unsigned char* array, unsigned length)
+ {
+ RefPtr<CanvasUnsignedByteArray> a = CanvasUnsignedByteArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+ }
+
+ PassRefPtr<CanvasUnsignedByteArray> CanvasUnsignedByteArray::create(PassRefPtr<CanvasArrayBuffer> buffer,
+ int offset,
+ unsigned length)
+ {
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given CanvasArrayBuffer's storage.
+ if ((offset + (length * sizeof(unsigned char))) > buffer->byteLength())
+ return NULL;
+ }
+
+ return adoptRef(new CanvasUnsignedByteArray(buffer, offset, length));
+ }
+
+ CanvasUnsignedByteArray::CanvasUnsignedByteArray(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length)
+ : CanvasArray(buffer, offset)
+ , m_size(length)
+ {
+ }
+
+ unsigned CanvasUnsignedByteArray::length() const {
+ return m_size;
+ }
+
+ unsigned CanvasUnsignedByteArray::sizeInBytes() const {
+ return length() * sizeof(unsigned char);
+ }
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasUnsignedByteArray.h b/WebCore/html/canvas/CanvasUnsignedByteArray.h
new file mode 100644
index 0000000..6293034
--- /dev/null
+++ b/WebCore/html/canvas/CanvasUnsignedByteArray.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasUnsignedByteArray_h
+#define CanvasUnsignedByteArray_h
+
+#include "CanvasArray.h"
+#include <limits>
+#include <wtf/MathExtras.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasUnsignedByteArray : public CanvasArray {
+ public:
+ static PassRefPtr<CanvasUnsignedByteArray> create(unsigned length);
+ static PassRefPtr<CanvasUnsignedByteArray> create(unsigned char* array, unsigned length);
+ static PassRefPtr<CanvasUnsignedByteArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length);
+
+ unsigned char* data() { return static_cast<unsigned char*>(baseAddress()); }
+
+ virtual unsigned length() const;
+ virtual unsigned sizeInBytes() const;
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<unsigned char>::min())
+ value = std::numeric_limits<unsigned char>::min();
+ else if (value > std::numeric_limits<unsigned char>::max())
+ value = std::numeric_limits<unsigned char>::max();
+ unsigned char* storage = static_cast<unsigned char*>(m_baseAddress);
+ storage[index] = static_cast<unsigned char>(value);
+ }
+
+ bool get(unsigned index, unsigned char& result) const
+ {
+ if (index >= m_size)
+ return false;
+ result = item(index);
+ return true;
+ }
+
+ unsigned char item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ unsigned char* storage = static_cast<unsigned char*>(m_baseAddress);
+ return storage[index];
+ }
+
+ private:
+ CanvasUnsignedByteArray(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length);
+ unsigned m_size;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasUnsignedByteArray_h
diff --git a/WebCore/html/canvas/CanvasUnsignedByteArray.idl b/WebCore/html/canvas/CanvasUnsignedByteArray.idl
new file mode 100644
index 0000000..d46f708
--- /dev/null
+++ b/WebCore/html/canvas/CanvasUnsignedByteArray.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ Conditional=3D_CANVAS,
+ HasNumericIndexGetter,
+ HasCustomIndexSetter,
+ GenerateNativeConverter,
+ GenerateCustomConstructor,
+ CustomToJS
+ ] CanvasUnsignedByteArray : CanvasArray {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasUnsignedIntArray.cpp b/WebCore/html/canvas/CanvasUnsignedIntArray.cpp
new file mode 100644
index 0000000..bd26343
--- /dev/null
+++ b/WebCore/html/canvas/CanvasUnsignedIntArray.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasUnsignedIntArray.h"
+
+namespace WebCore {
+
+ PassRefPtr<CanvasUnsignedIntArray> CanvasUnsignedIntArray::create(unsigned length)
+ {
+ RefPtr<CanvasArrayBuffer> buffer = CanvasArrayBuffer::create(length * sizeof(unsigned int));
+ return create(buffer, 0, length);
+ }
+
+ PassRefPtr<CanvasUnsignedIntArray> CanvasUnsignedIntArray::create(unsigned int* array, unsigned length)
+ {
+ RefPtr<CanvasUnsignedIntArray> a = CanvasUnsignedIntArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+ }
+
+ PassRefPtr<CanvasUnsignedIntArray> CanvasUnsignedIntArray::create(PassRefPtr<CanvasArrayBuffer> buffer,
+ int offset,
+ unsigned length)
+ {
+ // Make sure the offset results in valid alignment.
+ if ((offset % sizeof(unsigned int)) != 0) {
+ return NULL;
+ }
+
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given CanvasArrayBuffer's storage.
+ if ((offset + (length * sizeof(unsigned int))) > buffer->byteLength())
+ return NULL;
+ }
+
+ return adoptRef(new CanvasUnsignedIntArray(buffer, offset, length));
+ }
+
+ CanvasUnsignedIntArray::CanvasUnsignedIntArray(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length)
+ : CanvasArray(buffer, offset)
+ , m_size(length)
+ {
+ }
+
+ unsigned CanvasUnsignedIntArray::length() const {
+ return m_size;
+ }
+
+ unsigned CanvasUnsignedIntArray::sizeInBytes() const {
+ return length() * sizeof(unsigned int);
+ }
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasUnsignedIntArray.h b/WebCore/html/canvas/CanvasUnsignedIntArray.h
new file mode 100644
index 0000000..5b5994c
--- /dev/null
+++ b/WebCore/html/canvas/CanvasUnsignedIntArray.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasUnsignedIntArray_h
+#define CanvasUnsignedIntArray_h
+
+#include "CanvasArray.h"
+#include <limits>
+#include <wtf/MathExtras.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasUnsignedIntArray : public CanvasArray {
+ public:
+ static PassRefPtr<CanvasUnsignedIntArray> create(unsigned length);
+ static PassRefPtr<CanvasUnsignedIntArray> create(unsigned int* array, unsigned length);
+ static PassRefPtr<CanvasUnsignedIntArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length);
+
+ unsigned int* data() { return static_cast<unsigned int*>(baseAddress()); }
+
+ virtual unsigned length() const;
+ virtual unsigned sizeInBytes() const;
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<unsigned int>::min())
+ value = std::numeric_limits<unsigned int>::min();
+ else if (value > std::numeric_limits<unsigned int>::max())
+ value = std::numeric_limits<unsigned int>::max();
+ unsigned int* storage = static_cast<unsigned int*>(m_baseAddress);
+ storage[index] = static_cast<unsigned int>(value);
+ }
+
+ bool get(unsigned index, unsigned int& result) const
+ {
+ if (index >= m_size)
+ return false;
+ result = item(index);
+ return true;
+ }
+
+ unsigned int item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ unsigned int* storage = static_cast<unsigned int*>(m_baseAddress);
+ return storage[index];
+ }
+
+ private:
+ CanvasUnsignedIntArray(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length);
+ unsigned m_size;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasUnsignedIntArray_h
diff --git a/WebCore/html/canvas/CanvasUnsignedIntArray.idl b/WebCore/html/canvas/CanvasUnsignedIntArray.idl
new file mode 100644
index 0000000..3ab60d6
--- /dev/null
+++ b/WebCore/html/canvas/CanvasUnsignedIntArray.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ Conditional=3D_CANVAS,
+ HasNumericIndexGetter,
+ HasCustomIndexSetter,
+ GenerateNativeConverter,
+ GenerateCustomConstructor,
+ CustomToJS
+ ] CanvasUnsignedIntArray : CanvasArray {
+ };
+}
diff --git a/WebCore/html/canvas/CanvasUnsignedShortArray.cpp b/WebCore/html/canvas/CanvasUnsignedShortArray.cpp
new file mode 100644
index 0000000..45d827b
--- /dev/null
+++ b/WebCore/html/canvas/CanvasUnsignedShortArray.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasUnsignedShortArray.h"
+
+namespace WebCore {
+
+ PassRefPtr<CanvasUnsignedShortArray> CanvasUnsignedShortArray::create(unsigned length)
+ {
+ RefPtr<CanvasArrayBuffer> buffer = CanvasArrayBuffer::create(length * sizeof(unsigned short));
+ return create(buffer, 0, length);
+ }
+
+ PassRefPtr<CanvasUnsignedShortArray> CanvasUnsignedShortArray::create(unsigned short* array, unsigned length)
+ {
+ RefPtr<CanvasUnsignedShortArray> a = CanvasUnsignedShortArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+ }
+
+ PassRefPtr<CanvasUnsignedShortArray> CanvasUnsignedShortArray::create(PassRefPtr<CanvasArrayBuffer> buffer,
+ int offset,
+ unsigned length)
+ {
+ // Make sure the offset results in valid alignment.
+ if ((offset % sizeof(unsigned short)) != 0) {
+ return NULL;
+ }
+
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given CanvasArrayBuffer's storage.
+ if ((offset + (length * sizeof(unsigned short))) > buffer->byteLength())
+ return NULL;
+ }
+
+ return adoptRef(new CanvasUnsignedShortArray(buffer, offset, length));
+ }
+
+ CanvasUnsignedShortArray::CanvasUnsignedShortArray(PassRefPtr<CanvasArrayBuffer> buffer,
+ int offset,
+ unsigned length)
+ : CanvasArray(buffer, offset)
+ , m_size(length)
+ {
+ }
+
+ unsigned CanvasUnsignedShortArray::length() const {
+ return m_size;
+ }
+
+ unsigned CanvasUnsignedShortArray::sizeInBytes() const {
+ return length() * sizeof(unsigned short);
+ }
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/CanvasUnsignedShortArray.h b/WebCore/html/canvas/CanvasUnsignedShortArray.h
new file mode 100644
index 0000000..1f6252e
--- /dev/null
+++ b/WebCore/html/canvas/CanvasUnsignedShortArray.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CanvasUnsignedShortArray_h
+#define CanvasUnsignedShortArray_h
+
+#include "CanvasArray.h"
+#include <limits>
+#include <wtf/MathExtras.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+ class CanvasUnsignedShortArray : public CanvasArray {
+ public:
+ static PassRefPtr<CanvasUnsignedShortArray> create(unsigned length);
+ static PassRefPtr<CanvasUnsignedShortArray> create(unsigned short* array, unsigned length);
+ static PassRefPtr<CanvasUnsignedShortArray> create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length);
+
+ unsigned short* data() { return static_cast<unsigned short*>(baseAddress()); }
+
+ virtual unsigned length() const;
+ virtual unsigned sizeInBytes() const;
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<unsigned short>::min())
+ value = std::numeric_limits<unsigned short>::min();
+ else if (value > std::numeric_limits<unsigned short>::max())
+ value = std::numeric_limits<unsigned short>::max();
+ unsigned short* storage = static_cast<unsigned short*>(m_baseAddress);
+ storage[index] = static_cast<unsigned short>(value);
+ }
+
+ bool get(unsigned index, unsigned short& result) const
+ {
+ if (index >= m_size)
+ return false;
+ unsigned short* storage = static_cast<unsigned short*>(m_baseAddress);
+ result = storage[index];
+ return true;
+ }
+
+ unsigned short item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ unsigned short* storage = static_cast<unsigned short*>(m_baseAddress);
+ return storage[index];
+ }
+
+ private:
+ CanvasUnsignedShortArray(PassRefPtr<CanvasArrayBuffer> buffer,int offset,unsigned length);
+ unsigned m_size;
+ };
+
+} // namespace WebCore
+
+#endif // CanvasUnsignedShortArray_h
diff --git a/WebCore/html/canvas/CanvasUnsignedShortArray.idl b/WebCore/html/canvas/CanvasUnsignedShortArray.idl
new file mode 100644
index 0000000..99fc6a2
--- /dev/null
+++ b/WebCore/html/canvas/CanvasUnsignedShortArray.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ Conditional=3D_CANVAS,
+ HasNumericIndexGetter,
+ HasCustomIndexSetter,
+ GenerateNativeConverter,
+ GenerateCustomConstructor,
+ CustomToJS
+ ] CanvasUnsignedShortArray : CanvasArray {
+ };
+}