summaryrefslogtreecommitdiffstats
path: root/WebCore/html
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/html')
-rw-r--r--WebCore/html/FileError.idl2
-rw-r--r--WebCore/html/FileReader.idl64
-rw-r--r--WebCore/html/FileThreadTask.h4
-rw-r--r--WebCore/html/HTMLAttributeNames.in3
-rw-r--r--WebCore/html/HTMLElement.cpp1
-rw-r--r--WebCore/html/HTMLElementsAllInOne.cpp1
-rw-r--r--WebCore/html/HTMLFormControlElement.cpp46
-rw-r--r--WebCore/html/HTMLFormControlElement.h6
-rw-r--r--WebCore/html/HTMLFormElement.cpp21
-rw-r--r--WebCore/html/HTMLFormElement.h2
-rw-r--r--WebCore/html/HTMLFrameElementBase.cpp8
-rw-r--r--WebCore/html/HTMLInputElement.cpp11
-rw-r--r--WebCore/html/HTMLInputElement.h1
-rw-r--r--WebCore/html/HTMLIsIndexElement.h1
-rw-r--r--WebCore/html/HTMLLabelElement.cpp54
-rw-r--r--WebCore/html/HTMLLabelElement.h3
-rw-r--r--WebCore/html/HTMLLabelElement.idl1
-rw-r--r--WebCore/html/HTMLLinkElement.cpp74
-rw-r--r--WebCore/html/HTMLLinkElement.h30
-rw-r--r--WebCore/html/HTMLMediaElement.cpp17
-rw-r--r--WebCore/html/HTMLMeterElement.cpp166
-rw-r--r--WebCore/html/HTMLMeterElement.h66
-rw-r--r--WebCore/html/HTMLMeterElement.idl38
-rw-r--r--WebCore/html/HTMLTagNames.in1
-rw-r--r--WebCore/html/canvas/ArrayBuffer.cpp (renamed from WebCore/html/canvas/WebGLArrayBuffer.cpp)22
-rw-r--r--WebCore/html/canvas/ArrayBuffer.h (renamed from WebCore/html/canvas/WebGLArrayBuffer.h)18
-rw-r--r--WebCore/html/canvas/ArrayBuffer.idl (renamed from WebCore/html/canvas/WebGLArrayBuffer.idl)2
-rw-r--r--WebCore/html/canvas/ArrayBufferView.cpp (renamed from WebCore/html/canvas/WebGLArray.cpp)12
-rw-r--r--WebCore/html/canvas/ArrayBufferView.h (renamed from WebCore/html/canvas/WebGLArray.h)39
-rw-r--r--WebCore/html/canvas/ArrayBufferView.idl (renamed from WebCore/html/canvas/WebGLArray.idl)6
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext2D.cpp47
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext2D.h1
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext2D.idl7
-rw-r--r--WebCore/html/canvas/FloatArray.cpp62
-rw-r--r--WebCore/html/canvas/FloatArray.h (renamed from WebCore/html/canvas/WebGLFloatArray.h)64
-rw-r--r--WebCore/html/canvas/FloatArray.idl (renamed from WebCore/html/canvas/WebGLFloatArray.idl)6
-rw-r--r--WebCore/html/canvas/Int16Array.cpp61
-rw-r--r--WebCore/html/canvas/Int16Array.h58
-rw-r--r--WebCore/html/canvas/Int16Array.idl (renamed from WebCore/html/canvas/WebGLShortArray.idl)6
-rw-r--r--WebCore/html/canvas/Int32Array.cpp (renamed from WebCore/html/canvas/WebGLUnsignedIntArray.idl)50
-rw-r--r--WebCore/html/canvas/Int32Array.h57
-rw-r--r--WebCore/html/canvas/Int32Array.idl (renamed from WebCore/html/canvas/WebGLIntArray.idl)6
-rw-r--r--WebCore/html/canvas/Int8Array.cpp62
-rw-r--r--WebCore/html/canvas/Int8Array.h59
-rw-r--r--WebCore/html/canvas/Int8Array.idl (renamed from WebCore/html/canvas/WebGLByteArray.idl)6
-rw-r--r--WebCore/html/canvas/IntegralTypedArrayBase.h72
-rw-r--r--WebCore/html/canvas/TypedArrayBase.h111
-rw-r--r--WebCore/html/canvas/Uint16Array.cpp62
-rw-r--r--WebCore/html/canvas/Uint16Array.h59
-rw-r--r--WebCore/html/canvas/Uint16Array.idl (renamed from WebCore/html/canvas/WebGLUnsignedByteArray.idl)8
-rw-r--r--WebCore/html/canvas/Uint32Array.cpp62
-rw-r--r--WebCore/html/canvas/Uint32Array.h59
-rw-r--r--WebCore/html/canvas/Uint32Array.idl (renamed from WebCore/html/canvas/WebGLUnsignedShortArray.idl)6
-rw-r--r--WebCore/html/canvas/Uint8Array.cpp62
-rw-r--r--WebCore/html/canvas/Uint8Array.h59
-rw-r--r--WebCore/html/canvas/Uint8Array.idl40
-rw-r--r--WebCore/html/canvas/WebGLBuffer.cpp6
-rw-r--r--WebCore/html/canvas/WebGLBuffer.h10
-rw-r--r--WebCore/html/canvas/WebGLByteArray.cpp87
-rw-r--r--WebCore/html/canvas/WebGLByteArray.h100
-rw-r--r--WebCore/html/canvas/WebGLFloatArray.cpp86
-rw-r--r--WebCore/html/canvas/WebGLGetInfo.cpp18
-rw-r--r--WebCore/html/canvas/WebGLGetInfo.h24
-rw-r--r--WebCore/html/canvas/WebGLIntArray.cpp89
-rw-r--r--WebCore/html/canvas/WebGLIntArray.h97
-rw-r--r--WebCore/html/canvas/WebGLRenderingContext.cpp207
-rw-r--r--WebCore/html/canvas/WebGLRenderingContext.h53
-rw-r--r--WebCore/html/canvas/WebGLRenderingContext.idl40
-rw-r--r--WebCore/html/canvas/WebGLShortArray.cpp88
-rw-r--r--WebCore/html/canvas/WebGLShortArray.h94
-rw-r--r--WebCore/html/canvas/WebGLTexture.cpp147
-rw-r--r--WebCore/html/canvas/WebGLTexture.h26
-rw-r--r--WebCore/html/canvas/WebGLUnsignedByteArray.cpp89
-rw-r--r--WebCore/html/canvas/WebGLUnsignedByteArray.h95
-rw-r--r--WebCore/html/canvas/WebGLUnsignedIntArray.cpp89
-rw-r--r--WebCore/html/canvas/WebGLUnsignedIntArray.h95
-rw-r--r--WebCore/html/canvas/WebGLUnsignedShortArray.cpp91
-rw-r--r--WebCore/html/canvas/WebGLUnsignedShortArray.h96
78 files changed, 2100 insertions, 1499 deletions
diff --git a/WebCore/html/FileError.idl b/WebCore/html/FileError.idl
index 6c2b08c..adc25e8 100644
--- a/WebCore/html/FileError.idl
+++ b/WebCore/html/FileError.idl
@@ -32,8 +32,10 @@ module html {
interface [
Conditional=FILE_READER|FILE_WRITER
] FileError {
+#if !defined(LANGUAGE_OBJECTIVE_C)
const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
const unsigned short NOT_FOUND_ERR = 8;
+#endif
const unsigned short SECURITY_ERR = 18;
const unsigned short ABORT_ERR = 20;
const unsigned short NOT_READABLE_ERR = 24;
diff --git a/WebCore/html/FileReader.idl b/WebCore/html/FileReader.idl
new file mode 100644
index 0000000..b933f51
--- /dev/null
+++ b/WebCore/html/FileReader.idl
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 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 [
+ Conditional=FILE_READER,
+ CanBeConstructed,
+ CallWith=ScriptExecutionContext,
+ EventTarget,
+ NoStaticTables
+ ] FileReader {
+ // ready states
+ const unsigned short EMPTY = 0;
+ const unsigned short LOADING = 1;
+ const unsigned short DONE = 2;
+ readonly attribute unsigned short readyState;
+
+ // async read methods
+ void readAsBinaryString(in Blob fileBlob);
+ void readAsText(in Blob fileBlob, in [Optional] DOMString encoding);
+ void readAsDataURL(in File file);
+
+ void abort();
+
+ // file data
+ readonly attribute [ConvertScriptString] DOMString result;
+
+ readonly attribute FileError error;
+
+ attribute EventListener onloadstart;
+ attribute EventListener onprogress;
+ attribute EventListener onload;
+ attribute EventListener onabort;
+ attribute EventListener onerror;
+ attribute EventListener onloadend;
+ };
+}
diff --git a/WebCore/html/FileThreadTask.h b/WebCore/html/FileThreadTask.h
index f4c59d8..baf0888 100644
--- a/WebCore/html/FileThreadTask.h
+++ b/WebCore/html/FileThreadTask.h
@@ -184,6 +184,10 @@ private:
PassOwnPtr<FileThread::Task> createFileThreadTask(
FileStream* const callee,
+ void (FileStream::*method)());
+
+PassOwnPtr<FileThread::Task> createFileThreadTask(
+ FileStream* const callee,
void (FileStream::*method)())
{
return FileThreadTask0::create(
diff --git a/WebCore/html/HTMLAttributeNames.in b/WebCore/html/HTMLAttributeNames.in
index 7a353b2..7cde32f 100644
--- a/WebCore/html/HTMLAttributeNames.in
+++ b/WebCore/html/HTMLAttributeNames.in
@@ -98,6 +98,7 @@ frameborder
headers
height
hidden
+high
href
hreflang
hspace
@@ -115,6 +116,7 @@ link
list
longdesc
loop
+low
playcount
loopend
loopstart
@@ -219,6 +221,7 @@ onwebkitanimationend
onwebkitbeginfullscreen
onwebkitendfullscreen
onwebkittransitionend
+optimum
pattern
placeholder
pluginurl
diff --git a/WebCore/html/HTMLElement.cpp b/WebCore/html/HTMLElement.cpp
index f2ffc16..77aa93b 100644
--- a/WebCore/html/HTMLElement.cpp
+++ b/WebCore/html/HTMLElement.cpp
@@ -861,6 +861,7 @@ static HashSet<AtomicStringImpl*>* inlineTagList()
#if ENABLE(PROGRESS_TAG)
tagList.add(progressTag.localName().impl());
#endif
+ tagList.add(meterTag.localName().impl());
}
return &tagList;
}
diff --git a/WebCore/html/HTMLElementsAllInOne.cpp b/WebCore/html/HTMLElementsAllInOne.cpp
index 4cee927..f19addf 100644
--- a/WebCore/html/HTMLElementsAllInOne.cpp
+++ b/WebCore/html/HTMLElementsAllInOne.cpp
@@ -77,6 +77,7 @@
#include "HTMLMediaElement.cpp"
#include "HTMLMenuElement.cpp"
#include "HTMLMetaElement.cpp"
+#include "HTMLMeterElement.cpp"
#include "HTMLModElement.cpp"
#include "HTMLOListElement.cpp"
#include "HTMLObjectElement.cpp"
diff --git a/WebCore/html/HTMLFormControlElement.cpp b/WebCore/html/HTMLFormControlElement.cpp
index 7ae33d3..5512236 100644
--- a/WebCore/html/HTMLFormControlElement.cpp
+++ b/WebCore/html/HTMLFormControlElement.cpp
@@ -25,6 +25,7 @@
#include "config.h"
#include "HTMLFormControlElement.h"
+#include "CharacterNames.h"
#include "Chrome.h"
#include "ChromeClient.h"
#include "Document.h"
@@ -44,6 +45,7 @@
#include "RenderTheme.h"
#include "ScriptEventListener.h"
#include "ValidityState.h"
+#include <wtf/Vector.h>
namespace WebCore {
@@ -189,8 +191,8 @@ void HTMLFormControlElement::removedFromTree(bool deep)
const AtomicString& HTMLFormControlElement::formControlName() const
{
- const AtomicString& n = getAttribute(nameAttr);
- return n.isNull() ? emptyAtom : n;
+ const AtomicString& name = fastGetAttribute(nameAttr);
+ return name.isNull() ? emptyAtom : name;
}
void HTMLFormControlElement::setName(const AtomicString &value)
@@ -400,6 +402,16 @@ void HTMLFormControlElement::removeFromForm()
m_form = 0;
}
+bool HTMLFormControlElement::isLabelable() const
+{
+ // FIXME: Add meterTag and outputTag to the list once we support them.
+ return hasTagName(buttonTag) || hasTagName(inputTag) || hasTagName(keygenTag)
+#if ENABLE(PROGRESS_TAG)
+ || hasTagName(progressTag)
+#endif
+ || hasTagName(selectTag) || hasTagName(textareaTag);
+}
+
HTMLFormControlElementWithState::HTMLFormControlElementWithState(const QualifiedName& tagName, Document* doc, HTMLFormElement* f)
: HTMLFormControlElement(tagName, doc, f)
{
@@ -489,12 +501,40 @@ void HTMLTextFormControlElement::dispatchBlurEvent()
HTMLFormControlElementWithState::dispatchBlurEvent();
}
+String HTMLTextFormControlElement::strippedPlaceholder() const
+{
+ // According to the HTML5 specification, we need to remove CR and LF from
+ // the attribute value.
+ const AtomicString& attributeValue = getAttribute(placeholderAttr);
+ if (!attributeValue.contains(newlineCharacter) && !attributeValue.contains(carriageReturn))
+ return attributeValue;
+
+ Vector<UChar> stripped;
+ unsigned length = attributeValue.length();
+ stripped.reserveCapacity(length);
+ for (unsigned i = 0; i < length; ++i) {
+ UChar character = attributeValue[i];
+ if (character == newlineCharacter || character == carriageReturn)
+ continue;
+ stripped.append(character);
+ }
+ return String::adopt(stripped);
+}
+
+static bool isNotLineBreak(UChar ch) { return ch != newlineCharacter && ch != carriageReturn; }
+
+bool HTMLTextFormControlElement::isPlaceholderEmpty() const
+{
+ const AtomicString& attributeValue = getAttribute(placeholderAttr);
+ return attributeValue.string().find(isNotLineBreak) == -1;
+}
+
bool HTMLTextFormControlElement::placeholderShouldBeVisible() const
{
return supportsPlaceholder()
&& isEmptyValue()
&& document()->focusedNode() != this
- && !getAttribute(placeholderAttr).isEmpty();
+ && !isPlaceholderEmpty();
}
void HTMLTextFormControlElement::updatePlaceholderVisibility(bool placeholderValueChanged)
diff --git a/WebCore/html/HTMLFormControlElement.h b/WebCore/html/HTMLFormControlElement.h
index 5b3a490..5c13d24 100644
--- a/WebCore/html/HTMLFormControlElement.h
+++ b/WebCore/html/HTMLFormControlElement.h
@@ -94,6 +94,7 @@ public:
virtual bool isFormControlElement() const { return true; }
virtual bool isRadioButton() const { return false; }
+ virtual bool canTriggerImplicitSubmission() const { return false; }
/* Override in derived classes to get the encoded name=value pair for submitting.
* Return true for a successful control (see HTML4-17.13.2).
@@ -121,6 +122,8 @@ public:
virtual void dispatchFocusEvent();
virtual void dispatchBlurEvent();
+ bool isLabelable() const;
+
protected:
void removeFromForm();
// This must be called any time the result of willValidate() has changed.
@@ -170,6 +173,8 @@ public:
virtual void dispatchFocusEvent();
virtual void dispatchBlurEvent();
+ String strippedPlaceholder() const;
+
int selectionStart();
int selectionEnd();
void setSelectionStart(int);
@@ -179,6 +184,7 @@ public:
VisibleSelection selection() const;
protected:
+ bool isPlaceholderEmpty() const;
bool placeholderShouldBeVisible() const;
void updatePlaceholderVisibility(bool);
virtual int cachedSelectionStart() const = 0;
diff --git a/WebCore/html/HTMLFormElement.cpp b/WebCore/html/HTMLFormElement.cpp
index d7f5d96..7c58364 100644
--- a/WebCore/html/HTMLFormElement.cpp
+++ b/WebCore/html/HTMLFormElement.cpp
@@ -176,21 +176,20 @@ Node* HTMLFormElement::item(unsigned index)
return elements()->item(index);
}
-void HTMLFormElement::submitImplicitly(Event* event, bool fromTextField)
+void HTMLFormElement::submitImplicitly(Event* event, bool fromImplicitSubmissionTrigger)
{
- int textControlCount = 0;
+ int submissionTriggerCount = 0;
for (unsigned i = 0; i < formElements.size(); ++i) {
- if (formElements[i]->hasLocalName(inputTag)) {
- HTMLInputElement* element = static_cast<HTMLInputElement*>(formElements[i]);
- if (element->isSuccessfulSubmitButton() && element->renderer()) {
- element->dispatchSimulatedClick(event);
+ HTMLFormControlElement* formElement = formElements[i];
+ if (formElement->isSuccessfulSubmitButton()) {
+ if (formElement->renderer()) {
+ formElement->dispatchSimulatedClick(event);
return;
- } else if (element->isTextField())
- ++textControlCount;
- } else if (formElements[i]->hasLocalName(isindexTag))
- ++textControlCount;
+ }
+ } else if (formElement->canTriggerImplicitSubmission())
+ ++submissionTriggerCount;
}
- if (fromTextField && textControlCount == 1)
+ if (fromImplicitSubmissionTrigger && submissionTriggerCount == 1)
prepareSubmit(event);
}
diff --git a/WebCore/html/HTMLFormElement.h b/WebCore/html/HTMLFormElement.h
index a2142ec..68aebdf 100644
--- a/WebCore/html/HTMLFormElement.h
+++ b/WebCore/html/HTMLFormElement.h
@@ -91,7 +91,7 @@ public:
virtual bool isURLAttribute(Attribute*) const;
- void submitImplicitly(Event*, bool fromTextField);
+ void submitImplicitly(Event*, bool fromImplicitSubmissionTrigger);
bool formWouldHaveSecureSubmission(const String& url);
String name() const;
diff --git a/WebCore/html/HTMLFrameElementBase.cpp b/WebCore/html/HTMLFrameElementBase.cpp
index 76f3ed4..c30b74f 100644
--- a/WebCore/html/HTMLFrameElementBase.cpp
+++ b/WebCore/html/HTMLFrameElementBase.cpp
@@ -242,8 +242,12 @@ bool HTMLFrameElementBase::supportsFocus() const
void HTMLFrameElementBase::setFocus(bool received)
{
HTMLFrameOwnerElement::setFocus(received);
- if (Page* page = document()->page())
- page->focusController()->setFocusedFrame(received ? contentFrame() : 0);
+ if (Page* page = document()->page()) {
+ if (received)
+ page->focusController()->setFocusedFrame(contentFrame());
+ else if (page->focusController()->focusedFrame() == contentFrame()) // Focus may have already been given to another frame, don't take it away.
+ page->focusController()->setFocusedFrame(0);
+ }
}
bool HTMLFrameElementBase::isURLAttribute(Attribute *attr) const
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index bbc9f43..31d2cc2 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -751,9 +751,6 @@ bool HTMLInputElement::shouldUseInputMethod() const
void HTMLInputElement::handleFocusEvent()
{
InputElement::dispatchFocusEvent(this, this);
-
- if (isTextField())
- m_autofilled = false;
}
void HTMLInputElement::handleBlurEvent()
@@ -1432,6 +1429,7 @@ void HTMLInputElement::setChecked(bool nowChecked, bool sendChangeEvent)
m_useDefaultChecked = false;
m_checked = nowChecked;
+ setNeedsValidityCheck();
setNeedsStyleRecalc();
updateCheckedRadioButtons();
@@ -1495,7 +1493,7 @@ String HTMLInputElement::value() const
String value = m_data.value();
if (value.isNull()) {
- value = sanitizeValue(getAttribute(valueAttr));
+ value = sanitizeValue(fastGetAttribute(valueAttr));
// If no attribute exists, extra handling may be necessary.
// For Checkbox Types just use "on" or "" based off the checked() state of the control.
@@ -1950,6 +1948,9 @@ void HTMLInputElement::setValueFromRenderer(const String& value)
updatePlaceholderVisibility(false);
InputElement::setValueFromRenderer(m_data, this, this, value);
setNeedsValidityCheck();
+
+ // Clear autofill flag (and yellow background) on user edit.
+ setAutofilled(false);
}
void HTMLInputElement::setFileListFromRenderer(const Vector<String>& paths)
@@ -2353,7 +2354,7 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
// Form may never have been present, or may have been destroyed by code responding to the change event.
if (formForSubmission)
- formForSubmission->submitImplicitly(evt, isTextField());
+ formForSubmission->submitImplicitly(evt, canTriggerImplicitSubmission());
evt->setDefaultHandled();
return;
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index e717628..96fb492 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -131,6 +131,7 @@ public:
virtual bool isInputTypeHidden() const { return m_type == HIDDEN; }
virtual bool isPasswordField() const { return m_type == PASSWORD; }
virtual bool hasSpinButton() const { return m_type == NUMBER || m_type == DATE || m_type == DATETIME || m_type == DATETIMELOCAL || m_type == MONTH || m_type == TIME || m_type == WEEK; }
+ virtual bool canTriggerImplicitSubmission() const { return isTextField(); }
bool checked() const { return m_checked; }
void setChecked(bool, bool sendChangeEvent = false);
diff --git a/WebCore/html/HTMLIsIndexElement.h b/WebCore/html/HTMLIsIndexElement.h
index a1462b8..ad56079 100644
--- a/WebCore/html/HTMLIsIndexElement.h
+++ b/WebCore/html/HTMLIsIndexElement.h
@@ -33,6 +33,7 @@ public:
virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
virtual int tagPriority() const { return 0; }
+ virtual bool canTriggerImplicitSubmission() const { return true; }
virtual void parseMappedAttribute(MappedAttribute *attr);
diff --git a/WebCore/html/HTMLLabelElement.cpp b/WebCore/html/HTMLLabelElement.cpp
index 645017d..893106c 100644
--- a/WebCore/html/HTMLLabelElement.cpp
+++ b/WebCore/html/HTMLLabelElement.cpp
@@ -28,6 +28,7 @@
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
+#include "HTMLFormControlElement.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
@@ -35,6 +36,18 @@ namespace WebCore {
using namespace HTMLNames;
+static HTMLFormControlElement* nodeAsLabelableFormControl(Node* node)
+{
+ if (!node || !node->isHTMLElement() || !static_cast<HTMLElement*>(node)->isFormControlElement())
+ return 0;
+
+ HTMLFormControlElement* formControlElement = static_cast<HTMLFormControlElement*>(node);
+ if (!formControlElement->isLabelable())
+ return 0;
+
+ return formControlElement;
+}
+
HTMLLabelElement::HTMLLabelElement(const QualifiedName& tagName, Document *doc)
: HTMLElement(tagName, doc)
{
@@ -50,27 +63,24 @@ bool HTMLLabelElement::isFocusable() const
return false;
}
-HTMLElement* HTMLLabelElement::correspondingControl()
+HTMLFormControlElement* HTMLLabelElement::control()
{
const AtomicString& controlId = getAttribute(forAttr);
if (controlId.isNull()) {
- // Search children of the label element for a form element.
+ // Search the children and descendants of the label element for a form element.
+ // per http://dev.w3.org/html5/spec/Overview.html#the-label-element
+ // the form element must be "labelable form-associated element".
Node* node = this;
while ((node = node->traverseNextNode(this))) {
- if (node->isHTMLElement()) {
- HTMLElement* element = static_cast<HTMLElement*>(node);
- if (element->isFormControlElement())
- return element;
- }
+ if (HTMLFormControlElement* formControlElement = nodeAsLabelableFormControl(node))
+ return formControlElement;
}
return 0;
}
-
- // Only return HTML elements.
- Element* elt = document()->getElementById(controlId);
- if (elt && elt->isHTMLElement())
- return static_cast<HTMLElement*>(elt);
- return 0;
+
+ // Find the first element whose id is controlId. If it is found and it is a labelable form control,
+ // return it, otherwise return 0.
+ return nodeAsLabelableFormControl(document()->getElementById(controlId));
}
void HTMLLabelElement::setActive(bool down, bool pause)
@@ -82,7 +92,7 @@ void HTMLLabelElement::setActive(bool down, bool pause)
HTMLElement::setActive(down, pause);
// Also update our corresponding control.
- if (HTMLElement* element = correspondingControl())
+ if (HTMLElement* element = control())
element->setActive(down, pause);
}
@@ -95,7 +105,7 @@ void HTMLLabelElement::setHovered(bool over)
HTMLElement::setHovered(over);
// Also update our corresponding control.
- if (HTMLElement* element = correspondingControl())
+ if (HTMLElement* element = control())
element->setHovered(over);
}
@@ -104,21 +114,21 @@ void HTMLLabelElement::defaultEventHandler(Event* evt)
static bool processingClick = false;
if (evt->type() == eventNames().clickEvent && !processingClick) {
- RefPtr<HTMLElement> control = correspondingControl();
+ RefPtr<HTMLElement> element = control();
// If we can't find a control or if the control received the click
// event, then there's no need for us to do anything.
- if (!control || (evt->target() && control->contains(evt->target()->toNode())))
+ if (!element || (evt->target() && element->contains(evt->target()->toNode())))
return;
processingClick = true;
// Click the corresponding control.
- control->dispatchSimulatedClick(evt);
+ element->dispatchSimulatedClick(evt);
// If the control can be focused via the mouse, then do that too.
- if (control->isMouseFocusable())
- control->focus();
+ if (element->isMouseFocusable())
+ element->focus();
processingClick = false;
@@ -131,13 +141,13 @@ void HTMLLabelElement::defaultEventHandler(Event* evt)
void HTMLLabelElement::focus(bool)
{
// to match other browsers, always restore previous selection
- if (HTMLElement* element = correspondingControl())
+ if (HTMLElement* element = control())
element->focus();
}
void HTMLLabelElement::accessKeyAction(bool sendToAnyElement)
{
- if (HTMLElement* element = correspondingControl())
+ if (HTMLElement* element = control())
element->accessKeyAction(sendToAnyElement);
else
HTMLElement::accessKeyAction(sendToAnyElement);
diff --git a/WebCore/html/HTMLLabelElement.h b/WebCore/html/HTMLLabelElement.h
index 6331da5..48622f9 100644
--- a/WebCore/html/HTMLLabelElement.h
+++ b/WebCore/html/HTMLLabelElement.h
@@ -25,6 +25,7 @@
#define HTMLLabelElement_h
#include "HTMLElement.h"
+#include "HTMLFormControlElement.h"
namespace WebCore {
@@ -46,7 +47,7 @@ public:
// Overridden to either click() or focus() the corresponding control.
virtual void defaultEventHandler(Event*);
- HTMLElement* correspondingControl();
+ HTMLFormControlElement* control();
String accessKey() const;
void setAccessKey(const String&);
diff --git a/WebCore/html/HTMLLabelElement.idl b/WebCore/html/HTMLLabelElement.idl
index 3b25fa9..dddc89c 100644
--- a/WebCore/html/HTMLLabelElement.idl
+++ b/WebCore/html/HTMLLabelElement.idl
@@ -24,6 +24,7 @@ module html {
readonly attribute HTMLFormElement form;
attribute [ConvertNullToNullString] DOMString accessKey;
attribute [ConvertNullToNullString] DOMString htmlFor;
+ readonly attribute HTMLElement control;
};
}
diff --git a/WebCore/html/HTMLLinkElement.cpp b/WebCore/html/HTMLLinkElement.cpp
index cf9419f..e57e0b0 100644
--- a/WebCore/html/HTMLLinkElement.cpp
+++ b/WebCore/html/HTMLLinkElement.cpp
@@ -52,7 +52,7 @@ using namespace HTMLNames;
HTMLLinkElement::HTMLLinkElement(const QualifiedName& qName, Document *doc, bool createdByParser)
: HTMLElement(qName, doc)
, m_cachedSheet(0)
- , m_disabledState(0)
+ , m_disabledState(Unset)
, m_loading(false)
, m_createdByParser(createdByParser)
, m_timer(this, &HTMLLinkElement::timerFired)
@@ -71,8 +71,8 @@ HTMLLinkElement::~HTMLLinkElement()
void HTMLLinkElement::setDisabledState(bool _disabled)
{
- int oldDisabledState = m_disabledState;
- m_disabledState = _disabled ? 2 : 1;
+ DisabledState oldDisabledState = m_disabledState;
+ m_disabledState = _disabled ? Disabled : EnabledViaScript;
if (oldDisabledState != m_disabledState) {
// If we change the disabled state while the sheet is still loading, then we have to
// perform three checks:
@@ -80,11 +80,19 @@ void HTMLLinkElement::setDisabledState(bool _disabled)
// Check #1: If the sheet becomes disabled while it was loading, and if it was either
// a main sheet or a sheet that was previously enabled via script, then we need
// to remove it from the list of pending sheets.
+<<<<<<< HEAD
if (m_disabledState == 2 && (!m_rel.m_isAlternate || oldDisabledState == 1))
document()->removePendingSheet();
// Check #2: An alternate sheet becomes enabled while it is still loading.
if (m_rel.m_isAlternate && m_disabledState == 1)
+=======
+ if (m_disabledState == Disabled && (!m_relAttribute.m_isAlternate || oldDisabledState == EnabledViaScript))
+ document()->removePendingSheet();
+
+ // Check #2: An alternate sheet becomes enabled while it is still loading.
+ if (m_relAttribute.m_isAlternate && m_disabledState == EnabledViaScript)
+>>>>>>> webkit.org at r59636
document()->addPendingSheet();
// Check #3: A main sheet becomes enabled while it was still loading and
@@ -92,7 +100,11 @@ void HTMLLinkElement::setDisabledState(bool _disabled)
// happen (a double toggle for no reason essentially). This happens on
// virtualplastic.net, which manages to do about 12 enable/disables on only 3
// sheets. :)
+<<<<<<< HEAD
if (!m_rel.m_isAlternate && m_disabledState == 1 && oldDisabledState == 2)
+=======
+ if (!m_relAttribute.m_isAlternate && m_disabledState == EnabledViaScript && oldDisabledState == Disabled)
+>>>>>>> webkit.org at r59636
document()->addPendingSheet();
// If the sheet is already loading just bail.
@@ -100,7 +112,7 @@ void HTMLLinkElement::setDisabledState(bool _disabled)
}
// Load the sheet, since it's never been loaded before.
- if (!m_sheet && m_disabledState == 1)
+ if (!m_sheet && m_disabledState == EnabledViaScript)
process();
else
document()->updateStyleSelector(); // Update the style selector.
@@ -115,7 +127,11 @@ StyleSheet* HTMLLinkElement::sheet() const
void HTMLLinkElement::parseMappedAttribute(MappedAttribute *attr)
{
if (attr->name() == relAttr) {
+<<<<<<< HEAD
tokenizeRelAttribute(attr->value(), m_rel);
+=======
+ tokenizeRelAttribute(attr->value(), m_relAttribute);
+>>>>>>> webkit.org at r59636
process();
} else if (attr->name() == hrefAttr) {
m_url = document()->completeURL(deprecatedParseURL(attr->value()));
@@ -126,9 +142,13 @@ void HTMLLinkElement::parseMappedAttribute(MappedAttribute *attr)
} else if (attr->name() == mediaAttr) {
m_media = attr->value().string().lower();
process();
- } else if (attr->name() == disabledAttr) {
+ } else if (attr->name() == disabledAttr)
setDisabledState(!attr->isNull());
+<<<<<<< HEAD
} else if (attr->name() == onbeforeloadAttr) {
+=======
+ else if (attr->name() == onbeforeloadAttr)
+>>>>>>> webkit.org at r59636
setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
} else if (attr->name() == onloadAttr) {
setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
@@ -139,6 +159,7 @@ void HTMLLinkElement::parseMappedAttribute(MappedAttribute *attr)
}
}
+<<<<<<< HEAD
void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, RelAttribute& attribute)
{
attribute.m_isStyleSheet = false;
@@ -171,6 +192,23 @@ void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, RelAttribute
else if (equalIgnoringCase(rel, "alternate stylesheet") || equalIgnoringCase(rel, "stylesheet alternate")) {
attribute.m_isStyleSheet = true;
attribute.m_isAlternate = true;
+=======
+void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, RelAttribute& relAttribute)
+{
+ relAttribute.m_isStyleSheet = false;
+ relAttribute.m_isIcon = false;
+ relAttribute.m_isAlternate = false;
+ relAttribute.m_isDNSPrefetch = false;
+ if (equalIgnoringCase(rel, "stylesheet"))
+ relAttribute.m_isStyleSheet = true;
+ else if (equalIgnoringCase(rel, "icon") || equalIgnoringCase(rel, "shortcut icon"))
+ relAttribute.m_isIcon = true;
+ else if (equalIgnoringCase(rel, "dns-prefetch"))
+ relAttribute.m_isDNSPrefetch = true;
+ else if (equalIgnoringCase(rel, "alternate stylesheet") || equalIgnoringCase(rel, "stylesheet alternate")) {
+ relAttribute.m_isStyleSheet = true;
+ relAttribute.m_isAlternate = true;
+>>>>>>> webkit.org at r59636
} else {
// Tokenize the rel attribute and set bits based on specific keywords that we find.
String relString = rel.string();
@@ -180,11 +218,19 @@ void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, RelAttribute
Vector<String>::const_iterator end = list.end();
for (Vector<String>::const_iterator it = list.begin(); it != end; ++it) {
if (equalIgnoringCase(*it, "stylesheet"))
+<<<<<<< HEAD
attribute.m_isStyleSheet = true;
else if (equalIgnoringCase(*it, "alternate"))
attribute.m_isAlternate = true;
else if (equalIgnoringCase(*it, "icon"))
attribute.m_isIcon = true;
+=======
+ relAttribute.m_isStyleSheet = true;
+ else if (equalIgnoringCase(*it, "alternate"))
+ relAttribute.m_isAlternate = true;
+ else if (equalIgnoringCase(*it, "icon"))
+ relAttribute.m_isIcon = true;
+>>>>>>> webkit.org at r59636
}
}
}
@@ -198,6 +244,7 @@ void HTMLLinkElement::process()
// IE extension: location of small icon for locationbar / bookmarks
// We'll record this URL per document, even if we later only use it in top level frames
+<<<<<<< HEAD
if (m_rel.m_isIcon && m_url.isValid() && !m_url.isEmpty())
document()->setIconURL(m_url.string(), type);
@@ -210,6 +257,12 @@ void HTMLLinkElement::process()
#endif
if (m_rel.m_isDNSPrefetch && m_url.isValid() && !m_url.isEmpty())
+=======
+ if (m_relAttribute.m_isIcon && m_url.isValid() && !m_url.isEmpty())
+ document()->setIconURL(m_url.string(), type);
+
+ if (m_relAttribute.m_isDNSPrefetch && m_url.isValid() && !m_url.isEmpty())
+>>>>>>> webkit.org at r59636
ResourceHandle::prepareForURL(m_url);
#if ENABLE(LINK_PREFETCH)
@@ -226,7 +279,11 @@ void HTMLLinkElement::process()
// Stylesheet
// This was buggy and would incorrectly match <link rel="alternate">, which has a different specified meaning. -dwh
+<<<<<<< HEAD
if (m_disabledState != 2 && (m_rel.m_isStyleSheet || (acceptIfTypeContainsTextCSS && type.contains("text/css"))) && document()->frame() && m_url.isValid()) {
+=======
+ if (m_disabledState != Disabled && (m_relAttribute.m_isStyleSheet || (acceptIfTypeContainsTextCSS && type.contains("text/css"))) && document()->frame() && m_url.isValid()) {
+>>>>>>> webkit.org at r59636
// also, don't load style sheets for standalone documents
String charset = getAttribute(charsetAttr);
@@ -480,10 +537,17 @@ void HTMLLinkElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
HTMLElement::addSubresourceAttributeURLs(urls);
// Favicons are handled by a special case in LegacyWebArchive::create()
+<<<<<<< HEAD
if (m_rel.m_isIcon)
return;
if (!m_rel.m_isStyleSheet)
+=======
+ if (m_relAttribute.m_isIcon)
+ return;
+
+ if (!m_relAttribute.m_isStyleSheet)
+>>>>>>> webkit.org at r59636
return;
// Append the URL of this link element.
diff --git a/WebCore/html/HTMLLinkElement.h b/WebCore/html/HTMLLinkElement.h
index 7ff47dc..aa7e454 100644
--- a/WebCore/html/HTMLLinkElement.h
+++ b/WebCore/html/HTMLLinkElement.h
@@ -42,6 +42,7 @@ public:
bool m_isIcon;
bool m_isAlternate;
bool m_isDNSPrefetch;
+<<<<<<< HEAD
#ifdef ANDROID_APPLE_TOUCH_ICON
bool m_isTouchIcon;
bool m_isPrecomposedTouchIcon;
@@ -58,6 +59,10 @@ public:
, m_isLinkPrefetch(false)
#endif
{ };
+=======
+
+ RelAttribute() : m_isStyleSheet(false), m_isIcon(false), m_isAlternate(false), m_isDNSPrefetch(false) { }
+>>>>>>> webkit.org at r59636
};
HTMLLinkElement(const QualifiedName&, Document*, bool createdByParser);
@@ -110,17 +115,27 @@ public:
bool isLoading() const;
virtual bool sheetLoaded();
+<<<<<<< HEAD
bool isAlternate() const { return m_disabledState == 0 && m_rel.m_isAlternate; }
bool isDisabled() const { return m_disabledState == 2; }
bool isEnabledViaScript() const { return m_disabledState == 1; }
bool isIcon() const { return m_rel.m_isIcon; }
+=======
+ bool isAlternate() const { return m_disabledState == Unset && m_relAttribute.m_isAlternate; }
+ bool isDisabled() const { return m_disabledState == Disabled; }
+ bool isEnabledViaScript() const { return m_disabledState == EnabledViaScript; }
+ bool isIcon() const { return m_relAttribute.m_isIcon; }
+>>>>>>> webkit.org at r59636
- int disabledState() { return m_disabledState; }
void setDisabledState(bool _disabled);
virtual bool isURLAttribute(Attribute*) const;
+<<<<<<< HEAD
static void tokenizeRelAttribute(const AtomicString& value, RelAttribute& attribute);
+=======
+ static void tokenizeRelAttribute(const AtomicString& value, RelAttribute&);
+>>>>>>> webkit.org at r59636
virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
@@ -135,7 +150,15 @@ public:
#endif
protected:
+<<<<<<< HEAD
void timerFired(Timer<HTMLLinkElement>*);
+=======
+ enum DisabledState {
+ Unset,
+ EnabledViaScript,
+ Disabled
+ };
+>>>>>>> webkit.org at r59636
CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
RefPtr<CSSStyleSheet> m_sheet;
@@ -145,8 +168,13 @@ protected:
KURL m_url;
String m_type;
String m_media;
+<<<<<<< HEAD
int m_disabledState; // 0=unset(default), 1=enabled via script, 2=disabled
RelAttribute m_rel;
+=======
+ DisabledState m_disabledState;
+ RelAttribute m_relAttribute;
+>>>>>>> webkit.org at r59636
bool m_loading;
bool m_createdByParser;
Timer<HTMLLinkElement> m_timer;
diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp
index a0e9302..a08ff45 100644
--- a/WebCore/html/HTMLMediaElement.cpp
+++ b/WebCore/html/HTMLMediaElement.cpp
@@ -136,17 +136,16 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* doc)
HTMLMediaElement::~HTMLMediaElement()
{
- if (m_isWaitingUntilMediaCanStart) {
- if (Page* page = document()->page())
- page->removeMediaCanStartListener(this);
- }
-
+ if (m_isWaitingUntilMediaCanStart)
+ document()->removeMediaCanStartListener(this);
document()->unregisterForDocumentActivationCallbacks(this);
document()->unregisterForMediaVolumeCallbacks(this);
}
void HTMLMediaElement::willMoveToNewOwnerDocument()
{
+ if (m_isWaitingUntilMediaCanStart)
+ document()->removeMediaCanStartListener(this);
document()->unregisterForDocumentActivationCallbacks(this);
document()->unregisterForMediaVolumeCallbacks(this);
HTMLElement::willMoveToNewOwnerDocument();
@@ -154,6 +153,8 @@ void HTMLMediaElement::willMoveToNewOwnerDocument()
void HTMLMediaElement::didMoveToNewOwnerDocument()
{
+ if (m_isWaitingUntilMediaCanStart)
+ document()->addMediaCanStartListener(this);
document()->registerForDocumentActivationCallbacks(this);
document()->registerForMediaVolumeCallbacks(this);
HTMLElement::didMoveToNewOwnerDocument();
@@ -528,7 +529,7 @@ void HTMLMediaElement::loadInternal()
if (page && !page->canStartMedia()) {
if (m_isWaitingUntilMediaCanStart)
return;
- page->addMediaCanStartListener(this);
+ document()->addMediaCanStartListener(this);
m_isWaitingUntilMediaCanStart = true;
return;
}
@@ -2001,21 +2002,21 @@ void HTMLMediaElement::createMediaPlayerProxy()
void HTMLMediaElement::enterFullscreen()
{
ASSERT(!m_isFullscreen);
+ m_isFullscreen = true;
if (document() && document()->page()) {
document()->page()->chrome()->client()->enterFullscreenForNode(this);
scheduleEvent(eventNames().webkitbeginfullscreenEvent);
- m_isFullscreen = true;
}
}
void HTMLMediaElement::exitFullscreen()
{
ASSERT(m_isFullscreen);
+ m_isFullscreen = false;
if (document() && document()->page()) {
document()->page()->chrome()->client()->exitFullscreenForNode(this);
scheduleEvent(eventNames().webkitendfullscreenEvent);
}
- m_isFullscreen = false;
}
PlatformMedia HTMLMediaElement::platformMedia() const
diff --git a/WebCore/html/HTMLMeterElement.cpp b/WebCore/html/HTMLMeterElement.cpp
new file mode 100644
index 0000000..2c1f8a5
--- /dev/null
+++ b/WebCore/html/HTMLMeterElement.cpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#if ENABLE(METER_TAG)
+#include "HTMLMeterElement.h"
+
+#include "EventNames.h"
+#include "FormDataList.h"
+#include "HTMLFormElement.h"
+#include "HTMLNames.h"
+#include "HTMLParser.h"
+#include "MappedAttribute.h"
+#include "RenderMeter.h"
+#include <wtf/StdLibExtras.h>
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+HTMLMeterElement::HTMLMeterElement(const QualifiedName& tagName, Document* document)
+ : HTMLFormControlElement(tagName, document, 0, CreateHTMLElement)
+{
+ ASSERT(hasTagName(meterTag));
+}
+
+PassRefPtr<HTMLMeterElement> HTMLMeterElement::create(const QualifiedName& tagName, Document* document)
+{
+ return adoptRef(new HTMLMeterElement(tagName, document));
+}
+
+RenderObject* HTMLMeterElement::createRenderer(RenderArena* arena, RenderStyle*)
+{
+ return new (arena) RenderMeter(this);
+}
+
+const AtomicString& HTMLMeterElement::formControlType() const
+{
+ DEFINE_STATIC_LOCAL(const AtomicString, meter, ("meter"));
+ return meter;
+}
+
+void HTMLMeterElement::parseMappedAttribute(MappedAttribute* attribute)
+{
+ if (attribute->name() == valueAttr || attribute->name() == minAttr || attribute->name() == maxAttr || attribute->name() == lowAttr || attribute->name() == highAttr || attribute->name() == optimumAttr) {
+ if (renderer())
+ renderer()->updateFromElement();
+ } else
+ HTMLFormControlElement::parseMappedAttribute(attribute);
+}
+
+double HTMLMeterElement::min() const
+{
+ double min = 0;
+ parseToDoubleForNumberType(getAttribute(minAttr), &min);
+ return min;
+}
+
+void HTMLMeterElement::setMin(double min, ExceptionCode& ec)
+{
+ if (!isfinite(min)) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+ setAttribute(minAttr, String::number(min));
+}
+
+double HTMLMeterElement::max() const
+{
+ double max = std::max(1.0, min());
+ parseToDoubleForNumberType(getAttribute(maxAttr), &max);
+ return std::max(max, min());
+}
+
+void HTMLMeterElement::setMax(double max, ExceptionCode& ec)
+{
+ if (!isfinite(max)) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+ setAttribute(maxAttr, String::number(max));
+}
+
+double HTMLMeterElement::value() const
+{
+ double value = 0;
+ parseToDoubleForNumberType(getAttribute(valueAttr), &value);
+ return std::min(std::max(value, min()), max());
+}
+
+void HTMLMeterElement::setValue(double value, ExceptionCode& ec)
+{
+ if (!isfinite(value)) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+ setAttribute(valueAttr, String::number(value));
+}
+
+double HTMLMeterElement::low() const
+{
+ double low = min();
+ parseToDoubleForNumberType(getAttribute(lowAttr), &low);
+ return std::min(std::max(low, min()), max());
+}
+
+void HTMLMeterElement::setLow(double low, ExceptionCode& ec)
+{
+ if (!isfinite(low)) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+ setAttribute(lowAttr, String::number(low));
+}
+
+double HTMLMeterElement::high() const
+{
+ double high = max();
+ parseToDoubleForNumberType(getAttribute(highAttr), &high);
+ return std::min(std::max(high, low()), max());
+}
+
+void HTMLMeterElement::setHigh(double high, ExceptionCode& ec)
+{
+ if (!isfinite(high)) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+ setAttribute(highAttr, String::number(high));
+}
+
+double HTMLMeterElement::optimum() const
+{
+ double optimum = (max() + min()) / 2;
+ parseToDoubleForNumberType(getAttribute(optimumAttr), &optimum);
+ return std::min(std::max(optimum, min()), max());
+}
+
+void HTMLMeterElement::setOptimum(double optimum, ExceptionCode& ec)
+{
+ if (!isfinite(optimum)) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+ setAttribute(optimumAttr, String::number(optimum));
+}
+
+} // namespace
+#endif
diff --git a/WebCore/html/HTMLMeterElement.h b/WebCore/html/HTMLMeterElement.h
new file mode 100644
index 0000000..0808b9f
--- /dev/null
+++ b/WebCore/html/HTMLMeterElement.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef HTMLMeterElement_h
+#define HTMLMeterElement_h
+
+#if ENABLE(METER_TAG)
+#include "HTMLFormControlElement.h"
+
+namespace WebCore {
+
+class HTMLMeterElement : public HTMLFormControlElement {
+public:
+ static PassRefPtr<HTMLMeterElement> create(const QualifiedName&, Document*);
+
+ double min() const;
+ void setMin(double, ExceptionCode&);
+
+ double max() const;
+ void setMax(double, ExceptionCode&);
+
+ double value() const;
+ void setValue(double, ExceptionCode&);
+
+ double low() const;
+ void setLow(double, ExceptionCode&);
+
+ double high() const;
+ void setHigh(double, ExceptionCode&);
+
+ double optimum() const;
+ void setOptimum(double, ExceptionCode&);
+
+private:
+ HTMLMeterElement(const QualifiedName&, Document*);
+
+ virtual bool recalcWillValidate() const { return false; }
+
+ virtual const AtomicString& formControlType() const;
+
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ virtual void parseMappedAttribute(MappedAttribute*);
+};
+
+} // namespace
+
+#endif
+#endif
diff --git a/WebCore/html/HTMLMeterElement.idl b/WebCore/html/HTMLMeterElement.idl
new file mode 100644
index 0000000..e061764
--- /dev/null
+++ b/WebCore/html/HTMLMeterElement.idl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+module html {
+ interface [
+ Conditional=METER_TAG
+ ] HTMLMeterElement : HTMLElement {
+ attribute double value
+ setter raises(DOMException);
+ attribute double min
+ setter raises(DOMException);
+ attribute double max
+ setter raises(DOMException);
+ attribute double low
+ setter raises(DOMException);
+ attribute double high
+ setter raises(DOMException);
+ attribute double optimum
+ setter raises(DOMException);
+ readonly attribute HTMLFormElement form;
+ };
+}
diff --git a/WebCore/html/HTMLTagNames.in b/WebCore/html/HTMLTagNames.in
index 9f4900c..6374b4d 100644
--- a/WebCore/html/HTMLTagNames.in
+++ b/WebCore/html/HTMLTagNames.in
@@ -77,6 +77,7 @@ map createWithNew
marquee createWithNew
menu createWithNew
meta createWithNew
+meter interfaceName=HTMLMeterElement, conditional=METER_TAG
nav interfaceName=HTMLElement
nobr interfaceName=HTMLElement
noembed interfaceName=HTMLElement
diff --git a/WebCore/html/canvas/WebGLArrayBuffer.cpp b/WebCore/html/canvas/ArrayBuffer.cpp
index 7d3cd33..0ba2ffd 100644
--- a/WebCore/html/canvas/WebGLArrayBuffer.cpp
+++ b/WebCore/html/canvas/ArrayBuffer.cpp
@@ -27,52 +27,52 @@
#if ENABLE(3D_CANVAS)
-#include "WebGLArrayBuffer.h"
+#include "ArrayBuffer.h"
#include <wtf/RefPtr.h>
namespace WebCore {
-PassRefPtr<WebGLArrayBuffer> WebGLArrayBuffer::create(unsigned numElements, unsigned elementByteSize)
+PassRefPtr<ArrayBuffer> ArrayBuffer::create(unsigned numElements, unsigned elementByteSize)
{
void* data = tryAllocate(numElements, elementByteSize);
if (!data)
return 0;
- return adoptRef(new WebGLArrayBuffer(data, numElements * elementByteSize));
+ return adoptRef(new ArrayBuffer(data, numElements * elementByteSize));
}
-PassRefPtr<WebGLArrayBuffer> WebGLArrayBuffer::create(WebGLArrayBuffer* other)
+PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBuffer* other)
{
void* data = tryAllocate(other->byteLength(), 1);
if (!data)
return 0;
- RefPtr<WebGLArrayBuffer> buffer = adoptRef(new WebGLArrayBuffer(data, other->byteLength()));
+ RefPtr<ArrayBuffer> buffer = adoptRef(new ArrayBuffer(data, other->byteLength()));
memcpy(buffer->data(), other->data(), other->byteLength());
return buffer.release();
}
-WebGLArrayBuffer::WebGLArrayBuffer(void* data, unsigned sizeInBytes)
+ArrayBuffer::ArrayBuffer(void* data, unsigned sizeInBytes)
: m_sizeInBytes(sizeInBytes)
, m_data(data) {
}
-void* WebGLArrayBuffer::data() {
+void* ArrayBuffer::data() {
return m_data;
}
-const void* WebGLArrayBuffer::data() const {
+const void* ArrayBuffer::data() const {
return m_data;
}
-unsigned WebGLArrayBuffer::byteLength() const {
+unsigned ArrayBuffer::byteLength() const {
return m_sizeInBytes;
}
-WebGLArrayBuffer::~WebGLArrayBuffer() {
+ArrayBuffer::~ArrayBuffer() {
WTF::fastFree(m_data);
}
-void* WebGLArrayBuffer::tryAllocate(unsigned numElements, unsigned elementByteSize) {
+void* ArrayBuffer::tryAllocate(unsigned numElements, unsigned elementByteSize) {
void* result;
// Do not allow 32-bit overflow of the total size
if (numElements) {
diff --git a/WebCore/html/canvas/WebGLArrayBuffer.h b/WebCore/html/canvas/ArrayBuffer.h
index 59e0ddd..f538080 100644
--- a/WebCore/html/canvas/WebGLArrayBuffer.h
+++ b/WebCore/html/canvas/ArrayBuffer.h
@@ -23,28 +23,28 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebGLArrayBuffer_h
-#define WebGLArrayBuffer_h
+#ifndef ArrayBuffer_h
+#define ArrayBuffer_h
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
namespace WebCore {
-class WebGLArrayBuffer : public RefCounted<WebGLArrayBuffer> {
+class ArrayBuffer : public RefCounted<ArrayBuffer> {
public:
- static PassRefPtr<WebGLArrayBuffer> create(unsigned numElements, unsigned elementByteSize);
- static PassRefPtr<WebGLArrayBuffer> create(WebGLArrayBuffer*);
+ static PassRefPtr<ArrayBuffer> create(unsigned numElements, unsigned elementByteSize);
+ static PassRefPtr<ArrayBuffer> create(ArrayBuffer*);
void* data();
const void* data() const;
unsigned byteLength() const;
- ~WebGLArrayBuffer();
+ ~ArrayBuffer();
private:
- WebGLArrayBuffer(void* data, unsigned sizeInBytes);
- WebGLArrayBuffer(unsigned numElements, unsigned elementByteSize);
+ ArrayBuffer(void* data, unsigned sizeInBytes);
+ ArrayBuffer(unsigned numElements, unsigned elementByteSize);
static void* tryAllocate(unsigned numElements, unsigned elementByteSize);
unsigned m_sizeInBytes;
void* m_data;
@@ -52,4 +52,4 @@ class WebGLArrayBuffer : public RefCounted<WebGLArrayBuffer> {
} // namespace WebCore
-#endif // WebGLArrayBuffer_h
+#endif // ArrayBuffer_h
diff --git a/WebCore/html/canvas/WebGLArrayBuffer.idl b/WebCore/html/canvas/ArrayBuffer.idl
index 3325210..3165494 100644
--- a/WebCore/html/canvas/WebGLArrayBuffer.idl
+++ b/WebCore/html/canvas/ArrayBuffer.idl
@@ -24,7 +24,7 @@
*/
module html {
- interface [Conditional=3D_CANVAS, CustomConstructor] WebGLArrayBuffer {
+ interface [Conditional=3D_CANVAS, CustomConstructor] ArrayBuffer {
readonly attribute int byteLength;
};
}
diff --git a/WebCore/html/canvas/WebGLArray.cpp b/WebCore/html/canvas/ArrayBufferView.cpp
index 038aea4..787fd61 100644
--- a/WebCore/html/canvas/WebGLArray.cpp
+++ b/WebCore/html/canvas/ArrayBufferView.cpp
@@ -27,12 +27,12 @@
#if ENABLE(3D_CANVAS)
-#include "WebGLArray.h"
-#include "WebGLArrayBuffer.h"
+#include "ArrayBufferView.h"
+#include "ArrayBuffer.h"
namespace WebCore {
-WebGLArray::WebGLArray(PassRefPtr<WebGLArrayBuffer> buffer,
+ArrayBufferView::ArrayBufferView(PassRefPtr<ArrayBuffer> buffer,
unsigned byteOffset)
: m_byteOffset(byteOffset)
, m_buffer(buffer)
@@ -40,11 +40,11 @@ WebGLArray::WebGLArray(PassRefPtr<WebGLArrayBuffer> buffer,
m_baseAddress = m_buffer ? (static_cast<char*>(m_buffer->data()) + m_byteOffset) : 0;
}
-WebGLArray::~WebGLArray()
+ArrayBufferView::~ArrayBufferView()
{
}
-void WebGLArray::setImpl(WebGLArray* array, unsigned byteOffset, ExceptionCode& ec)
+void ArrayBufferView::setImpl(ArrayBufferView* array, unsigned byteOffset, ExceptionCode& ec)
{
if (byteOffset > byteLength() ||
byteOffset + array->byteLength() > byteLength() ||
@@ -58,7 +58,7 @@ void WebGLArray::setImpl(WebGLArray* array, unsigned byteOffset, ExceptionCode&
memmove(base + byteOffset, array->baseAddress(), array->byteLength());
}
-void WebGLArray::calculateOffsetAndLength(int start, int end, unsigned arraySize,
+void ArrayBufferView::calculateOffsetAndLength(int start, int end, unsigned arraySize,
unsigned* offset, unsigned* length)
{
if (start < 0)
diff --git a/WebCore/html/canvas/WebGLArray.h b/WebCore/html/canvas/ArrayBufferView.h
index 7d67474..dcf6d13 100644
--- a/WebCore/html/canvas/WebGLArray.h
+++ b/WebCore/html/canvas/ArrayBufferView.h
@@ -23,8 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebGLArray_h
-#define WebGLArray_h
+#ifndef ArrayBufferView_h
+#define ArrayBufferView_h
#include <algorithm>
#include "ExceptionCode.h"
@@ -32,11 +32,11 @@
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
-#include "WebGLArrayBuffer.h"
+#include "ArrayBuffer.h"
namespace WebCore {
-class WebGLArray : public RefCounted<WebGLArray> {
+class ArrayBufferView : public RefCounted<ArrayBufferView> {
public:
virtual bool isByteArray() const { return false; }
virtual bool isUnsignedByteArray() const { return false; }
@@ -46,36 +46,39 @@ class WebGLArray : public RefCounted<WebGLArray> {
virtual bool isUnsignedIntArray() const { return false; }
virtual bool isFloatArray() const { return false; }
- PassRefPtr<WebGLArrayBuffer> buffer() {
+ PassRefPtr<ArrayBuffer> buffer() const
+ {
return m_buffer;
}
- void* baseAddress() {
+ void* baseAddress() const
+ {
return m_baseAddress;
}
- unsigned byteOffset() const {
+ unsigned byteOffset() const
+ {
return m_byteOffset;
}
virtual unsigned length() const = 0;
virtual unsigned byteLength() const = 0;
- virtual PassRefPtr<WebGLArray> slice(int start, int end) = 0;
+ virtual PassRefPtr<ArrayBufferView> slice(int start, int end) const = 0;
- virtual ~WebGLArray();
+ virtual ~ArrayBufferView();
protected:
- WebGLArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset);
+ ArrayBufferView(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset);
- void setImpl(WebGLArray* array, unsigned byteOffset, ExceptionCode& ec);
+ void setImpl(ArrayBufferView* array, unsigned byteOffset, ExceptionCode& ec);
- void calculateOffsetAndLength(int start, int end, unsigned arraySize,
- unsigned* offset, unsigned* length);
+ static void calculateOffsetAndLength(int start, int end, unsigned arraySize,
+ unsigned* offset, unsigned* length);
// Helper to verify that a given sub-range of an ArrayBuffer is
// within range.
template <typename T>
- static bool verifySubRange(PassRefPtr<WebGLArrayBuffer> buffer,
+ static bool verifySubRange(PassRefPtr<ArrayBuffer> buffer,
unsigned byteOffset,
unsigned numElements)
{
@@ -94,7 +97,7 @@ class WebGLArray : public RefCounted<WebGLArray> {
// Input offset is in number of elements from this array's view;
// output offset is in number of bytes from the underlying buffer's view.
template <typename T>
- static void clampOffsetAndNumElements(PassRefPtr<WebGLArrayBuffer> buffer,
+ static void clampOffsetAndNumElements(PassRefPtr<ArrayBuffer> buffer,
unsigned arrayByteOffset,
unsigned *offset,
unsigned *numElements)
@@ -111,15 +114,15 @@ class WebGLArray : public RefCounted<WebGLArray> {
*numElements = std::min(remainingElements, *numElements);
}
- // This is the address of the WebGLArrayBuffer's storage, plus the byte offset.
+ // This is the address of the ArrayBuffer's storage, plus the byte offset.
void* m_baseAddress;
unsigned m_byteOffset;
private:
- RefPtr<WebGLArrayBuffer> m_buffer;
+ RefPtr<ArrayBuffer> m_buffer;
};
} // namespace WebCore
-#endif // WebGLArray_h
+#endif // ArrayBufferView_h
diff --git a/WebCore/html/canvas/WebGLArray.idl b/WebCore/html/canvas/ArrayBufferView.idl
index 2cc00d0..450345e 100644
--- a/WebCore/html/canvas/WebGLArray.idl
+++ b/WebCore/html/canvas/ArrayBufferView.idl
@@ -24,12 +24,12 @@
*/
module html {
- interface [Conditional=3D_CANVAS, CustomToJS, OmitConstructor] WebGLArray {
- readonly attribute WebGLArrayBuffer buffer;
+ interface [Conditional=3D_CANVAS, CustomToJS, OmitConstructor] ArrayBufferView {
+ readonly attribute ArrayBuffer buffer;
readonly attribute unsigned long byteOffset;
readonly attribute unsigned long byteLength;
readonly attribute unsigned long length;
- [Custom] WebGLArray slice(in long start, in long end);
+ [Custom] ArrayBufferView slice(in long start, in long end);
};
}
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
index 615b45d..7cdf5d6 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
@@ -114,11 +114,12 @@ void CanvasRenderingContext2D::reset()
{
m_stateStack.resize(1);
m_stateStack.first() = State();
+ m_path.clear();
}
CanvasRenderingContext2D::State::State()
- : m_strokeStyle(CanvasStyle::create("black"))
- , m_fillStyle(CanvasStyle::create("black"))
+ : m_strokeStyle(CanvasStyle::create("#000000"))
+ , m_fillStyle(CanvasStyle::create("#000000"))
, m_lineWidth(1)
, m_lineCap(ButtCap)
, m_lineJoin(MiterJoin)
@@ -214,7 +215,7 @@ float CanvasRenderingContext2D::lineWidth() const
void CanvasRenderingContext2D::setLineWidth(float width)
{
- if (!(width > 0))
+ if (!(isfinite(width) && width > 0))
return;
state().m_lineWidth = width;
GraphicsContext* c = drawingContext();
@@ -264,7 +265,7 @@ float CanvasRenderingContext2D::miterLimit() const
void CanvasRenderingContext2D::setMiterLimit(float limit)
{
- if (!(limit > 0))
+ if (!(isfinite(limit) && limit > 0))
return;
state().m_miterLimit = limit;
GraphicsContext* c = drawingContext();
@@ -280,6 +281,8 @@ float CanvasRenderingContext2D::shadowOffsetX() const
void CanvasRenderingContext2D::setShadowOffsetX(float x)
{
+ if (!isfinite(x))
+ return;
state().m_shadowOffset.setWidth(x);
applyShadow();
}
@@ -291,6 +294,8 @@ float CanvasRenderingContext2D::shadowOffsetY() const
void CanvasRenderingContext2D::setShadowOffsetY(float y)
{
+ if (!isfinite(y))
+ return;
state().m_shadowOffset.setHeight(y);
applyShadow();
}
@@ -302,6 +307,8 @@ float CanvasRenderingContext2D::shadowBlur() const
void CanvasRenderingContext2D::setShadowBlur(float blur)
{
+ if (!(isfinite(blur) && blur >= 0))
+ return;
state().m_shadowBlur = blur;
applyShadow();
}
@@ -874,8 +881,6 @@ void CanvasRenderingContext2D::setShadow(float width, float height, float blur,
return;
RGBA32 rgba = makeRGBA32FromFloats(r, g, b, a); // default is transparent black
- if (!state().m_shadowColor.isEmpty())
- CSSParser::parseColor(rgba, state().m_shadowColor);
c->setShadow(IntSize(width, -height), state().m_shadowBlur, Color(rgba), DeviceColorSpace);
}
@@ -1337,14 +1342,30 @@ static PassRefPtr<ImageData> createEmptyImageData(const IntSize& size)
return data.get();
}
+PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(PassRefPtr<ImageData> imageData, ExceptionCode& ec) const
+{
+ if (!imageData) {
+ ec = NOT_SUPPORTED_ERR;
+ return 0;
+ }
+
+ IntSize size(imageData->width(), imageData->height());
+ return createEmptyImageData(size);
+}
+
PassRefPtr<ImageData> CanvasRenderingContext2D::createImageData(float sw, float sh, ExceptionCode& ec) const
{
ec = 0;
+ if (!sw || !sh) {
+ ec = INDEX_SIZE_ERR;
+ return 0;
+ }
if (!isfinite(sw) || !isfinite(sh)) {
ec = NOT_SUPPORTED_ERR;
return 0;
}
- FloatSize unscaledSize(sw, sh);
+
+ FloatSize unscaledSize(fabs(sw), fabs(sh));
IntSize scaledSize = canvas()->convertLogicalToDevice(unscaledSize);
if (scaledSize.width() < 1)
scaledSize.setWidth(1);
@@ -1360,7 +1381,15 @@ PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(float sx, float sy,
ec = SECURITY_ERR;
return 0;
}
-
+ if (!sw || !sh) {
+ ec = INDEX_SIZE_ERR;
+ return 0;
+ }
+ if (!isfinite(sx) || !isfinite(sy) || !isfinite(sw) || !isfinite(sh)) {
+ ec = NOT_SUPPORTED_ERR;
+ return 0;
+ }
+
FloatRect unscaledRect(sx, sy, sw, sh);
IntRect scaledRect = canvas()->convertLogicalToDevice(unscaledRect);
if (scaledRect.width() < 1)
@@ -1391,7 +1420,7 @@ void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
}
if (!isfinite(dx) || !isfinite(dy) || !isfinite(dirtyX) ||
!isfinite(dirtyY) || !isfinite(dirtyWidth) || !isfinite(dirtyHeight)) {
- ec = INDEX_SIZE_ERR;
+ ec = NOT_SUPPORTED_ERR;
return;
}
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.h b/WebCore/html/canvas/CanvasRenderingContext2D.h
index 2bac902..a49ff81 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.h
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.h
@@ -181,6 +181,7 @@ namespace WebCore {
PassRefPtr<CanvasPattern> createPattern(HTMLImageElement*, const String& repetitionType, ExceptionCode&);
PassRefPtr<CanvasPattern> createPattern(HTMLCanvasElement*, const String& repetitionType, ExceptionCode&);
+ PassRefPtr<ImageData> createImageData(PassRefPtr<ImageData> imageData, ExceptionCode&) 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&);
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.idl b/WebCore/html/canvas/CanvasRenderingContext2D.idl
index a3c83ca..da4dd72 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.idl
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.idl
@@ -148,6 +148,10 @@ module html {
raises (DOMException);
void putImageData(in ImageData imagedata, in float dx, in float dy, in [Optional] float dirtyX, in float dirtyY, in float dirtyWidth, in float dirtyHeight)
raises(DOMException);
+ ImageData createImageData(in ImageData imagedata)
+ raises (DOMException);
+ ImageData createImageData(in float sw, in float sh)
+ raises (DOMException);
#else
// FIXME: Remove 'else' once JSC supports overloads too.
[Custom] void fillText(/* 4 */);
@@ -160,14 +164,13 @@ module html {
[Custom] void setShadow(/* 3 */);
[Custom] void createPattern(/* 2 */);
[Custom] void putImageData(/* in ImageData imagedata, in float dx, in float dy [, in float dirtyX, in float dirtyY, in float dirtyWidth, in float dirtyHeight] */);
+ [Custom] ImageData createImageData(/* 3 */);
#endif // defined(V8_BINDING)
attribute [Custom] custom strokeStyle;
attribute [Custom] custom fillStyle;
// pixel manipulation
- 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);
};
diff --git a/WebCore/html/canvas/FloatArray.cpp b/WebCore/html/canvas/FloatArray.cpp
new file mode 100644
index 0000000..942a123
--- /dev/null
+++ b/WebCore/html/canvas/FloatArray.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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:
+ * 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 "FloatArray.h"
+
+namespace WebCore {
+
+PassRefPtr<FloatArray> FloatArray::create(unsigned length)
+{
+ return TypedArrayBase<float>::create<FloatArray>(length);
+}
+
+PassRefPtr<FloatArray> FloatArray::create(float* array, unsigned length)
+{
+ return TypedArrayBase<float>::create<FloatArray>(array, length);
+}
+
+PassRefPtr<FloatArray> FloatArray::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+{
+ return TypedArrayBase<float>::create<FloatArray>(buffer, byteOffset, length);
+}
+
+FloatArray::FloatArray(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+ : TypedArrayBase<float>(buffer, byteOffset, length)
+{
+}
+
+PassRefPtr<ArrayBufferView> FloatArray::slice(int start, int end) const
+{
+ return sliceImpl<FloatArray>(start, end);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLFloatArray.h b/WebCore/html/canvas/FloatArray.h
index 5b4e6c9..9211a40 100644
--- a/WebCore/html/canvas/WebGLFloatArray.h
+++ b/WebCore/html/canvas/FloatArray.h
@@ -24,58 +24,37 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebGLFloatArray_h
-#define WebGLFloatArray_h
+#ifndef FloatArray_h
+#define FloatArray_h
-#include "WebGLArray.h"
+#include "TypedArrayBase.h"
#include <wtf/MathExtras.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
namespace WebCore {
-class WebGLFloatArray : public WebGLArray {
+class FloatArray : public TypedArrayBase<float> {
public:
- virtual bool isFloatArray() const { return true; }
-
- static PassRefPtr<WebGLFloatArray> create(unsigned length);
- static PassRefPtr<WebGLFloatArray> create(float* array, unsigned length);
- static PassRefPtr<WebGLFloatArray> create(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length);
-
- float* data() { return static_cast<float*>(baseAddress()); }
+ static PassRefPtr<FloatArray> create(unsigned length);
+ static PassRefPtr<FloatArray> create(float* array, unsigned length);
+ static PassRefPtr<FloatArray> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length);
- virtual unsigned length() const;
- virtual unsigned byteLength() const;
- virtual PassRefPtr<WebGLArray> slice(int start, int end);
+ using TypedArrayBase<float>::set;
void set(unsigned index, double value)
{
- if (index >= m_size)
+ if (index >= TypedArrayBase<float>::m_length)
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 get(unsigned index) const
- {
- return item(index);
+ TypedArrayBase<float>::data()[index] = static_cast<float>(value);
}
+ // Invoked by the indexed getter. Does not perform range checks; caller
+ // is responsible for doing so and returning undefined as necessary.
float item(unsigned index) const
{
- ASSERT(index < m_size);
- float* storage = static_cast<float*>(m_baseAddress);
- float result = storage[index];
+ ASSERT(index < TypedArrayBase<float>::m_length);
+ float result = TypedArrayBase<float>::data()[index];
if (isnan(result)) {
// Clamp NaN to 0
result = 0;
@@ -83,13 +62,18 @@ class WebGLFloatArray : public WebGLArray {
return result;
}
- void set(WebGLFloatArray* array, unsigned offset, ExceptionCode& ec);
-
private:
- WebGLFloatArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length);
- unsigned m_size;
+ FloatArray(PassRefPtr<ArrayBuffer> buffer,
+ unsigned byteOffset,
+ unsigned length);
+ // Make constructor visible to superclass.
+ friend class TypedArrayBase<float>;
+
+ // Overridden from ArrayBufferView.
+ virtual bool isFloatArray() const { return true; }
+ virtual PassRefPtr<ArrayBufferView> slice(int start, int end) const;
};
} // namespace WebCore
-#endif // WebGLFloatArray_h
+#endif // FloatArray_h
diff --git a/WebCore/html/canvas/WebGLFloatArray.idl b/WebCore/html/canvas/FloatArray.idl
index e0a80f2..41b2c94 100644
--- a/WebCore/html/canvas/WebGLFloatArray.idl
+++ b/WebCore/html/canvas/FloatArray.idl
@@ -32,10 +32,8 @@ module html {
GenerateNativeConverter,
CustomConstructor,
CustomToJS
- ] WebGLFloatArray : WebGLArray {
- float get(in unsigned long index);
- // void set(in unsigned long index, in float value);
- // void set(in WebGLFloatArray array, [Optional] in unsigned long offset);
+ ] FloatArray : ArrayBufferView {
+ // void set(in FloatArray array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
};
diff --git a/WebCore/html/canvas/Int16Array.cpp b/WebCore/html/canvas/Int16Array.cpp
new file mode 100644
index 0000000..f3f9742
--- /dev/null
+++ b/WebCore/html/canvas/Int16Array.cpp
@@ -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.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "Int16Array.h"
+
+namespace WebCore {
+
+PassRefPtr<Int16Array> Int16Array::create(unsigned length)
+{
+ return TypedArrayBase<short>::create<Int16Array>(length);
+}
+
+PassRefPtr<Int16Array> Int16Array::create(short* array, unsigned length)
+{
+ return TypedArrayBase<short>::create<Int16Array>(array, length);
+}
+
+PassRefPtr<Int16Array> Int16Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+{
+ return TypedArrayBase<short>::create<Int16Array>(buffer, byteOffset, length);
+}
+
+Int16Array::Int16Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+ : IntegralTypedArrayBase<short>(buffer, byteOffset, length)
+{
+}
+
+PassRefPtr<ArrayBufferView> Int16Array::slice(int start, int end) const
+{
+ return sliceImpl<Int16Array>(start, end);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/Int16Array.h b/WebCore/html/canvas/Int16Array.h
new file mode 100644
index 0000000..00877ef
--- /dev/null
+++ b/WebCore/html/canvas/Int16Array.h
@@ -0,0 +1,58 @@
+/*
+ * 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 Int16Array_h
+#define Int16Array_h
+
+#include "IntegralTypedArrayBase.h"
+
+namespace WebCore {
+
+class ArrayBuffer;
+
+class Int16Array : public IntegralTypedArrayBase<short> {
+ public:
+ static PassRefPtr<Int16Array> create(unsigned length);
+ static PassRefPtr<Int16Array> create(short* array, unsigned length);
+ static PassRefPtr<Int16Array> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length);
+
+ using TypedArrayBase<short>::set;
+ using IntegralTypedArrayBase<short>::set;
+
+ private:
+ Int16Array(PassRefPtr<ArrayBuffer> buffer,
+ unsigned byteOffset,
+ unsigned length);
+ // Make constructor visible to superclass.
+ friend class TypedArrayBase<short>;
+
+ // Overridden from ArrayBufferView.
+ virtual bool isShortArray() const { return true; }
+ virtual PassRefPtr<ArrayBufferView> slice(int start, int end) const;
+};
+
+} // namespace WebCore
+
+#endif // Int16Array_h
diff --git a/WebCore/html/canvas/WebGLShortArray.idl b/WebCore/html/canvas/Int16Array.idl
index 59dce76..2ac52fe 100644
--- a/WebCore/html/canvas/WebGLShortArray.idl
+++ b/WebCore/html/canvas/Int16Array.idl
@@ -31,10 +31,8 @@ module html {
GenerateNativeConverter,
CustomConstructor,
CustomToJS
- ] WebGLShortArray : WebGLArray {
- long get(in unsigned long index);
- // void set(in unsigned long index, in long value);
- // void set(in WebGLShortArray array, [Optional] in unsigned long offset);
+ ] Int16Array : ArrayBufferView {
+ // void set(in Int16Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
};
diff --git a/WebCore/html/canvas/WebGLUnsignedIntArray.idl b/WebCore/html/canvas/Int32Array.cpp
index 75ff598..423c36b 100644
--- a/WebCore/html/canvas/WebGLUnsignedIntArray.idl
+++ b/WebCore/html/canvas/Int32Array.cpp
@@ -24,19 +24,39 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-module html {
- interface [
- Conditional=3D_CANVAS,
- CustomConstructor,
- HasNumericIndexGetter,
- HasCustomIndexSetter,
- GenerateNativeConverter,
- CustomToJS
- ] WebGLUnsignedIntArray : WebGLArray {
- unsigned long get(in unsigned long index);
- // void set(in unsigned long index, in long value);
- // void set(in WebGLUnsignedIntArray array, [Optional] in unsigned long offset);
- // void set(in sequence<long> array, [Optional] in unsigned long offset);
- [Custom] void set();
- };
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "Int32Array.h"
+
+namespace WebCore {
+
+PassRefPtr<Int32Array> Int32Array::create(unsigned length)
+{
+ return TypedArrayBase<int>::create<Int32Array>(length);
+}
+
+PassRefPtr<Int32Array> Int32Array::create(int* array, unsigned length)
+{
+ return TypedArrayBase<int>::create<Int32Array>(array, length);
+}
+
+PassRefPtr<Int32Array> Int32Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+{
+ return TypedArrayBase<int>::create<Int32Array>(buffer, byteOffset, length);
}
+
+Int32Array::Int32Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+ : IntegralTypedArrayBase<int>(buffer, byteOffset, length)
+{
+}
+
+PassRefPtr<ArrayBufferView> Int32Array::slice(int start, int end) const
+{
+ return sliceImpl<Int32Array>(start, end);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/Int32Array.h b/WebCore/html/canvas/Int32Array.h
new file mode 100644
index 0000000..72fb579
--- /dev/null
+++ b/WebCore/html/canvas/Int32Array.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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:
+ * 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 Int32Array_h
+#define Int32Array_h
+
+#include "IntegralTypedArrayBase.h"
+
+namespace WebCore {
+
+class Int32Array : public IntegralTypedArrayBase<int> {
+ public:
+ static PassRefPtr<Int32Array> create(unsigned length);
+ static PassRefPtr<Int32Array> create(int* array, unsigned length);
+ static PassRefPtr<Int32Array> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length);
+
+ using TypedArrayBase<int>::set;
+ using IntegralTypedArrayBase<int>::set;
+
+ private:
+ Int32Array(PassRefPtr<ArrayBuffer> buffer,
+ unsigned byteOffset,
+ unsigned length);
+ // Make constructor visible to superclass.
+ friend class TypedArrayBase<int>;
+
+ // Overridden from ArrayBufferView.
+ virtual bool isIntArray() const { return true; }
+ virtual PassRefPtr<ArrayBufferView> slice(int start, int end) const;
+};
+
+} // namespace WebCore
+
+#endif // Int32Array_h
diff --git a/WebCore/html/canvas/WebGLIntArray.idl b/WebCore/html/canvas/Int32Array.idl
index ef0d92f..80a885e 100644
--- a/WebCore/html/canvas/WebGLIntArray.idl
+++ b/WebCore/html/canvas/Int32Array.idl
@@ -32,10 +32,8 @@ module html {
GenerateNativeConverter,
CustomConstructor,
CustomToJS
- ] WebGLIntArray : WebGLArray {
- long get(in unsigned long index);
- // void set(in unsigned long index, in long value);
- // void set(in WebGLIntArray array, [Optional] in unsigned long offset);
+ ] Int32Array : ArrayBufferView {
+ // void set(in Int32Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
};
diff --git a/WebCore/html/canvas/Int8Array.cpp b/WebCore/html/canvas/Int8Array.cpp
new file mode 100644
index 0000000..20ff32a
--- /dev/null
+++ b/WebCore/html/canvas/Int8Array.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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:
+ * 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 "Int8Array.h"
+
+namespace WebCore {
+
+PassRefPtr<Int8Array> Int8Array::create(unsigned length)
+{
+ return TypedArrayBase<signed char>::create<Int8Array>(length);
+}
+
+PassRefPtr<Int8Array> Int8Array::create(signed char* array, unsigned length)
+{
+ return TypedArrayBase<signed char>::create<Int8Array>(array, length);
+}
+
+PassRefPtr<Int8Array> Int8Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+{
+ return TypedArrayBase<signed char>::create<Int8Array>(buffer, byteOffset, length);
+}
+
+Int8Array::Int8Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+ : IntegralTypedArrayBase<signed char>(buffer, byteOffset, length)
+{
+}
+
+PassRefPtr<ArrayBufferView> Int8Array::slice(int start, int end) const
+{
+ return sliceImpl<Int8Array>(start, end);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/Int8Array.h b/WebCore/html/canvas/Int8Array.h
new file mode 100644
index 0000000..d267f7f
--- /dev/null
+++ b/WebCore/html/canvas/Int8Array.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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:
+ * 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 Int8Array_h
+#define Int8Array_h
+
+#include "IntegralTypedArrayBase.h"
+
+namespace WebCore {
+
+class ArrayBuffer;
+
+class Int8Array : public IntegralTypedArrayBase<signed char> {
+ public:
+ static PassRefPtr<Int8Array> create(unsigned length);
+ static PassRefPtr<Int8Array> create(signed char* array, unsigned length);
+ static PassRefPtr<Int8Array> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length);
+
+ using TypedArrayBase<signed char>::set;
+ using IntegralTypedArrayBase<signed char>::set;
+
+ private:
+ Int8Array(PassRefPtr<ArrayBuffer> buffer,
+ unsigned byteOffset,
+ unsigned length);
+ // Make constructor visible to superclass.
+ friend class TypedArrayBase<signed char>;
+
+ // Overridden from ArrayBufferView.
+ virtual bool isByteArray() const { return true; }
+ virtual PassRefPtr<ArrayBufferView> slice(int start, int end) const;
+};
+
+} // namespace WebCore
+
+#endif // Int8Array_h
diff --git a/WebCore/html/canvas/WebGLByteArray.idl b/WebCore/html/canvas/Int8Array.idl
index dbb3bb2..1124ac1 100644
--- a/WebCore/html/canvas/WebGLByteArray.idl
+++ b/WebCore/html/canvas/Int8Array.idl
@@ -32,10 +32,8 @@ module html {
GenerateNativeConverter,
CustomConstructor,
CustomToJS
- ] WebGLByteArray : WebGLArray {
- long get(in unsigned long index);
- // void set(in unsigned long index, in long value);
- // void set(in WebGLByteArray array, [Optional] in unsigned long offset);
+ ] Int8Array : ArrayBufferView {
+ // void set(in Int8Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
};
diff --git a/WebCore/html/canvas/IntegralTypedArrayBase.h b/WebCore/html/canvas/IntegralTypedArrayBase.h
new file mode 100644
index 0000000..b87d832
--- /dev/null
+++ b/WebCore/html/canvas/IntegralTypedArrayBase.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (c) 2010, 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:
+ * 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 IntegralTypedArrayBase_h
+#define IntegralTypedArrayBase_h
+
+#include "TypedArrayBase.h"
+#include <limits>
+#include <wtf/MathExtras.h>
+
+// Base class for all WebGL<T>Array types holding integral
+// (non-floating-point) values.
+
+namespace WebCore {
+
+template <typename T>
+class IntegralTypedArrayBase : public TypedArrayBase<T> {
+ public:
+ void set(unsigned index, double value)
+ {
+ if (index >= TypedArrayBase<T>::m_length)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<T>::min())
+ value = std::numeric_limits<T>::min();
+ else if (value > std::numeric_limits<T>::max())
+ value = std::numeric_limits<T>::max();
+ TypedArrayBase<T>::data()[index] = static_cast<T>(value);
+ }
+
+ // Invoked by the indexed getter. Does not perform range checks; caller
+ // is responsible for doing so and returning undefined as necessary.
+ T item(unsigned index) const
+ {
+ ASSERT(index < TypedArrayBase<T>::m_length);
+ return TypedArrayBase<T>::data()[index];
+ }
+
+ protected:
+ IntegralTypedArrayBase(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+ : TypedArrayBase<T>(buffer, byteOffset, length)
+ {
+ }
+};
+
+} // namespace WebCore
+
+#endif // IntegralTypedArrayBase_h
diff --git a/WebCore/html/canvas/TypedArrayBase.h b/WebCore/html/canvas/TypedArrayBase.h
new file mode 100644
index 0000000..06d7ed5
--- /dev/null
+++ b/WebCore/html/canvas/TypedArrayBase.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (c) 2010, 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:
+ * 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 TypedArrayBase_h
+#define TypedArrayBase_h
+
+#include "ArrayBufferView.h"
+#include "ArrayBuffer.h"
+
+namespace WebCore {
+
+template <typename T>
+class TypedArrayBase : public ArrayBufferView {
+ public:
+ T* data() const { return static_cast<T*>(baseAddress()); }
+
+ void set(TypedArrayBase<T>* array, unsigned offset, ExceptionCode& ec)
+ {
+ setImpl(array, offset * sizeof(T), ec);
+ }
+
+ // Overridden from ArrayBufferView. This must be public because of
+ // rules about inheritance of members in template classes, and
+ // because it is accessed via pointers to subclasses.
+ virtual unsigned length() const
+ {
+ return m_length;
+ }
+
+ protected:
+ TypedArrayBase(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+ : ArrayBufferView(buffer, byteOffset)
+ , m_length(length)
+ {
+ }
+
+ template <class Subclass>
+ static PassRefPtr<Subclass> create(unsigned length)
+ {
+ RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(length, sizeof(T));
+ return create<Subclass>(buffer, 0, length);
+ }
+
+ template <class Subclass>
+ static PassRefPtr<Subclass> create(T* array, unsigned length)
+ {
+ RefPtr<Subclass> a = create<Subclass>(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+ }
+
+ template <class Subclass>
+ static PassRefPtr<Subclass> create(PassRefPtr<ArrayBuffer> buffer,
+ unsigned byteOffset,
+ unsigned length)
+ {
+ RefPtr<ArrayBuffer> buf(buffer);
+ if (!verifySubRange<T>(buf, byteOffset, length))
+ return 0;
+
+ return adoptRef(new Subclass(buf, byteOffset, length));
+ }
+
+ template <class Subclass>
+ PassRefPtr<Subclass> sliceImpl(int start, int end) const
+ {
+ unsigned offset, length;
+ calculateOffsetAndLength(start, end, m_length, &offset, &length);
+ clampOffsetAndNumElements<T>(buffer(), m_byteOffset, &offset, &length);
+ return create<Subclass>(buffer(), offset, length);
+ }
+
+ // We do not want to have to access this via a virtual function in subclasses,
+ // which is why it is protected rather than private.
+ unsigned m_length;
+
+ private:
+ // Overridden from ArrayBufferView.
+ virtual unsigned byteLength() const
+ {
+ return m_length * sizeof(T);
+ }
+};
+
+} // namespace WebCore
+
+#endif // TypedArrayBase_h
diff --git a/WebCore/html/canvas/Uint16Array.cpp b/WebCore/html/canvas/Uint16Array.cpp
new file mode 100644
index 0000000..4656173
--- /dev/null
+++ b/WebCore/html/canvas/Uint16Array.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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:
+ * 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 "Uint16Array.h"
+
+namespace WebCore {
+
+PassRefPtr<Uint16Array> Uint16Array::create(unsigned length)
+{
+ return TypedArrayBase<unsigned short>::create<Uint16Array>(length);
+}
+
+PassRefPtr<Uint16Array> Uint16Array::create(unsigned short* array, unsigned length)
+{
+ return TypedArrayBase<unsigned short>::create<Uint16Array>(array, length);
+}
+
+PassRefPtr<Uint16Array> Uint16Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+{
+ return TypedArrayBase<unsigned short>::create<Uint16Array>(buffer, byteOffset, length);
+}
+
+Uint16Array::Uint16Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+ : IntegralTypedArrayBase<unsigned short>(buffer, byteOffset, length)
+{
+}
+
+PassRefPtr<ArrayBufferView> Uint16Array::slice(int start, int end) const
+{
+ return sliceImpl<Uint16Array>(start, end);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/Uint16Array.h b/WebCore/html/canvas/Uint16Array.h
new file mode 100644
index 0000000..fee31f6
--- /dev/null
+++ b/WebCore/html/canvas/Uint16Array.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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:
+ * 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 Uint16Array_h
+#define Uint16Array_h
+
+#include "IntegralTypedArrayBase.h"
+
+namespace WebCore {
+
+class ArrayBuffer;
+
+class Uint16Array : public IntegralTypedArrayBase<unsigned short> {
+ public:
+ static PassRefPtr<Uint16Array> create(unsigned length);
+ static PassRefPtr<Uint16Array> create(unsigned short* array, unsigned length);
+ static PassRefPtr<Uint16Array> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length);
+
+ using TypedArrayBase<unsigned short>::set;
+ using IntegralTypedArrayBase<unsigned short>::set;
+
+ private:
+ Uint16Array(PassRefPtr<ArrayBuffer> buffer,
+ unsigned byteOffset,
+ unsigned length);
+ // Make constructor visible to superclass.
+ friend class TypedArrayBase<unsigned short>;
+
+ // Overridden from ArrayBufferView.
+ virtual bool isUnsignedShortArray() const { return true; }
+ virtual PassRefPtr<ArrayBufferView> slice(int start, int end) const;
+};
+
+} // namespace WebCore
+
+#endif // Uint16Array_h
diff --git a/WebCore/html/canvas/WebGLUnsignedByteArray.idl b/WebCore/html/canvas/Uint16Array.idl
index 4de8b42..2d5b34e 100644
--- a/WebCore/html/canvas/WebGLUnsignedByteArray.idl
+++ b/WebCore/html/canvas/Uint16Array.idl
@@ -27,15 +27,13 @@
module html {
interface [
Conditional=3D_CANVAS,
+ CustomConstructor,
HasNumericIndexGetter,
HasCustomIndexSetter,
GenerateNativeConverter,
- CustomConstructor,
CustomToJS
- ] WebGLUnsignedByteArray : WebGLArray {
- long get(in unsigned long index);
- // void set(in unsigned long index, in long value);
- // void set(in WebGLUnsignedByteArray array, [Optional] in unsigned long offset);
+ ] Uint16Array : ArrayBufferView {
+ // void set(in Uint16Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
};
diff --git a/WebCore/html/canvas/Uint32Array.cpp b/WebCore/html/canvas/Uint32Array.cpp
new file mode 100644
index 0000000..3f43bef
--- /dev/null
+++ b/WebCore/html/canvas/Uint32Array.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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:
+ * 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 "Uint32Array.h"
+
+namespace WebCore {
+
+PassRefPtr<Uint32Array> Uint32Array::create(unsigned length)
+{
+ return TypedArrayBase<unsigned int>::create<Uint32Array>(length);
+}
+
+PassRefPtr<Uint32Array> Uint32Array::create(unsigned int* array, unsigned length)
+{
+ return TypedArrayBase<unsigned int>::create<Uint32Array>(array, length);
+}
+
+PassRefPtr<Uint32Array> Uint32Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+{
+ return TypedArrayBase<unsigned int>::create<Uint32Array>(buffer, byteOffset, length);
+}
+
+Uint32Array::Uint32Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+ : IntegralTypedArrayBase<unsigned int>(buffer, byteOffset, length)
+{
+}
+
+PassRefPtr<ArrayBufferView> Uint32Array::slice(int start, int end) const
+{
+ return sliceImpl<Uint32Array>(start, end);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/Uint32Array.h b/WebCore/html/canvas/Uint32Array.h
new file mode 100644
index 0000000..db23088
--- /dev/null
+++ b/WebCore/html/canvas/Uint32Array.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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:
+ * 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 Uint32Array_h
+#define Uint32Array_h
+
+#include "IntegralTypedArrayBase.h"
+
+namespace WebCore {
+
+class ArrayBuffer;
+
+class Uint32Array : public IntegralTypedArrayBase<unsigned int> {
+ public:
+ static PassRefPtr<Uint32Array> create(unsigned length);
+ static PassRefPtr<Uint32Array> create(unsigned int* array, unsigned length);
+ static PassRefPtr<Uint32Array> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length);
+
+ using TypedArrayBase<unsigned int>::set;
+ using IntegralTypedArrayBase<unsigned int>::set;
+
+ private:
+ Uint32Array(PassRefPtr<ArrayBuffer> buffer,
+ unsigned byteOffset,
+ unsigned length);
+ // Make constructor visible to superclass.
+ friend class TypedArrayBase<unsigned int>;
+
+ // Overridden from ArrayBufferView.
+ virtual bool isUnsignedIntArray() const { return true; }
+ virtual PassRefPtr<ArrayBufferView> slice(int start, int end) const;
+};
+
+} // namespace WebCore
+
+#endif // Uint32Array_h
diff --git a/WebCore/html/canvas/WebGLUnsignedShortArray.idl b/WebCore/html/canvas/Uint32Array.idl
index fc53929..bab0f8d 100644
--- a/WebCore/html/canvas/WebGLUnsignedShortArray.idl
+++ b/WebCore/html/canvas/Uint32Array.idl
@@ -32,10 +32,8 @@ module html {
HasCustomIndexSetter,
GenerateNativeConverter,
CustomToJS
- ] WebGLUnsignedShortArray : WebGLArray {
- long get(in unsigned long index);
- // void set(in unsigned long index, in long value);
- // void set(in WebGLUnsignedShortArray array, [Optional] in unsigned long offset);
+ ] Uint32Array : ArrayBufferView {
+ // void set(in Uint32Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
};
diff --git a/WebCore/html/canvas/Uint8Array.cpp b/WebCore/html/canvas/Uint8Array.cpp
new file mode 100644
index 0000000..13b7022
--- /dev/null
+++ b/WebCore/html/canvas/Uint8Array.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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:
+ * 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 "Uint8Array.h"
+
+namespace WebCore {
+
+PassRefPtr<Uint8Array> Uint8Array::create(unsigned length)
+{
+ return TypedArrayBase<unsigned char>::create<Uint8Array>(length);
+}
+
+PassRefPtr<Uint8Array> Uint8Array::create(unsigned char* array, unsigned length)
+{
+ return TypedArrayBase<unsigned char>::create<Uint8Array>(array, length);
+}
+
+PassRefPtr<Uint8Array> Uint8Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+{
+ return TypedArrayBase<unsigned char>::create<Uint8Array>(buffer, byteOffset, length);
+}
+
+Uint8Array::Uint8Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+ : IntegralTypedArrayBase<unsigned char>(buffer, byteOffset, length)
+{
+}
+
+PassRefPtr<ArrayBufferView> Uint8Array::slice(int start, int end) const
+{
+ return sliceImpl<Uint8Array>(start, end);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/Uint8Array.h b/WebCore/html/canvas/Uint8Array.h
new file mode 100644
index 0000000..6e20b42
--- /dev/null
+++ b/WebCore/html/canvas/Uint8Array.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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:
+ * 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 Uint8Array_h
+#define Uint8Array_h
+
+#include "IntegralTypedArrayBase.h"
+
+namespace WebCore {
+
+class ArrayBuffer;
+
+class Uint8Array : public IntegralTypedArrayBase<unsigned char> {
+ public:
+ static PassRefPtr<Uint8Array> create(unsigned length);
+ static PassRefPtr<Uint8Array> create(unsigned char* array, unsigned length);
+ static PassRefPtr<Uint8Array> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length);
+
+ using TypedArrayBase<unsigned char>::set;
+ using IntegralTypedArrayBase<unsigned char>::set;
+
+ private:
+ Uint8Array(PassRefPtr<ArrayBuffer> buffer,
+ unsigned byteOffset,
+ unsigned length);
+ // Make constructor visible to superclass.
+ friend class TypedArrayBase<unsigned char>;
+
+ // Overridden from ArrayBufferView.
+ virtual bool isUnsignedByteArray() const { return true; }
+ virtual PassRefPtr<ArrayBufferView> slice(int start, int end) const;
+};
+
+} // namespace WebCore
+
+#endif // Uint8Array_h
diff --git a/WebCore/html/canvas/Uint8Array.idl b/WebCore/html/canvas/Uint8Array.idl
new file mode 100644
index 0000000..7031bfc
--- /dev/null
+++ b/WebCore/html/canvas/Uint8Array.idl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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:
+ * 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,
+ CustomConstructor,
+ CustomToJS
+ ] Uint8Array : ArrayBufferView {
+ // void set(in Uint8Array array, [Optional] in unsigned long offset);
+ // void set(in sequence<long> array, [Optional] in unsigned long offset);
+ [Custom] void set();
+ };
+}
diff --git a/WebCore/html/canvas/WebGLBuffer.cpp b/WebCore/html/canvas/WebGLBuffer.cpp
index 958bedc..192967e 100644
--- a/WebCore/html/canvas/WebGLBuffer.cpp
+++ b/WebCore/html/canvas/WebGLBuffer.cpp
@@ -80,7 +80,7 @@ bool WebGLBuffer::associateBufferData(unsigned long target, int size)
return false;
}
-bool WebGLBuffer::associateBufferData(unsigned long target, WebGLArray* array)
+bool WebGLBuffer::associateBufferData(unsigned long target, ArrayBufferView* array)
{
if (!array)
return false;
@@ -91,7 +91,7 @@ bool WebGLBuffer::associateBufferData(unsigned long target, WebGLArray* array)
// We must always clone the incoming data because client-side
// modifications without calling bufferData or bufferSubData
// must never be able to change the validation results.
- m_elementArrayBuffer = WebGLArrayBuffer::create(array->buffer().get());
+ m_elementArrayBuffer = ArrayBuffer::create(array->buffer().get());
return true;
}
@@ -103,7 +103,7 @@ bool WebGLBuffer::associateBufferData(unsigned long target, WebGLArray* array)
return false;
}
-bool WebGLBuffer::associateBufferSubData(unsigned long target, long offset, WebGLArray* array)
+bool WebGLBuffer::associateBufferSubData(unsigned long target, long offset, ArrayBufferView* array)
{
if (!array)
return false;
diff --git a/WebCore/html/canvas/WebGLBuffer.h b/WebCore/html/canvas/WebGLBuffer.h
index f56d374..feaadbb 100644
--- a/WebCore/html/canvas/WebGLBuffer.h
+++ b/WebCore/html/canvas/WebGLBuffer.h
@@ -27,7 +27,7 @@
#define WebGLBuffer_h
#include "CanvasObject.h"
-#include "WebGLArrayBuffer.h"
+#include "ArrayBuffer.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -45,11 +45,11 @@ namespace WebCore {
static PassRefPtr<WebGLBuffer> create(WebGLRenderingContext*, Platform3DObject);
bool associateBufferData(unsigned long target, int size);
- bool associateBufferData(unsigned long target, WebGLArray* array);
- bool associateBufferSubData(unsigned long target, long offset, WebGLArray* array);
+ bool associateBufferData(unsigned long target, ArrayBufferView* array);
+ bool associateBufferSubData(unsigned long target, long offset, ArrayBufferView* array);
unsigned byteLength(unsigned long target) const;
- const WebGLArrayBuffer* elementArrayBuffer() const { return m_elementArrayBuffer.get(); }
+ const ArrayBuffer* elementArrayBuffer() const { return m_elementArrayBuffer.get(); }
// Gets the cached max index for the given type. Returns -1 if
// none has been set.
@@ -66,7 +66,7 @@ namespace WebCore {
private:
virtual bool isBuffer() const { return true; }
- RefPtr<WebGLArrayBuffer> m_elementArrayBuffer;
+ RefPtr<ArrayBuffer> m_elementArrayBuffer;
unsigned m_elementArrayBufferByteLength;
unsigned m_arrayBufferByteLength;
diff --git a/WebCore/html/canvas/WebGLByteArray.cpp b/WebCore/html/canvas/WebGLByteArray.cpp
deleted file mode 100644
index 603e4d1..0000000
--- a/WebCore/html/canvas/WebGLByteArray.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * 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:
- * 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 "WebGLArrayBuffer.h"
-#include "WebGLByteArray.h"
-
-namespace WebCore {
-
-PassRefPtr<WebGLByteArray> WebGLByteArray::create(unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length, sizeof(signed char));
- return create(buffer, 0, length);
-}
-
-PassRefPtr<WebGLByteArray> WebGLByteArray::create(signed char* array, unsigned length)
-{
- RefPtr<WebGLByteArray> a = WebGLByteArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
-}
-
-PassRefPtr<WebGLByteArray> WebGLByteArray::create(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buf(buffer);
- if (!verifySubRange<signed char>(buf, byteOffset, length))
- return 0;
-
- return adoptRef(new WebGLByteArray(buf, byteOffset, length));
-}
-
-WebGLByteArray::WebGLByteArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned offset, unsigned length)
- : WebGLArray(buffer, offset)
- , m_size(length)
-{
-}
-
-unsigned WebGLByteArray::length() const {
- return m_size;
-}
-
-unsigned WebGLByteArray::byteLength() const {
- return m_size * sizeof(signed char);
-}
-
-PassRefPtr<WebGLArray> WebGLByteArray::slice(int start, int end)
-{
- unsigned offset, length;
- calculateOffsetAndLength(start, end, m_size, &offset, &length);
- clampOffsetAndNumElements<signed char>(buffer().get(), m_byteOffset, &offset, &length);
- return create(buffer(), offset, length);
-}
-
-void WebGLByteArray::set(WebGLByteArray* array, unsigned offset, ExceptionCode& ec) {
- setImpl(array, offset * sizeof(signed char), ec);
-}
-
-}
-
-#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLByteArray.h b/WebCore/html/canvas/WebGLByteArray.h
deleted file mode 100644
index 60d301c..0000000
--- a/WebCore/html/canvas/WebGLByteArray.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * 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:
- * 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 WebGLByteArray_h
-#define WebGLByteArray_h
-
-#include "WebGLArray.h"
-#include <limits>
-#include <wtf/MathExtras.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class WebGLArrayBuffer;
-
-class WebGLByteArray : public WebGLArray {
- public:
- virtual bool isByteArray() const { return true; }
-
- static PassRefPtr<WebGLByteArray> create(unsigned length);
- static PassRefPtr<WebGLByteArray> create(signed char* array, unsigned length);
- static PassRefPtr<WebGLByteArray> create(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length);
-
- char* data() { return static_cast<char*>(baseAddress()); }
-
- virtual unsigned length() const;
- virtual unsigned byteLength() const;
- virtual PassRefPtr<WebGLArray> slice(int start, int end);
-
- 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 get(unsigned index) const
- {
- return item(index);
- }
-
- signed char item(unsigned index) const
- {
- ASSERT(index < m_size);
- signed char* storage = static_cast<signed char*>(m_baseAddress);
- return storage[index];
- }
-
- void set(WebGLByteArray* array, unsigned offset, ExceptionCode& ec);
-
- private:
- WebGLByteArray(PassRefPtr<WebGLArrayBuffer> buffer,
- unsigned offset,
- unsigned length);
- unsigned m_size;
-};
-
-} // namespace WebCore
-
-#endif // WebGLByteArray_h
diff --git a/WebCore/html/canvas/WebGLFloatArray.cpp b/WebCore/html/canvas/WebGLFloatArray.cpp
deleted file mode 100644
index ca93c4c..0000000
--- a/WebCore/html/canvas/WebGLFloatArray.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * 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:
- * 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 "WebGLFloatArray.h"
-
-namespace WebCore {
-
-PassRefPtr<WebGLFloatArray> WebGLFloatArray::create(unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length, sizeof(float));
- return create(buffer, 0, length);
-}
-
-PassRefPtr<WebGLFloatArray> WebGLFloatArray::create(float* array, unsigned length)
-{
- RefPtr<WebGLFloatArray> a = WebGLFloatArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
-}
-
-PassRefPtr<WebGLFloatArray> WebGLFloatArray::create(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buf(buffer);
- if (!verifySubRange<float>(buf, byteOffset, length))
- return 0;
-
- return adoptRef(new WebGLFloatArray(buf, byteOffset, length));
-}
-
-WebGLFloatArray::WebGLFloatArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length)
- : WebGLArray(buffer, byteOffset)
- , m_size(length)
-{
-}
-
-unsigned WebGLFloatArray::length() const {
- return m_size;
-}
-
-unsigned WebGLFloatArray::byteLength() const {
- return m_size * sizeof(float);
-}
-
-PassRefPtr<WebGLArray> WebGLFloatArray::slice(int start, int end)
-{
- unsigned offset, length;
- calculateOffsetAndLength(start, end, m_size, &offset, &length);
- clampOffsetAndNumElements<float>(buffer(), m_byteOffset, &offset, &length);
- return create(buffer(), offset, length);
-}
-
-void WebGLFloatArray::set(WebGLFloatArray* array, unsigned offset, ExceptionCode& ec) {
- setImpl(array, offset * sizeof(float), ec);
-}
-
-}
-
-#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLGetInfo.cpp b/WebCore/html/canvas/WebGLGetInfo.cpp
index 96218e5..d5fcd92 100644
--- a/WebCore/html/canvas/WebGLGetInfo.cpp
+++ b/WebCore/html/canvas/WebGLGetInfo.cpp
@@ -30,13 +30,13 @@
#include "WebGLGetInfo.h"
#include "WebGLBuffer.h"
-#include "WebGLFloatArray.h"
+#include "FloatArray.h"
#include "WebGLFramebuffer.h"
-#include "WebGLIntArray.h"
+#include "Int32Array.h"
#include "WebGLProgram.h"
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
-#include "WebGLUnsignedByteArray.h"
+#include "Uint8Array.h"
namespace WebCore {
@@ -81,7 +81,7 @@ WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLBuffer> value)
{
}
-WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLFloatArray> value)
+WebGLGetInfo::WebGLGetInfo(PassRefPtr<FloatArray> value)
: m_type(kTypeWebGLFloatArray)
, m_webglFloatArray(value)
{
@@ -93,7 +93,7 @@ WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLFramebuffer> value)
{
}
-WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLIntArray> value)
+WebGLGetInfo::WebGLGetInfo(PassRefPtr<Int32Array> value)
: m_type(kTypeWebGLIntArray)
, m_webglIntArray(value)
{
@@ -117,7 +117,7 @@ WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLTexture> value)
{
}
-WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLUnsignedByteArray> value)
+WebGLGetInfo::WebGLGetInfo(PassRefPtr<Uint8Array> value)
: m_type(kTypeWebGLUnsignedByteArray)
, m_webglUnsignedByteArray(value)
{
@@ -168,7 +168,7 @@ PassRefPtr<WebGLBuffer> WebGLGetInfo::getWebGLBuffer() const
return m_webglBuffer;
}
-PassRefPtr<WebGLFloatArray> WebGLGetInfo::getWebGLFloatArray() const
+PassRefPtr<FloatArray> WebGLGetInfo::getWebGLFloatArray() const
{
ASSERT(getType() == kTypeWebGLFloatArray);
return m_webglFloatArray;
@@ -180,7 +180,7 @@ PassRefPtr<WebGLFramebuffer> WebGLGetInfo::getWebGLFramebuffer() const
return m_webglFramebuffer;
}
-PassRefPtr<WebGLIntArray> WebGLGetInfo::getWebGLIntArray() const
+PassRefPtr<Int32Array> WebGLGetInfo::getWebGLIntArray() const
{
ASSERT(getType() == kTypeWebGLIntArray);
return m_webglIntArray;
@@ -204,7 +204,7 @@ PassRefPtr<WebGLTexture> WebGLGetInfo::getWebGLTexture() const
return m_webglTexture;
}
-PassRefPtr<WebGLUnsignedByteArray> WebGLGetInfo::getWebGLUnsignedByteArray() const
+PassRefPtr<Uint8Array> WebGLGetInfo::getWebGLUnsignedByteArray() const
{
ASSERT(getType() == kTypeWebGLUnsignedByteArray);
return m_webglUnsignedByteArray;
diff --git a/WebCore/html/canvas/WebGLGetInfo.h b/WebCore/html/canvas/WebGLGetInfo.h
index 8ac42c4..969e05d 100644
--- a/WebCore/html/canvas/WebGLGetInfo.h
+++ b/WebCore/html/canvas/WebGLGetInfo.h
@@ -32,15 +32,15 @@
#include "PlatformString.h"
#include "WebGLBuffer.h"
-#include "WebGLFloatArray.h"
+#include "FloatArray.h"
#include "WebGLFramebuffer.h"
-#include "WebGLIntArray.h"
+#include "Int32Array.h"
// FIXME: implement WebGLObjectArray
//#include "WebGLObjectArray.h"
#include "WebGLProgram.h"
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
-#include "WebGLUnsignedByteArray.h"
+#include "Uint8Array.h"
namespace WebCore {
@@ -77,15 +77,15 @@ public:
WebGLGetInfo(const String& value);
WebGLGetInfo(unsigned long value);
WebGLGetInfo(PassRefPtr<WebGLBuffer> value);
- WebGLGetInfo(PassRefPtr<WebGLFloatArray> value);
+ WebGLGetInfo(PassRefPtr<FloatArray> value);
WebGLGetInfo(PassRefPtr<WebGLFramebuffer> value);
- WebGLGetInfo(PassRefPtr<WebGLIntArray> value);
+ WebGLGetInfo(PassRefPtr<Int32Array> value);
// FIXME: implement WebGLObjectArray
// WebGLGetInfo(PassRefPtr<WebGLObjectArray> value);
WebGLGetInfo(PassRefPtr<WebGLProgram> value);
WebGLGetInfo(PassRefPtr<WebGLRenderbuffer> value);
WebGLGetInfo(PassRefPtr<WebGLTexture> value);
- WebGLGetInfo(PassRefPtr<WebGLUnsignedByteArray> value);
+ WebGLGetInfo(PassRefPtr<Uint8Array> value);
virtual ~WebGLGetInfo();
@@ -97,15 +97,15 @@ public:
const String& getString() const;
unsigned long getUnsignedLong() const;
PassRefPtr<WebGLBuffer> getWebGLBuffer() const;
- PassRefPtr<WebGLFloatArray> getWebGLFloatArray() const;
+ PassRefPtr<FloatArray> getWebGLFloatArray() const;
PassRefPtr<WebGLFramebuffer> getWebGLFramebuffer() const;
- PassRefPtr<WebGLIntArray> getWebGLIntArray() const;
+ PassRefPtr<Int32Array> getWebGLIntArray() const;
// FIXME: implement WebGLObjectArray
// PassRefPtr<WebGLObjectArray> getWebGLObjectArray() const;
PassRefPtr<WebGLProgram> getWebGLProgram() const;
PassRefPtr<WebGLRenderbuffer> getWebGLRenderbuffer() const;
PassRefPtr<WebGLTexture> getWebGLTexture() const;
- PassRefPtr<WebGLUnsignedByteArray> getWebGLUnsignedByteArray() const;
+ PassRefPtr<Uint8Array> getWebGLUnsignedByteArray() const;
private:
Type m_type;
@@ -115,15 +115,15 @@ private:
String m_string;
unsigned long m_unsignedLong;
RefPtr<WebGLBuffer> m_webglBuffer;
- RefPtr<WebGLFloatArray> m_webglFloatArray;
+ RefPtr<FloatArray> m_webglFloatArray;
RefPtr<WebGLFramebuffer> m_webglFramebuffer;
- RefPtr<WebGLIntArray> m_webglIntArray;
+ RefPtr<Int32Array> m_webglIntArray;
// FIXME: implement WebGLObjectArray
// RefPtr<WebGLObjectArray> m_webglObjectArray;
RefPtr<WebGLProgram> m_webglProgram;
RefPtr<WebGLRenderbuffer> m_webglRenderbuffer;
RefPtr<WebGLTexture> m_webglTexture;
- RefPtr<WebGLUnsignedByteArray> m_webglUnsignedByteArray;
+ RefPtr<Uint8Array> m_webglUnsignedByteArray;
};
} // namespace WebCore
diff --git a/WebCore/html/canvas/WebGLIntArray.cpp b/WebCore/html/canvas/WebGLIntArray.cpp
deleted file mode 100644
index 21b7a88..0000000
--- a/WebCore/html/canvas/WebGLIntArray.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * 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:
- * 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 "WebGLArrayBuffer.h"
-#include "WebGLIntArray.h"
-
-namespace WebCore {
-
-PassRefPtr<WebGLIntArray> WebGLIntArray::create(unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length, sizeof(int));
- return create(buffer, 0, length);
-}
-
-PassRefPtr<WebGLIntArray> WebGLIntArray::create(int* array, unsigned length)
-{
- RefPtr<WebGLIntArray> a = WebGLIntArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
-}
-
-PassRefPtr<WebGLIntArray> WebGLIntArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
- unsigned byteOffset,
- unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buf(buffer);
- if (!verifySubRange<int>(buf, byteOffset, length))
- return 0;
-
- return adoptRef(new WebGLIntArray(buf, byteOffset, length));
-}
-
-WebGLIntArray::WebGLIntArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length)
- : WebGLArray(buffer, byteOffset)
- , m_size(length)
-{
-}
-
-unsigned WebGLIntArray::length() const {
- return m_size;
-}
-
-unsigned WebGLIntArray::byteLength() const {
- return m_size * sizeof(int);
-}
-
-PassRefPtr<WebGLArray> WebGLIntArray::slice(int start, int end)
-{
- unsigned offset, length;
- calculateOffsetAndLength(start, end, m_size, &offset, &length);
- clampOffsetAndNumElements<int>(buffer(), m_byteOffset, &offset, &length);
- return create(buffer(), offset, length);
-}
-
-void WebGLIntArray::set(WebGLIntArray* array, unsigned offset, ExceptionCode& ec) {
- setImpl(array, offset * sizeof(int), ec);
-}
-
-}
-
-#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLIntArray.h b/WebCore/html/canvas/WebGLIntArray.h
deleted file mode 100644
index 5929e75..0000000
--- a/WebCore/html/canvas/WebGLIntArray.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * 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:
- * 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 WebGLIntArray_h
-#define WebGLIntArray_h
-
-#include "WebGLArray.h"
-#include <limits>
-#include <wtf/MathExtras.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class WebGLIntArray : public WebGLArray {
- public:
- virtual bool isIntArray() const { return true; }
-
- static PassRefPtr<WebGLIntArray> create(unsigned length);
- static PassRefPtr<WebGLIntArray> create(int* array, unsigned length);
- static PassRefPtr<WebGLIntArray> create(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length);
-
- int* data() { return static_cast<int*>(baseAddress()); }
-
- virtual unsigned length() const;
- virtual unsigned byteLength() const;
- virtual PassRefPtr<WebGLArray> slice(int start, int end);
-
- 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 get(unsigned index) const
- {
- return item(index);
- }
-
- int item(unsigned index) const
- {
- ASSERT(index < m_size);
- int* storage = static_cast<int*>(m_baseAddress);
- return storage[index];
- }
-
- void set(WebGLIntArray* array, unsigned offset, ExceptionCode& ec);
-
- private:
- WebGLIntArray(PassRefPtr<WebGLArrayBuffer> buffer,
- unsigned byteOffset,
- unsigned length);
- unsigned m_size;
-};
-
-} // namespace WebCore
-
-#endif // WebGLIntArray_h
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 54ba17f..fe192a6 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -39,7 +39,7 @@
#include "RenderBox.h"
#include "RenderLayer.h"
#include "WebGLActiveInfo.h"
-#include "WebGLUnsignedShortArray.h"
+#include "Uint16Array.h"
#include "WebGLBuffer.h"
#include "WebGLContextAttributes.h"
#include "WebGLFramebuffer.h"
@@ -102,6 +102,8 @@ WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
int implementationColorReadType = GraphicsContext3D::UNSIGNED_BYTE;
m_context->getIntegerv(GraphicsContext3D::IMPLEMENTATION_COLOR_READ_TYPE, &implementationColorReadType);
m_implementationColorReadType = implementationColorReadType;
+ if (!isGLES2Compliant())
+ createFallbackBlackTextures1x1();
m_context->reshape(canvas()->width(), canvas()->height());
m_context->viewport(0, 0, canvas()->width(), canvas()->height());
}
@@ -272,6 +274,8 @@ void WebGLRenderingContext::bindTexture(unsigned long target, WebGLTexture* text
return;
}
m_context->bindTexture(target, texture);
+ if (!isGLES2Compliant() && texture)
+ texture->setTarget(target);
cleanupAfterGraphicsCall(false);
}
@@ -328,7 +332,7 @@ void WebGLRenderingContext::bufferData(unsigned long target, int size, unsigned
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::bufferData(unsigned long target, WebGLArray* data, unsigned long usage, ExceptionCode& ec)
+void WebGLRenderingContext::bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER && m_boundElementArrayBuffer) {
@@ -350,7 +354,7 @@ void WebGLRenderingContext::bufferData(unsigned long target, WebGLArray* data, u
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, WebGLArray* data, ExceptionCode& ec)
+void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, ArrayBufferView* data, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER && m_boundElementArrayBuffer) {
@@ -427,6 +431,28 @@ void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode& ec
void WebGLRenderingContext::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border)
{
+ if (!isGLES2Compliant()) {
+ if (level && WebGLTexture::isNPOT(width, height)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+ RefPtr<WebGLTexture> tex = 0;
+ switch (target) {
+ case GraphicsContext3D::TEXTURE_2D:
+ tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+ break;
+ }
+ if (tex && !level) // only for level 0
+ tex->setSize(target, width, height);
+ }
m_context->copyTexImage2D(target, level, internalformat, x, y, width, height, border);
cleanupAfterGraphicsCall(false);
}
@@ -737,8 +763,10 @@ void WebGLRenderingContext::drawArrays(unsigned long mode, long first, long coun
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
-
+
+ handleNPOTTextures(true);
m_context->drawArrays(mode, first, count);
+ handleNPOTTextures(false);
cleanupAfterGraphicsCall(true);
}
@@ -758,8 +786,10 @@ void WebGLRenderingContext::drawElements(unsigned long mode, unsigned long count
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
-
+
+ handleNPOTTextures(true);
m_context->drawElements(mode, count, type, offset);
+ handleNPOTTextures(false);
cleanupAfterGraphicsCall(true);
}
@@ -882,6 +912,17 @@ void WebGLRenderingContext::frontFace(unsigned long mode)
void WebGLRenderingContext::generateMipmap(unsigned long target)
{
+ if (!isGLES2Compliant()) {
+ RefPtr<WebGLTexture> tex = 0;
+ if (target == GraphicsContext3D::TEXTURE_2D)
+ tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+ else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP)
+ tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+ if (tex && tex->isNPOT()) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ return;
+ }
+ }
m_context->generateMipmap(target);
cleanupAfterGraphicsCall(false);
}
@@ -1410,7 +1451,7 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
if (length == 1)
return WebGLGetInfo(value[0]);
else
- return WebGLGetInfo(WebGLFloatArray::create(value, length));
+ return WebGLGetInfo(FloatArray::create(value, length));
}
case GraphicsContext3D::INT: {
int value[16] = {0};
@@ -1418,7 +1459,7 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
if (length == 1)
return WebGLGetInfo(static_cast<long>(value[0]));
else
- return WebGLGetInfo(WebGLIntArray::create(value, length));
+ return WebGLGetInfo(Int32Array::create(value, length));
}
case GraphicsContext3D::BOOL: {
int value[16] = {0};
@@ -1429,7 +1470,7 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
unsigned char boolValue[16] = {0};
for (unsigned j = 0; j < length; j++)
boolValue[j] = static_cast<bool>(value[j]);
- return WebGLGetInfo(WebGLUnsignedByteArray::create(boolValue, length));
+ return WebGLGetInfo(Uint8Array::create(boolValue, length));
}
}
default:
@@ -1488,7 +1529,7 @@ WebGLGetInfo WebGLRenderingContext::getVertexAttrib(unsigned long index, unsigne
case GraphicsContext3D::CURRENT_VERTEX_ATTRIB: {
float value[4] = {0};
m_context->getVertexAttribfv(index, pname, value);
- return WebGLGetInfo(WebGLFloatArray::create(value, 4));
+ return WebGLGetInfo(FloatArray::create(value, 4));
}
default: {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
@@ -1601,7 +1642,7 @@ void WebGLRenderingContext::polygonOffset(double factor, double units)
cleanupAfterGraphicsCall(false);
}
-PassRefPtr<WebGLArray> WebGLRenderingContext::readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type)
+PassRefPtr<ArrayBufferView> WebGLRenderingContext::readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type)
{
// Validate enums.
unsigned long componentsPerPixel = 0;
@@ -1649,11 +1690,11 @@ PassRefPtr<WebGLArray> WebGLRenderingContext::readPixels(long x, long y, unsigne
// The last row needs no padding.
unsigned long totalBytes = bytesPerRow * height - padding;
unsigned long num = totalBytes / bytesPerComponent;
- RefPtr<WebGLArray> array;
+ RefPtr<ArrayBufferView> array;
if (type == GraphicsContext3D::UNSIGNED_BYTE)
- array = WebGLUnsignedByteArray::create(num);
+ array = Uint8Array::create(num);
else
- array = WebGLUnsignedShortArray::create(num);
+ array = Uint16Array::create(num);
void* data = array->baseAddress();
m_context->readPixels(x, y, width, height, format, type, data);
#if PLATFORM(CG)
@@ -1765,6 +1806,28 @@ void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsi
{
// FIXME: For now we ignore any errors returned
ec = 0;
+ if (!isGLES2Compliant()) {
+ if (level && WebGLTexture::isNPOT(width, height)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+ RefPtr<WebGLTexture> tex = 0;
+ switch (target) {
+ case GraphicsContext3D::TEXTURE_2D:
+ tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+ break;
+ }
+ if (tex && !level) // only for level 0
+ tex->setSize(target, width, height);
+ }
m_context->texImage2D(target, level, internalformat, width, height,
border, format, type, pixels);
cleanupAfterGraphicsCall(false);
@@ -1786,7 +1849,7 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, Image* i
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat,
unsigned width, unsigned height, unsigned border,
- unsigned format, unsigned type, WebGLArray* pixels, ExceptionCode& ec)
+ unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode& ec)
{
// FIXME: Need to make sure passed buffer has enough bytes to define the texture
texImage2DBase(target, level, internalformat, width, height, border,
@@ -1894,12 +1957,30 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, HTMLVide
void WebGLRenderingContext::texParameterf(unsigned target, unsigned pname, float param)
{
m_context->texParameterf(target, pname, param);
+ if (!isGLES2Compliant()) {
+ RefPtr<WebGLTexture> tex = 0;
+ if (target == GraphicsContext3D::TEXTURE_2D)
+ tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+ else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP)
+ tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+ if (tex)
+ tex->setParameterf(pname, param);
+ }
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::texParameteri(unsigned target, unsigned pname, int param)
{
m_context->texParameteri(target, pname, param);
+ if (!isGLES2Compliant()) {
+ RefPtr<WebGLTexture> tex = 0;
+ if (target == GraphicsContext3D::TEXTURE_2D)
+ tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+ else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP)
+ tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+ if (tex)
+ tex->setParameteri(pname, param);
+ }
cleanupAfterGraphicsCall(false);
}
@@ -1929,7 +2010,7 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsig
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
unsigned width, unsigned height,
- unsigned format, unsigned type, WebGLArray* pixels, ExceptionCode& ec)
+ unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode& ec)
{
// FIXME: Need to make sure passed buffer has enough bytes to define the texture
texSubImage2DBase(target, level, xoffset, yoffset, width, height, format, type, pixels ? pixels->baseAddress() : 0, ec);
@@ -2052,7 +2133,7 @@ void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2111,7 +2192,7 @@ void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, int
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2170,7 +2251,7 @@ void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2231,7 +2312,7 @@ void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, int
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2292,7 +2373,7 @@ void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2353,7 +2434,7 @@ void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, int
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2414,7 +2495,7 @@ void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2475,7 +2556,7 @@ void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, int
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2519,7 +2600,7 @@ void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, int
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2563,7 +2644,7 @@ void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2607,7 +2688,7 @@ void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2682,7 +2763,7 @@ void WebGLRenderingContext::vertexAttrib1f(unsigned long indx, float v0)
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib1fv(unsigned long indx, WebGLFloatArray* v)
+void WebGLRenderingContext::vertexAttrib1fv(unsigned long indx, FloatArray* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib1fv(indx, v->data());
@@ -2704,7 +2785,7 @@ void WebGLRenderingContext::vertexAttrib2f(unsigned long indx, float v0, float v
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib2fv(unsigned long indx, WebGLFloatArray* v)
+void WebGLRenderingContext::vertexAttrib2fv(unsigned long indx, FloatArray* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib2fv(indx, v->data());
@@ -2726,7 +2807,7 @@ void WebGLRenderingContext::vertexAttrib3f(unsigned long indx, float v0, float v
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib3fv(unsigned long indx, WebGLFloatArray* v)
+void WebGLRenderingContext::vertexAttrib3fv(unsigned long indx, FloatArray* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib3fv(indx, v->data());
@@ -2748,7 +2829,7 @@ void WebGLRenderingContext::vertexAttrib4f(unsigned long indx, float v0, float v
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib4fv(unsigned long indx, WebGLFloatArray* v)
+void WebGLRenderingContext::vertexAttrib4fv(unsigned long indx, FloatArray* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib4fv(indx, v->data());
@@ -2911,7 +2992,7 @@ WebGLGetInfo WebGLRenderingContext::getWebGLFloatArrayParameter(unsigned long pn
default:
notImplemented();
}
- return WebGLGetInfo(WebGLFloatArray::create(value, length));
+ return WebGLGetInfo(FloatArray::create(value, length));
}
WebGLGetInfo WebGLRenderingContext::getWebGLIntArrayParameter(unsigned long pname)
@@ -2930,7 +3011,7 @@ WebGLGetInfo WebGLRenderingContext::getWebGLIntArrayParameter(unsigned long pnam
default:
notImplemented();
}
- return WebGLGetInfo(WebGLIntArray::create(value, length));
+ return WebGLGetInfo(Int32Array::create(value, length));
}
WebGLGetInfo WebGLRenderingContext::getWebGLUnsignedByteArrayParameter(unsigned long pname)
@@ -2945,7 +3026,7 @@ WebGLGetInfo WebGLRenderingContext::getWebGLUnsignedByteArrayParameter(unsigned
default:
notImplemented();
}
- return WebGLGetInfo(WebGLUnsignedByteArray::create(value, length));
+ return WebGLGetInfo(Uint8Array::create(value, length));
}
bool WebGLRenderingContext::isGLES2Compliant()
@@ -2953,6 +3034,66 @@ bool WebGLRenderingContext::isGLES2Compliant()
return m_context->isGLES2Compliant();
}
+void WebGLRenderingContext::handleNPOTTextures(bool prepareToDraw)
+{
+ if (isGLES2Compliant())
+ return;
+ bool resetActiveUnit = false;
+ // FIXME: active texture unit limits should be queries instead of 32.
+ for (unsigned long ii = 0; ii < 32; ++ii) {
+ if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture()
+ || m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture()) {
+ if (ii != m_activeTextureUnit) {
+ m_context->activeTexture(ii);
+ resetActiveUnit = true;
+ } else if (resetActiveUnit) {
+ m_context->activeTexture(ii);
+ resetActiveUnit = false;
+ }
+ WebGLTexture* tex2D;
+ WebGLTexture* texCubeMap;
+ if (prepareToDraw) {
+ tex2D = m_blackTexture2D.get();
+ texCubeMap = m_blackTextureCubeMap.get();
+ } else {
+ tex2D = m_textureUnits[ii].m_texture2DBinding.get();
+ texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get();
+ }
+ if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture())
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, tex2D);
+ if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture())
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, texCubeMap);
+ }
+ }
+ if (resetActiveUnit)
+ m_context->activeTexture(m_activeTextureUnit);
+}
+
+void WebGLRenderingContext::createFallbackBlackTextures1x1()
+{
+ unsigned char black[] = {0, 0, 0, 255};
+ m_blackTexture2D = createTexture();
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_blackTexture2D.get());
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
+ m_blackTextureCubeMap = createTexture();
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, m_blackTextureCubeMap.get());
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, 0);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLRenderingContext.h b/WebCore/html/canvas/WebGLRenderingContext.h
index aefa6cc..d447529 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.h
+++ b/WebCore/html/canvas/WebGLRenderingContext.h
@@ -28,10 +28,10 @@
#include "CanvasRenderingContext.h"
#include "ExceptionCode.h"
-#include "WebGLFloatArray.h"
+#include "FloatArray.h"
#include "WebGLGetInfo.h"
-#include "WebGLIntArray.h"
-#include "WebGLUnsignedByteArray.h"
+#include "Int32Array.h"
+#include "Uint8Array.h"
#include "GraphicsContext3D.h"
#include "PlatformString.h"
@@ -77,8 +77,8 @@ class WebKitCSSMatrix;
void blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha);
void bufferData(unsigned long target, int size, unsigned long usage, ExceptionCode&);
- void bufferData(unsigned long target, WebGLArray* data, unsigned long usage, ExceptionCode&);
- void bufferSubData(unsigned long target, long offset, WebGLArray* data, ExceptionCode&);
+ void bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage, ExceptionCode&);
+ void bufferSubData(unsigned long target, long offset, ArrayBufferView* data, ExceptionCode&);
unsigned long checkFramebufferStatus(unsigned long target);
void clear(unsigned long mask);
@@ -182,7 +182,7 @@ class WebKitCSSMatrix;
void pixelStorei(unsigned long pname, long param);
void polygonOffset(double factor, double units);
- PassRefPtr<WebGLArray> readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type);
+ PassRefPtr<ArrayBufferView> readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type);
void releaseShaderCompiler();
void renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height);
@@ -198,7 +198,7 @@ class WebKitCSSMatrix;
void texImage2D(unsigned target, unsigned level, unsigned internalformat,
unsigned width, unsigned height, unsigned border,
- unsigned format, unsigned type, WebGLArray* pixels, ExceptionCode&);
+ unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode&);
void texImage2D(unsigned target, unsigned level, ImageData* pixels, ExceptionCode&);
void texImage2D(unsigned target, unsigned level, ImageData* pixels, bool flipY, ExceptionCode&);
void texImage2D(unsigned target, unsigned level, ImageData* pixels, bool flipY, bool premultiplyAlpha, ExceptionCode&);
@@ -217,7 +217,7 @@ class WebKitCSSMatrix;
void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
unsigned width, unsigned height,
- unsigned format, unsigned type, WebGLArray* pixels, ExceptionCode&);
+ unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode&);
void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, ExceptionCode&);
void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, bool flipY, ExceptionCode&);
void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, bool flipY, bool premultiplyAlpha, ExceptionCode&);
@@ -232,50 +232,50 @@ class WebKitCSSMatrix;
void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLVideoElement* video, bool flipY, bool premultiplyAlpha, ExceptionCode&);
void uniform1f(const WebGLUniformLocation* location, float x, ExceptionCode&);
- void uniform1fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode&);
+ void uniform1fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode&);
void uniform1fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&);
void uniform1i(const WebGLUniformLocation* location, int x, ExceptionCode&);
- void uniform1iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode&);
+ void uniform1iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&);
void uniform1iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&);
void uniform2f(const WebGLUniformLocation* location, float x, float y, ExceptionCode&);
- void uniform2fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode&);
+ void uniform2fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode&);
void uniform2fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&);
void uniform2i(const WebGLUniformLocation* location, int x, int y, ExceptionCode&);
- void uniform2iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode&);
+ void uniform2iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&);
void uniform2iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&);
void uniform3f(const WebGLUniformLocation* location, float x, float y, float z, ExceptionCode&);
- void uniform3fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode&);
+ void uniform3fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode&);
void uniform3fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&);
void uniform3i(const WebGLUniformLocation* location, int x, int y, int z, ExceptionCode&);
- void uniform3iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode&);
+ void uniform3iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&);
void uniform3iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&);
void uniform4f(const WebGLUniformLocation* location, float x, float y, float z, float w, ExceptionCode&);
- void uniform4fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode&);
+ void uniform4fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode&);
void uniform4fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&);
void uniform4i(const WebGLUniformLocation* location, int x, int y, int z, int w, ExceptionCode&);
- void uniform4iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode&);
+ void uniform4iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&);
void uniform4iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&);
- void uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, WebGLFloatArray* value, ExceptionCode&);
+ void uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, FloatArray* value, ExceptionCode&);
void uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&);
- void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, WebGLFloatArray* value, ExceptionCode&);
+ void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, FloatArray* value, ExceptionCode&);
void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&);
- void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, WebGLFloatArray* value, ExceptionCode&);
+ void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, FloatArray* value, ExceptionCode&);
void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&);
void useProgram(WebGLProgram*, ExceptionCode&);
void validateProgram(WebGLProgram*, ExceptionCode&);
void vertexAttrib1f(unsigned long indx, float x);
- void vertexAttrib1fv(unsigned long indx, WebGLFloatArray* values);
+ void vertexAttrib1fv(unsigned long indx, FloatArray* values);
void vertexAttrib1fv(unsigned long indx, float* values, int size);
void vertexAttrib2f(unsigned long indx, float x, float y);
- void vertexAttrib2fv(unsigned long indx, WebGLFloatArray* values);
+ void vertexAttrib2fv(unsigned long indx, FloatArray* 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, WebGLFloatArray* values);
+ void vertexAttrib3fv(unsigned long indx, FloatArray* 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, WebGLFloatArray* values);
+ void vertexAttrib4fv(unsigned long indx, FloatArray* 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, ExceptionCode&);
@@ -356,6 +356,9 @@ class WebKitCSSMatrix;
TextureUnitState m_textureUnits[32];
unsigned long m_activeTextureUnit;
+ RefPtr<WebGLTexture> m_blackTexture2D;
+ RefPtr<WebGLTexture> m_blackTextureCubeMap;
+
int m_packAlignment;
int m_unpackAlignment;
unsigned long m_implementationColorReadFormat;
@@ -382,6 +385,10 @@ class WebKitCSSMatrix;
void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode&);
+ void handleNPOTTextures(bool prepareToDraw);
+
+ void createFallbackBlackTextures1x1();
+
friend class WebGLStateRestorer;
};
diff --git a/WebCore/html/canvas/WebGLRenderingContext.idl b/WebCore/html/canvas/WebGLRenderingContext.idl
index b775378..029cae3 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.idl
+++ b/WebCore/html/canvas/WebGLRenderingContext.idl
@@ -475,9 +475,9 @@ module html {
void blendFuncSeparate(in unsigned long srcRGB, in unsigned long dstRGB, in unsigned long srcAlpha, in unsigned long dstAlpha);
#if defined(V8_BINDING) && V8_BINDING
- void bufferData(in unsigned long target, in WebGLArray data, in unsigned long usage) raises (DOMException);
+ void bufferData(in unsigned long target, in ArrayBufferView data, in unsigned long usage) raises (DOMException);
void bufferData(in unsigned long target, in long size, in unsigned long usage) raises (DOMException);
- void bufferSubData(in unsigned long target, in long offset, in WebGLArray data) raises (DOMException);
+ void bufferSubData(in unsigned long target, in long offset, in ArrayBufferView data) raises (DOMException);
#else
// FIXME: Unfork once JSC supports overload generation too.
[Custom] void bufferData() raises(DOMException);
@@ -595,7 +595,7 @@ module html {
void pixelStorei(in unsigned long pname, in long param);
void polygonOffset(in double factor, in double units);
- WebGLArray readPixels(in long x, in long y, in unsigned long width, in unsigned long height, in unsigned long format, in unsigned long type);
+ ArrayBufferView readPixels(in long x, in long y, in unsigned long width, in unsigned long height, in unsigned long format, in unsigned long type);
void releaseShaderCompiler();
void renderbufferStorage(in unsigned long target, in unsigned long internalformat, in unsigned long width, in unsigned long height);
@@ -615,7 +615,7 @@ module html {
// Supported forms:
#if defined(V8_BINDING) && V8_BINDING
void texImage2D(in unsigned long target, in long level, in unsigned long internalformat, in long width, in long height,
- in long border, in unsigned long format, in unsigned long type, in WebGLArray pixels) raises (DOMException);
+ in long border, in unsigned long format, in unsigned long type, in ArrayBufferView pixels) raises (DOMException);
void texImage2D(in unsigned long target, in long level, in ImageData pixels,
in [Optional] boolean flipY, in [Optional] boolean premultiplyAlpha) raises (DOMException);
void texImage2D(in unsigned long target, in long level, in HTMLImageElement image,
@@ -627,7 +627,7 @@ module html {
void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
in long width, in long height,
- in unsigned long format, in unsigned long type, in WebGLArray pixels) raises (DOMException);
+ in unsigned long format, in unsigned long type, in ArrayBufferView pixels) raises (DOMException);
void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
in ImageData pixels, in [Optional] boolean flipY, in [Optional] boolean premultiplyAlpha) raises (DOMException);
void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
@@ -642,37 +642,37 @@ module html {
[Custom] void texSubImage2D();
#endif
void uniform1f(in WebGLUniformLocation location, in float x) raises(DOMException);
- [Custom] void uniform1fv(in WebGLUniformLocation location, in WebGLFloatArray v) raises(DOMException);
+ [Custom] void uniform1fv(in WebGLUniformLocation location, in FloatArray v) raises(DOMException);
void uniform1i(in WebGLUniformLocation location, in long x) raises(DOMException);
- [Custom] void uniform1iv(in WebGLUniformLocation location, in WebGLIntArray v) raises(DOMException);
+ [Custom] void uniform1iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
void uniform2f(in WebGLUniformLocation location, in float x, in float y) raises(DOMException);
- [Custom] void uniform2fv(in WebGLUniformLocation location, in WebGLFloatArray v) raises(DOMException);
+ [Custom] void uniform2fv(in WebGLUniformLocation location, in FloatArray v) raises(DOMException);
void uniform2i(in WebGLUniformLocation location, in long x, in long y) raises(DOMException);
- [Custom] void uniform2iv(in WebGLUniformLocation location, in WebGLIntArray v) raises(DOMException);
+ [Custom] void uniform2iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
void uniform3f(in WebGLUniformLocation location, in float x, in float y, in float z) raises(DOMException);
- [Custom] void uniform3fv(in WebGLUniformLocation location, in WebGLFloatArray v) raises(DOMException);
+ [Custom] void uniform3fv(in WebGLUniformLocation location, in FloatArray v) raises(DOMException);
void uniform3i(in WebGLUniformLocation location, in long x, in long y, in long z) raises(DOMException);
- [Custom] void uniform3iv(in WebGLUniformLocation location, in WebGLIntArray v) raises(DOMException);
+ [Custom] void uniform3iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
void uniform4f(in WebGLUniformLocation location, in float x, in float y, in float z, in float w) raises(DOMException);
- [Custom] void uniform4fv(in WebGLUniformLocation location, in WebGLFloatArray v) raises(DOMException);
+ [Custom] void uniform4fv(in WebGLUniformLocation location, in FloatArray v) raises(DOMException);
void uniform4i(in WebGLUniformLocation location, in long x, in long y, in long z, in long w) raises(DOMException);
- [Custom] void uniform4iv(in WebGLUniformLocation location, in WebGLIntArray v) raises(DOMException);
+ [Custom] void uniform4iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
- [Custom] void uniformMatrix2fv(in WebGLUniformLocation location, in boolean transpose, in WebGLFloatArray array) raises(DOMException);
- [Custom] void uniformMatrix3fv(in WebGLUniformLocation location, in boolean transpose, in WebGLFloatArray array) raises(DOMException);
- [Custom] void uniformMatrix4fv(in WebGLUniformLocation location, in boolean transpose, in WebGLFloatArray array) raises(DOMException);
+ [Custom] void uniformMatrix2fv(in WebGLUniformLocation location, in boolean transpose, in FloatArray array) raises(DOMException);
+ [Custom] void uniformMatrix3fv(in WebGLUniformLocation location, in boolean transpose, in FloatArray array) raises(DOMException);
+ [Custom] void uniformMatrix4fv(in WebGLUniformLocation location, in boolean transpose, in FloatArray array) raises(DOMException);
void useProgram(in WebGLProgram program) raises(DOMException);
void validateProgram(in WebGLProgram program) raises(DOMException);
void vertexAttrib1f(in unsigned long indx, in float x);
- [Custom] void vertexAttrib1fv(in unsigned long indx, in WebGLFloatArray values);
+ [Custom] void vertexAttrib1fv(in unsigned long indx, in FloatArray values);
void vertexAttrib2f(in unsigned long indx, in float x, in float y);
- [Custom] void vertexAttrib2fv(in unsigned long indx, in WebGLFloatArray values);
+ [Custom] void vertexAttrib2fv(in unsigned long indx, in FloatArray values);
void vertexAttrib3f(in unsigned long indx, in float x, in float y, in float z);
- [Custom] void vertexAttrib3fv(in unsigned long indx, in WebGLFloatArray values);
+ [Custom] void vertexAttrib3fv(in unsigned long indx, in FloatArray 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 WebGLFloatArray values);
+ [Custom] void vertexAttrib4fv(in unsigned long indx, in FloatArray values);
void vertexAttribPointer(in unsigned long indx, in long size, in unsigned long type, in boolean normalized,
in long stride, in unsigned long offset) raises(DOMException);
diff --git a/WebCore/html/canvas/WebGLShortArray.cpp b/WebCore/html/canvas/WebGLShortArray.cpp
deleted file mode 100644
index a9b0f0d..0000000
--- a/WebCore/html/canvas/WebGLShortArray.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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 "WebGLArrayBuffer.h"
-#include "WebGLShortArray.h"
-
-namespace WebCore {
-
-PassRefPtr<WebGLShortArray> WebGLShortArray::create(unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length, sizeof(short));
- return create(buffer, 0, length);
-}
-
-PassRefPtr<WebGLShortArray> WebGLShortArray::create(short* array, unsigned length)
-{
- RefPtr<WebGLShortArray> a = WebGLShortArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
-}
-
-PassRefPtr<WebGLShortArray> WebGLShortArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
- unsigned byteOffset,
- unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buf(buffer);
- if (!verifySubRange<short>(buf, byteOffset, length))
- return 0;
-
- return adoptRef(new WebGLShortArray(buf, byteOffset, length));
-}
-
-WebGLShortArray::WebGLShortArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length)
- : WebGLArray(buffer, byteOffset)
- , m_size(length)
-{
-}
-
-unsigned WebGLShortArray::length() const {
- return m_size;
-}
-
-unsigned WebGLShortArray::byteLength() const {
- return m_size * sizeof(short);
-}
-
-PassRefPtr<WebGLArray> WebGLShortArray::slice(int start, int end)
-{
- unsigned offset, length;
- calculateOffsetAndLength(start, end, m_size, &offset, &length);
- clampOffsetAndNumElements<short>(buffer(), m_byteOffset, &offset, &length);
- return create(buffer(), offset, length);
-}
-
-void WebGLShortArray::set(WebGLShortArray* array, unsigned offset, ExceptionCode& ec) {
- setImpl(array, offset * sizeof(short), ec);
-}
-
-}
-
-#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLShortArray.h b/WebCore/html/canvas/WebGLShortArray.h
deleted file mode 100644
index af4befb..0000000
--- a/WebCore/html/canvas/WebGLShortArray.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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 WebGLShortArray_h
-#define WebGLShortArray_h
-
-#include "WebGLArray.h"
-#include <limits>
-#include <wtf/MathExtras.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class WebGLShortArray : public WebGLArray {
- public:
- virtual bool isShortArray() const { return true; }
-
- static PassRefPtr<WebGLShortArray> create(unsigned length);
- static PassRefPtr<WebGLShortArray> create(short* array, unsigned length);
- static PassRefPtr<WebGLShortArray> create(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length);
-
- short* data() { return static_cast<short*>(baseAddress()); }
-
- virtual unsigned length() const;
- virtual unsigned byteLength() const;
- virtual PassRefPtr<WebGLArray> slice(int start, int end);
-
- 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 get(unsigned index) const
- {
- return item(index);
- }
-
- short item(unsigned index) const
- {
- ASSERT(index < m_size);
- short* storage = static_cast<short*>(m_baseAddress);
- return storage[index];
- }
-
- void set(WebGLShortArray* array, unsigned offset, ExceptionCode& ec);
-
- private:
- WebGLShortArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length);
- unsigned m_size;
-};
-
-} // namespace WebCore
-
-#endif // WebGLShortArray_h
diff --git a/WebCore/html/canvas/WebGLTexture.cpp b/WebCore/html/canvas/WebGLTexture.cpp
index 0c58edb..4e4096b 100644
--- a/WebCore/html/canvas/WebGLTexture.cpp
+++ b/WebCore/html/canvas/WebGLTexture.cpp
@@ -40,8 +40,131 @@ PassRefPtr<WebGLTexture> WebGLTexture::create(WebGLRenderingContext* ctx)
WebGLTexture::WebGLTexture(WebGLRenderingContext* ctx)
: CanvasObject(ctx)
, cubeMapRWrapModeInitialized(false)
+ , m_target(0)
+ , m_minFilter(GraphicsContext3D::NEAREST_MIPMAP_LINEAR)
+ , m_magFilter(GraphicsContext3D::LINEAR)
+ , m_wrapS(GraphicsContext3D::REPEAT)
+ , m_wrapT(GraphicsContext3D::REPEAT)
+ , m_isNPOT(false)
+ , m_needToUseBlackTexture(false)
{
setObject(context()->graphicsContext3D()->createTexture());
+ for (int ii = 0; ii < 6; ++ii) {
+ m_width[ii] = 0;
+ m_height[ii] = 0;
+ }
+}
+
+void WebGLTexture::setTarget(unsigned long target)
+{
+ // Target is finalized the first time bindTexture() is called.
+ if (m_target)
+ return;
+ switch (target) {
+ case GraphicsContext3D::TEXTURE_2D:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP:
+ m_target = target;
+ break;
+ }
+}
+
+void WebGLTexture::setParameteri(unsigned long pname, int param)
+{
+ switch (pname) {
+ case GraphicsContext3D::TEXTURE_MIN_FILTER:
+ switch (param) {
+ case GraphicsContext3D::NEAREST:
+ case GraphicsContext3D::LINEAR:
+ case GraphicsContext3D::NEAREST_MIPMAP_NEAREST:
+ case GraphicsContext3D::LINEAR_MIPMAP_NEAREST:
+ case GraphicsContext3D::NEAREST_MIPMAP_LINEAR:
+ case GraphicsContext3D::LINEAR_MIPMAP_LINEAR:
+ m_minFilter = param;
+ break;
+ }
+ break;
+ case GraphicsContext3D::TEXTURE_MAG_FILTER:
+ switch (param) {
+ case GraphicsContext3D::NEAREST:
+ case GraphicsContext3D::LINEAR:
+ m_magFilter = param;
+ break;
+ }
+ break;
+ case GraphicsContext3D::TEXTURE_WRAP_S:
+ switch (param) {
+ case GraphicsContext3D::CLAMP_TO_EDGE:
+ case GraphicsContext3D::MIRRORED_REPEAT:
+ case GraphicsContext3D::REPEAT:
+ m_wrapS = param;
+ break;
+ }
+ break;
+ case GraphicsContext3D::TEXTURE_WRAP_T:
+ switch (param) {
+ case GraphicsContext3D::CLAMP_TO_EDGE:
+ case GraphicsContext3D::MIRRORED_REPEAT:
+ case GraphicsContext3D::REPEAT:
+ m_wrapT = param;
+ break;
+ }
+ break;
+ default:
+ return;
+ }
+ updateNPOTStates();
+}
+
+void WebGLTexture::setParameterf(unsigned long pname, float param)
+{
+ int iparam = static_cast<int>(param);
+ setParameteri(pname, iparam);
+}
+
+void WebGLTexture::setSize(unsigned long target, unsigned width, unsigned height)
+{
+ if (!width || !height)
+ return;
+ int iTarget = -1;
+ if (m_target == GraphicsContext3D::TEXTURE_2D) {
+ if (target == GraphicsContext3D::TEXTURE_2D)
+ iTarget = 0;
+ } else if (m_target == GraphicsContext3D::TEXTURE_CUBE_MAP && width == height) {
+ switch (target) {
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X:
+ iTarget = 0;
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X:
+ iTarget = 1;
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y:
+ iTarget = 2;
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ iTarget = 3;
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z:
+ iTarget = 4;
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ iTarget = 5;
+ break;
+ }
+ }
+ if (iTarget < 0)
+ return;
+ m_width[iTarget] = width;
+ m_height[iTarget] = height;
+ updateNPOTStates();
+}
+
+bool WebGLTexture::isNPOT(unsigned width, unsigned height)
+{
+ if (!width || !height)
+ return false;
+ if ((width & (width - 1)) || (height & (height - 1)))
+ return true;
+ return false;
}
void WebGLTexture::_deleteObject(Platform3DObject object)
@@ -49,6 +172,30 @@ void WebGLTexture::_deleteObject(Platform3DObject object)
context()->graphicsContext3D()->deleteTexture(object);
}
+void WebGLTexture::updateNPOTStates()
+{
+ int numTargets = 0;
+ if (m_target == GraphicsContext3D::TEXTURE_2D)
+ numTargets = 1;
+ else if (m_target == GraphicsContext3D::TEXTURE_CUBE_MAP)
+ numTargets = 6;
+ m_isNPOT = false;
+ unsigned w0 = m_width[0], h0 = m_height[0];
+ for (int ii = 0; ii < numTargets; ++ii) {
+ if (ii && (!m_width[ii] || !m_height[ii] || m_width[ii] != w0 || m_height[ii] != h0)) {
+ // We only set NPOT for complete cube map textures.
+ m_isNPOT = false;
+ break;
+ }
+ if (isNPOT(m_width[ii], m_height[ii]))
+ m_isNPOT = true;
+ }
+ m_needToUseBlackTexture = false;
+ if (m_isNPOT && ((m_minFilter != GraphicsContext3D::NEAREST && m_minFilter != GraphicsContext3D::LINEAR)
+ || m_wrapS != GraphicsContext3D::CLAMP_TO_EDGE || m_wrapT != GraphicsContext3D::CLAMP_TO_EDGE))
+ m_needToUseBlackTexture = true;
+}
+
}
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLTexture.h b/WebCore/html/canvas/WebGLTexture.h
index b3c1f05..864533e 100644
--- a/WebCore/html/canvas/WebGLTexture.h
+++ b/WebCore/html/canvas/WebGLTexture.h
@@ -47,6 +47,17 @@ namespace WebCore {
cubeMapRWrapModeInitialized = initialized;
}
+ void setTarget(unsigned long);
+ void setParameteri(unsigned long pname, int param);
+ void setParameterf(unsigned long pname, float param);
+ void setSize(unsigned long target, unsigned width, unsigned height);
+
+ static bool isNPOT(unsigned, unsigned);
+
+ bool isNPOT() const { return m_isNPOT; }
+ // Determine if texture sampling should always return [0, 0, 0, 1] (OpenGL ES 2.0 Sec 3.8.2).
+ bool needToUseBlackTexture() const { return m_needToUseBlackTexture; }
+
protected:
WebGLTexture(WebGLRenderingContext*);
@@ -55,7 +66,22 @@ namespace WebCore {
private:
virtual bool isTexture() const { return true; }
+ void updateNPOTStates();
+
bool cubeMapRWrapModeInitialized;
+
+ unsigned long m_target;
+
+ int m_minFilter;
+ int m_magFilter;
+ int m_wrapS;
+ int m_wrapT;
+
+ unsigned m_width[6];
+ unsigned m_height[6];
+
+ bool m_isNPOT;
+ bool m_needToUseBlackTexture;
};
} // namespace WebCore
diff --git a/WebCore/html/canvas/WebGLUnsignedByteArray.cpp b/WebCore/html/canvas/WebGLUnsignedByteArray.cpp
deleted file mode 100644
index 81e0135..0000000
--- a/WebCore/html/canvas/WebGLUnsignedByteArray.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * 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:
- * 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 "WebGLArrayBuffer.h"
-#include "WebGLUnsignedByteArray.h"
-
-namespace WebCore {
-
-PassRefPtr<WebGLUnsignedByteArray> WebGLUnsignedByteArray::create(unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length, sizeof(unsigned char));
- return create(buffer, 0, length);
-}
-
-PassRefPtr<WebGLUnsignedByteArray> WebGLUnsignedByteArray::create(unsigned char* array, unsigned length)
-{
- RefPtr<WebGLUnsignedByteArray> a = WebGLUnsignedByteArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
-}
-
-PassRefPtr<WebGLUnsignedByteArray> WebGLUnsignedByteArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
- unsigned byteOffset,
- unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buf(buffer);
- if (!verifySubRange<unsigned char>(buf, byteOffset, length))
- return 0;
-
- return adoptRef(new WebGLUnsignedByteArray(buf, byteOffset, length));
-}
-
-WebGLUnsignedByteArray::WebGLUnsignedByteArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length)
- : WebGLArray(buffer, byteOffset)
- , m_size(length)
-{
-}
-
-unsigned WebGLUnsignedByteArray::length() const {
- return m_size;
-}
-
-unsigned WebGLUnsignedByteArray::byteLength() const {
- return m_size * sizeof(unsigned char);
-}
-
-PassRefPtr<WebGLArray> WebGLUnsignedByteArray::slice(int start, int end)
-{
- unsigned offset, length;
- calculateOffsetAndLength(start, end, m_size, &offset, &length);
- clampOffsetAndNumElements<unsigned char>(buffer(), m_byteOffset, &offset, &length);
- return create(buffer(), offset, length);
-}
-
-void WebGLUnsignedByteArray::set(WebGLUnsignedByteArray* array, unsigned offset, ExceptionCode& ec) {
- setImpl(array, offset * sizeof(unsigned char), ec);
-}
-
-}
-
-#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLUnsignedByteArray.h b/WebCore/html/canvas/WebGLUnsignedByteArray.h
deleted file mode 100644
index 505b2fd..0000000
--- a/WebCore/html/canvas/WebGLUnsignedByteArray.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * 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:
- * 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 WebGLUnsignedByteArray_h
-#define WebGLUnsignedByteArray_h
-
-#include "WebGLArray.h"
-#include <limits>
-#include <wtf/MathExtras.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class WebGLUnsignedByteArray : public WebGLArray {
- public:
- virtual bool isUnsignedByteArray() const { return true; }
-
- static PassRefPtr<WebGLUnsignedByteArray> create(unsigned length);
- static PassRefPtr<WebGLUnsignedByteArray> create(unsigned char* array, unsigned length);
- static PassRefPtr<WebGLUnsignedByteArray> create(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length);
-
- unsigned char* data() { return static_cast<unsigned char*>(baseAddress()); }
-
- virtual unsigned length() const;
- virtual unsigned byteLength() const;
- virtual PassRefPtr<WebGLArray> slice(int start, int end);
-
- 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 get(unsigned index) const
- {
- return item(index);
- }
-
- unsigned char item(unsigned index) const
- {
- ASSERT(index < m_size);
- unsigned char* storage = static_cast<unsigned char*>(m_baseAddress);
- return storage[index];
- }
-
- void set(WebGLUnsignedByteArray* array, unsigned offset, ExceptionCode& ec);
-
- private:
- WebGLUnsignedByteArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length);
- unsigned m_size;
-};
-
-} // namespace WebCore
-
-#endif // WebGLUnsignedByteArray_h
diff --git a/WebCore/html/canvas/WebGLUnsignedIntArray.cpp b/WebCore/html/canvas/WebGLUnsignedIntArray.cpp
deleted file mode 100644
index 59d895f..0000000
--- a/WebCore/html/canvas/WebGLUnsignedIntArray.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * 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:
- * 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 "WebGLArrayBuffer.h"
-#include "WebGLUnsignedIntArray.h"
-
-namespace WebCore {
-
-PassRefPtr<WebGLUnsignedIntArray> WebGLUnsignedIntArray::create(unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length, sizeof(unsigned int));
- return create(buffer, 0, length);
-}
-
-PassRefPtr<WebGLUnsignedIntArray> WebGLUnsignedIntArray::create(unsigned int* array, unsigned length)
-{
- RefPtr<WebGLUnsignedIntArray> a = WebGLUnsignedIntArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
-}
-
-PassRefPtr<WebGLUnsignedIntArray> WebGLUnsignedIntArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
- unsigned byteOffset,
- unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buf(buffer);
- if (!verifySubRange<unsigned int>(buf, byteOffset, length))
- return 0;
-
- return adoptRef(new WebGLUnsignedIntArray(buf, byteOffset, length));
-}
-
-WebGLUnsignedIntArray::WebGLUnsignedIntArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length)
- : WebGLArray(buffer, byteOffset)
- , m_size(length)
-{
-}
-
-unsigned WebGLUnsignedIntArray::length() const {
- return m_size;
-}
-
-unsigned WebGLUnsignedIntArray::byteLength() const {
- return m_size * sizeof(unsigned int);
-}
-
-PassRefPtr<WebGLArray> WebGLUnsignedIntArray::slice(int start, int end)
-{
- unsigned offset, length;
- calculateOffsetAndLength(start, end, m_size, &offset, &length);
- clampOffsetAndNumElements<unsigned int>(buffer(), m_byteOffset, &offset, &length);
- return create(buffer(), offset, length);
-}
-
-void WebGLUnsignedIntArray::set(WebGLUnsignedIntArray* array, unsigned offset, ExceptionCode& ec) {
- setImpl(array, offset * sizeof(unsigned int), ec);
-}
-
-}
-
-#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLUnsignedIntArray.h b/WebCore/html/canvas/WebGLUnsignedIntArray.h
deleted file mode 100644
index 6e9b220..0000000
--- a/WebCore/html/canvas/WebGLUnsignedIntArray.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * 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:
- * 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 WebGLUnsignedIntArray_h
-#define WebGLUnsignedIntArray_h
-
-#include "WebGLArray.h"
-#include <limits>
-#include <wtf/MathExtras.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class WebGLUnsignedIntArray : public WebGLArray {
- public:
- virtual bool isUnsignedIntArray() const { return true; }
-
- static PassRefPtr<WebGLUnsignedIntArray> create(unsigned length);
- static PassRefPtr<WebGLUnsignedIntArray> create(unsigned int* array, unsigned length);
- static PassRefPtr<WebGLUnsignedIntArray> create(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length);
-
- unsigned int* data() { return static_cast<unsigned int*>(baseAddress()); }
-
- virtual unsigned length() const;
- virtual unsigned byteLength() const;
- virtual PassRefPtr<WebGLArray> slice(int start, int end);
-
- 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 get(unsigned index) const
- {
- return item(index);
- }
-
- unsigned int item(unsigned index) const
- {
- ASSERT(index < m_size);
- unsigned int* storage = static_cast<unsigned int*>(m_baseAddress);
- return storage[index];
- }
-
- void set(WebGLUnsignedIntArray* array, unsigned offset, ExceptionCode& ec);
-
- private:
- WebGLUnsignedIntArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length);
- unsigned m_size;
-};
-
-} // namespace WebCore
-
-#endif // WebGLUnsignedIntArray_h
diff --git a/WebCore/html/canvas/WebGLUnsignedShortArray.cpp b/WebCore/html/canvas/WebGLUnsignedShortArray.cpp
deleted file mode 100644
index c283a81..0000000
--- a/WebCore/html/canvas/WebGLUnsignedShortArray.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * 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:
- * 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 "WebGLArrayBuffer.h"
-#include "WebGLUnsignedShortArray.h"
-
-namespace WebCore {
-
-PassRefPtr<WebGLUnsignedShortArray> WebGLUnsignedShortArray::create(unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length, sizeof(unsigned short));
- return create(buffer, 0, length);
-}
-
-PassRefPtr<WebGLUnsignedShortArray> WebGLUnsignedShortArray::create(unsigned short* array, unsigned length)
-{
- RefPtr<WebGLUnsignedShortArray> a = WebGLUnsignedShortArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
-}
-
-PassRefPtr<WebGLUnsignedShortArray> WebGLUnsignedShortArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
- unsigned byteOffset,
- unsigned length)
-{
- RefPtr<WebGLArrayBuffer> buf(buffer);
- if (!verifySubRange<unsigned short>(buf, byteOffset, length))
- return 0;
-
- return adoptRef(new WebGLUnsignedShortArray(buf, byteOffset, length));
-}
-
-WebGLUnsignedShortArray::WebGLUnsignedShortArray(PassRefPtr<WebGLArrayBuffer> buffer,
- unsigned byteOffset,
- unsigned length)
- : WebGLArray(buffer, byteOffset)
- , m_size(length)
-{
-}
-
-unsigned WebGLUnsignedShortArray::length() const {
- return m_size;
-}
-
-unsigned WebGLUnsignedShortArray::byteLength() const {
- return m_size * sizeof(unsigned short);
-}
-
-PassRefPtr<WebGLArray> WebGLUnsignedShortArray::slice(int start, int end)
-{
- unsigned offset, length;
- calculateOffsetAndLength(start, end, m_size, &offset, &length);
- clampOffsetAndNumElements<unsigned short>(buffer(), m_byteOffset, &offset, &length);
- return create(buffer(), offset, length);
-}
-
-void WebGLUnsignedShortArray::set(WebGLUnsignedShortArray* array, unsigned offset, ExceptionCode& ec) {
- setImpl(array, offset * sizeof(unsigned short), ec);
-}
-
-}
-
-#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLUnsignedShortArray.h b/WebCore/html/canvas/WebGLUnsignedShortArray.h
deleted file mode 100644
index 94b428a..0000000
--- a/WebCore/html/canvas/WebGLUnsignedShortArray.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * 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:
- * 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 WebGLUnsignedShortArray_h
-#define WebGLUnsignedShortArray_h
-
-#include "WebGLArray.h"
-#include <limits>
-#include <wtf/MathExtras.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class WebGLUnsignedShortArray : public WebGLArray {
- public:
- virtual bool isUnsignedShortArray() const { return true; }
-
- static PassRefPtr<WebGLUnsignedShortArray> create(unsigned length);
- static PassRefPtr<WebGLUnsignedShortArray> create(unsigned short* array, unsigned length);
- static PassRefPtr<WebGLUnsignedShortArray> create(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset, unsigned length);
-
- unsigned short* data() { return static_cast<unsigned short*>(baseAddress()); }
-
- virtual unsigned length() const;
- virtual unsigned byteLength() const;
- virtual PassRefPtr<WebGLArray> slice(int start, int end);
-
- 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 get(unsigned index) const
- {
- return item(index);
- }
-
- unsigned short item(unsigned index) const
- {
- ASSERT(index < m_size);
- unsigned short* storage = static_cast<unsigned short*>(m_baseAddress);
- return storage[index];
- }
-
- void set(WebGLUnsignedShortArray* array, unsigned offset, ExceptionCode& ec);
-
- private:
- WebGLUnsignedShortArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset,unsigned length);
- unsigned m_size;
-};
-
-} // namespace WebCore
-
-#endif // WebGLUnsignedShortArray_h