diff options
Diffstat (limited to 'Source/WebCore/html')
40 files changed, 1206 insertions, 819 deletions
diff --git a/Source/WebCore/html/DOMURL.cpp b/Source/WebCore/html/DOMURL.cpp new file mode 100644 index 0000000..87f9f45 --- /dev/null +++ b/Source/WebCore/html/DOMURL.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2011 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 AND ITS 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 APPLE OR ITS 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(BLOB) + +#include "DOMURL.h" + +#include "KURL.h" +#include "ScriptExecutionContext.h" + +namespace WebCore { + +DOMURL::DOMURL(ScriptExecutionContext* scriptExecutionContext) + : m_scriptExecutionContext(scriptExecutionContext) +{ +} + +String DOMURL::createObjectURL(Blob* blob) +{ + if (!m_scriptExecutionContext) + return String(); + return m_scriptExecutionContext->createPublicBlobURL(blob).string(); +} + +void DOMURL::revokeObjectURL(const String& urlString) +{ + if (!m_scriptExecutionContext) + return; + m_scriptExecutionContext->revokePublicBlobURL(KURL(KURL(), urlString)); +} + +} // namespace WebCore + +#endif // ENABLE(BLOB) diff --git a/Source/WebCore/html/DOMURL.h b/Source/WebCore/html/DOMURL.h new file mode 100644 index 0000000..57f3000 --- /dev/null +++ b/Source/WebCore/html/DOMURL.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011 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 AND ITS 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 APPLE OR ITS 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 DOMURL_h +#define DOMURL_h + +#if ENABLE(BLOB) + +#include "PlatformString.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + +class Blob; +class ScriptExecutionContext; + +class DOMURL : public RefCounted<DOMURL> { +public: + static PassRefPtr<DOMURL> create(ScriptExecutionContext* scriptExecutionContext) { return adoptRef(new DOMURL(scriptExecutionContext)); } + + String createObjectURL(Blob*); + void revokeObjectURL(const String&); + +private: + explicit DOMURL(ScriptExecutionContext*); + + ScriptExecutionContext* m_scriptExecutionContext; +}; + +} // namespace WebCore + +#endif // ENABLE(BLOB) + +#endif // DOMURL_h diff --git a/Source/WebCore/html/DOMURL.idl b/Source/WebCore/html/DOMURL.idl new file mode 100644 index 0000000..75945b7 --- /dev/null +++ b/Source/WebCore/html/DOMURL.idl @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2011 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 AND ITS 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 APPLE OR ITS 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=BLOB, + OmitConstructor, + GenerateNativeConverter, + GenerateToJS, + NoStaticTables + ] DOMURL { + [ConvertNullStringTo=Undefined] DOMString createObjectURL(in Blob blob); + void revokeObjectURL(in DOMString url); + }; +} diff --git a/Source/WebCore/html/FormAssociatedElement.cpp b/Source/WebCore/html/FormAssociatedElement.cpp index a97c0e2..574dfe5 100644 --- a/Source/WebCore/html/FormAssociatedElement.cpp +++ b/Source/WebCore/html/FormAssociatedElement.cpp @@ -52,6 +52,13 @@ ValidityState* FormAssociatedElement::validity() return m_validityState.get(); } +void FormAssociatedElement::willMoveToNewOwnerDocument() +{ + HTMLElement* element = toHTMLElement(this); + if (element->fastHasAttribute(formAttr)) + element->document()->unregisterFormElementWithFormAttribute(this); +} + void FormAssociatedElement::insertedIntoTree() { HTMLElement* element = toHTMLElement(this); @@ -140,6 +147,7 @@ void FormAssociatedElement::formAttributeChanged() m_form = element->findFormAncestor(); if (m_form) form()->registerFormElement(this); + element->document()->unregisterFormElementWithFormAttribute(this); } else resetFormOwner(0); } diff --git a/Source/WebCore/html/FormAssociatedElement.h b/Source/WebCore/html/FormAssociatedElement.h index 3c8c6e1..873bdf4 100644 --- a/Source/WebCore/html/FormAssociatedElement.h +++ b/Source/WebCore/html/FormAssociatedElement.h @@ -63,6 +63,8 @@ protected: void insertedIntoTree(); void removedFromTree(); + void willMoveToNewOwnerDocument(); + void setForm(HTMLFormElement* form) { m_form = form; } void removeFromForm(); void formAttributeChanged(); diff --git a/Source/WebCore/html/HTMLElement.cpp b/Source/WebCore/html/HTMLElement.cpp index a504f75..af3115c 100644 --- a/Source/WebCore/html/HTMLElement.cpp +++ b/Source/WebCore/html/HTMLElement.cpp @@ -376,6 +376,39 @@ void HTMLElement::setOuterHTML(const String& html, ExceptionCode& ec) } } +PassRefPtr<DocumentFragment> HTMLElement::textToFragment(const String& text, ExceptionCode& ec) +{ + RefPtr<DocumentFragment> fragment = DocumentFragment::create(document()); + unsigned int i, length = text.length(); + UChar c = 0; + for (unsigned int start = 0; start < length; ) { + + // Find next line break. + for (i = start; i < length; i++) { + c = text[i]; + if (c == '\r' || c == '\n') + break; + } + + fragment->appendChild(Text::create(document(), text.substring(start, i - start)), ec); + if (ec) + return 0; + + if (c == '\r' || c == '\n') { + fragment->appendChild(HTMLBRElement::create(document()), ec); + if (ec) + return 0; + // Make sure \r\n doesn't result in two line breaks. + if (c == '\r' && i + 1 < length && text[i + 1] == '\n') + i++; + } + + start = i + 1; // Character after line break. + } + + return fragment; +} + void HTMLElement::setInnerText(const String& text, ExceptionCode& ec) { if (ieForbidsInsertHTML()) { @@ -419,30 +452,25 @@ void HTMLElement::setInnerText(const String& text, ExceptionCode& ec) // Add text nodes and <br> elements. ec = 0; - RefPtr<DocumentFragment> fragment = DocumentFragment::create(document()); - int lineStart = 0; - UChar prev = 0; - int length = text.length(); - for (int i = 0; i < length; ++i) { - UChar c = text[i]; - if (c == '\n' || c == '\r') { - if (i > lineStart) { - fragment->appendChild(Text::create(document(), text.substring(lineStart, i - lineStart)), ec); - if (ec) - return; - } - if (!(c == '\n' && i != 0 && prev == '\r')) { - fragment->appendChild(HTMLBRElement::create(document()), ec); - if (ec) - return; - } - lineStart = i + 1; - } - prev = c; - } - if (length > lineStart) - fragment->appendChild(Text::create(document(), text.substring(lineStart, length - lineStart)), ec); - replaceChildrenWithFragment(this, fragment.release(), ec); + RefPtr<DocumentFragment> fragment = textToFragment(text, ec); + if (!ec) + replaceChildrenWithFragment(this, fragment.release(), ec); +} + +static void mergeWithNextTextNode(PassRefPtr<Node> node, ExceptionCode& ec) +{ + ASSERT(node && node->isTextNode()); + Node* next = node->nextSibling(); + if (!next || !next->isTextNode()) + return; + + RefPtr<Text> textNode = static_cast<Text*>(node.get()); + RefPtr<Text> textNext = static_cast<Text*>(next); + textNode->appendData(textNext->data(), ec); + if (ec) + return; + if (textNext->parentNode()) // Might have been removed by mutation event. + textNext->remove(ec); } void HTMLElement::setOuterText(const String &text, ExceptionCode& ec) @@ -465,39 +493,29 @@ void HTMLElement::setOuterText(const String &text, ExceptionCode& ec) return; } - // FIXME: This creates a new text node even when the text is empty. - // FIXME: This creates a single text node even when the text has CR and LF - // characters in it. Instead it should create <br> elements. - RefPtr<Text> t = Text::create(document(), text); + RefPtr<Node> prev = previousSibling(); + RefPtr<Node> next = nextSibling(); + RefPtr<Node> newChild; ec = 0; - parent->replaceChild(t, this, ec); + + // Convert text to fragment with <br> tags instead of linebreaks if needed. + if (text.contains('\r') || text.contains('\n')) + newChild = textToFragment(text, ec); + else + newChild = Text::create(document(), text); + + if (!this || !parentNode()) + ec = HIERARCHY_REQUEST_ERR; if (ec) return; + parent->replaceChild(newChild.release(), this, ec); - // Is previous node a text node? If so, merge into it. - Node* prev = t->previousSibling(); - if (prev && prev->isTextNode()) { - Text* textPrev = static_cast<Text*>(prev); - textPrev->appendData(t->data(), ec); - if (ec) - return; - t->remove(ec); - if (ec) - return; - t = textPrev; - } + RefPtr<Node> node = next ? next->previousSibling() : 0; + if (!ec && node && node->isTextNode()) + mergeWithNextTextNode(node.release(), ec); - // Is next node a text node? If so, merge it in. - Node* next = t->nextSibling(); - if (next && next->isTextNode()) { - Text* textNext = static_cast<Text*>(next); - t->appendData(textNext->data(), ec); - if (ec) - return; - textNext->remove(ec); - if (ec) - return; - } + if (!ec && prev && prev->isTextNode()) + mergeWithNextTextNode(prev.release(), ec); } Node* HTMLElement::insertAdjacent(const String& where, Node* newChild, ExceptionCode& ec) diff --git a/Source/WebCore/html/HTMLElement.h b/Source/WebCore/html/HTMLElement.h index 63ce110..a64db2c 100644 --- a/Source/WebCore/html/HTMLElement.h +++ b/Source/WebCore/html/HTMLElement.h @@ -100,6 +100,7 @@ private: virtual HTMLFormElement* virtualForm() const; Node* insertAdjacent(const String& where, Node* newChild, ExceptionCode&); + PassRefPtr<DocumentFragment> textToFragment(const String&, ExceptionCode&); }; inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document* document) diff --git a/Source/WebCore/html/HTMLFormControlElement.cpp b/Source/WebCore/html/HTMLFormControlElement.cpp index 8556c1e..b3ad7c8 100644 --- a/Source/WebCore/html/HTMLFormControlElement.cpp +++ b/Source/WebCore/html/HTMLFormControlElement.cpp @@ -80,7 +80,7 @@ HTMLFormControlElement::~HTMLFormControlElement() void HTMLFormControlElement::detach() { - hideVisibleValidationMessage(); + m_validationMessage = 0; HTMLElement::detach(); } @@ -144,6 +144,12 @@ void HTMLFormControlElement::attach() focus(); } +void HTMLFormControlElement::willMoveToNewOwnerDocument() +{ + FormAssociatedElement::willMoveToNewOwnerDocument(); + HTMLElement::willMoveToNewOwnerDocument(); +} + void HTMLFormControlElement::insertedIntoTree(bool deep) { FormAssociatedElement::insertedIntoTree(); @@ -304,18 +310,24 @@ void HTMLFormControlElement::updateVisibleValidationMessage() message.append(title); } } + if (message.isEmpty()) { + hideVisibleValidationMessage(); + return; + } if (!m_validationMessage) { m_validationMessage = ValidationMessage::create(this); m_validationMessage->setMessage(message); - } else if (message.isEmpty()) - hideVisibleValidationMessage(); - else if (m_validationMessage->message() != message) + } else { + // Call setMessage() even if m_validationMesage->message() == message + // because the existing message might be to be hidden. m_validationMessage->setMessage(message); + } } void HTMLFormControlElement::hideVisibleValidationMessage() { - m_validationMessage = 0; + if (m_validationMessage) + m_validationMessage->requestToHideMessage(); } String HTMLFormControlElement::visibleValidationMessage() const diff --git a/Source/WebCore/html/HTMLFormControlElement.h b/Source/WebCore/html/HTMLFormControlElement.h index e5d741b..8403b84 100644 --- a/Source/WebCore/html/HTMLFormControlElement.h +++ b/Source/WebCore/html/HTMLFormControlElement.h @@ -109,6 +109,7 @@ protected: virtual void attach(); virtual void insertedIntoTree(bool deep); virtual void removedFromTree(bool deep); + virtual void willMoveToNewOwnerDocument(); virtual bool isKeyboardFocusable(KeyboardEvent*) const; virtual bool isMouseFocusable() const; diff --git a/Source/WebCore/html/HTMLInputElement.cpp b/Source/WebCore/html/HTMLInputElement.cpp index 49888f1..c7a1a86 100644 --- a/Source/WebCore/html/HTMLInputElement.cpp +++ b/Source/WebCore/html/HTMLInputElement.cpp @@ -455,7 +455,9 @@ void HTMLInputElement::updateType() bool neededActivationCallback = needsActivationCallback(); bool didRespectHeightAndWidth = m_inputType->shouldRespectHeightAndWidthAttributes(); + m_inputType->destroyShadowSubtree(); m_inputType = newType.release(); + m_inputType->createShadowSubtree(); setNeedsWillValidateCheck(); @@ -637,9 +639,14 @@ void HTMLInputElement::parseMappedAttribute(Attribute* attr) #endif #if ENABLE(INPUT_SPEECH) else if (attr->name() == webkitspeechAttr) { - if (renderer()) - toRenderTextControlSingleLine(renderer())->speechAttributeChanged(); - setNeedsStyleRecalc(); + if (renderer()) { + // This renderer and its children have quite different layouts and styles depending on + // whether the speech button is visible or not. So we reset the whole thing and recreate + // to get the right styles and layout. + detach(); + attach(); + } + setNeedsStyleRecalc(); } else if (attr->name() == onwebkitspeechchangeAttr) setAttributeEventListener(eventNames().webkitspeechchangeEvent, createAttributeEventListener(this, attr)); #endif diff --git a/Source/WebCore/html/HTMLObjectElement.cpp b/Source/WebCore/html/HTMLObjectElement.cpp index 2c6e6de..a1dde1a 100644 --- a/Source/WebCore/html/HTMLObjectElement.cpp +++ b/Source/WebCore/html/HTMLObjectElement.cpp @@ -479,6 +479,12 @@ void HTMLObjectElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) con addSubresourceURL(urls, document()->completeURL(useMap)); } +void HTMLObjectElement::willMoveToNewOwnerDocument() +{ + FormAssociatedElement::willMoveToNewOwnerDocument(); + HTMLPlugInImageElement::willMoveToNewOwnerDocument(); +} + void HTMLObjectElement::insertedIntoTree(bool deep) { FormAssociatedElement::insertedIntoTree(); diff --git a/Source/WebCore/html/HTMLObjectElement.h b/Source/WebCore/html/HTMLObjectElement.h index d5797ff..ff773f1 100644 --- a/Source/WebCore/html/HTMLObjectElement.h +++ b/Source/WebCore/html/HTMLObjectElement.h @@ -73,6 +73,7 @@ private: virtual bool rendererIsNeeded(RenderStyle*); virtual void insertedIntoDocument(); virtual void removedFromDocument(); + virtual void willMoveToNewOwnerDocument(); virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); diff --git a/Source/WebCore/html/HTMLPlugInImageElement.h b/Source/WebCore/html/HTMLPlugInImageElement.h index 377fd99..f394d40 100644 --- a/Source/WebCore/html/HTMLPlugInImageElement.h +++ b/Source/WebCore/html/HTMLPlugInImageElement.h @@ -58,12 +58,13 @@ protected: bool allowedToLoadFrameURL(const String& url); bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType); + virtual void willMoveToNewOwnerDocument(); + private: virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); virtual void recalcStyle(StyleChange); virtual void finishParsingChildren(); - virtual void willMoveToNewOwnerDocument(); void updateWidgetIfNecessary(); virtual bool useFallbackContent() const { return false; } diff --git a/Source/WebCore/html/HTMLStyleElement.cpp b/Source/WebCore/html/HTMLStyleElement.cpp index 7c2512b..0f256e1 100644 --- a/Source/WebCore/html/HTMLStyleElement.cpp +++ b/Source/WebCore/html/HTMLStyleElement.cpp @@ -27,8 +27,9 @@ #include "Attribute.h" #include "Document.h" #include "HTMLNames.h" -#include "ScriptableDocumentParser.h" #include "ScriptEventListener.h" +#include "ScriptableDocumentParser.h" + namespace WebCore { @@ -104,4 +105,19 @@ void HTMLStyleElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons styleSheet->addSubresourceStyleURLs(urls); } +bool HTMLStyleElement::disabled() const +{ + StyleSheet* styleSheet = sheet(); + if (!styleSheet) + return false; + + return styleSheet->disabled(); +} + +void HTMLStyleElement::setDisabled(bool setDisabled) +{ + if (StyleSheet* styleSheet = sheet()) + styleSheet->setDisabled(setDisabled); +} + } diff --git a/Source/WebCore/html/HTMLStyleElement.h b/Source/WebCore/html/HTMLStyleElement.h index 3d6958f..c9b5649 100644 --- a/Source/WebCore/html/HTMLStyleElement.h +++ b/Source/WebCore/html/HTMLStyleElement.h @@ -39,6 +39,9 @@ public: using StyleElement::sheet; + bool disabled() const; + void setDisabled(bool); + private: HTMLStyleElement(const QualifiedName&, Document*, bool createdByParser); diff --git a/Source/WebCore/html/HTMLStyleElement.idl b/Source/WebCore/html/HTMLStyleElement.idl index d78e9d3..459801e 100644 --- a/Source/WebCore/html/HTMLStyleElement.idl +++ b/Source/WebCore/html/HTMLStyleElement.idl @@ -21,7 +21,7 @@ module html { interface [CustomMarkFunction] HTMLStyleElement : HTMLElement { - attribute [Reflect] boolean disabled; + attribute boolean disabled; attribute [Reflect] DOMString media; attribute [Reflect] DOMString type; diff --git a/Source/WebCore/html/InputType.cpp b/Source/WebCore/html/InputType.cpp index be86399..729f204 100644 --- a/Source/WebCore/html/InputType.cpp +++ b/Source/WebCore/html/InputType.cpp @@ -349,6 +349,15 @@ RenderObject* InputType::createRenderer(RenderArena*, RenderStyle* style) const return RenderObject::createObject(element(), style); } +void InputType::createShadowSubtree() +{ +} + +void InputType::destroyShadowSubtree() +{ + element()->setShadowRoot(0); +} + double InputType::parseToDouble(const String&, double defaultValue) const { return defaultValue; diff --git a/Source/WebCore/html/InputType.h b/Source/WebCore/html/InputType.h index 4d25a97..0d1f6b8 100644 --- a/Source/WebCore/html/InputType.h +++ b/Source/WebCore/html/InputType.h @@ -171,6 +171,12 @@ public: virtual void accessKeyAction(bool sendToAnyElement); virtual bool canBeSuccessfulSubmitButton(); + + // Shadow tree handling + + virtual void createShadowSubtree(); + void destroyShadowSubtree(); + // Miscellaneous functions virtual bool rendererIsNeeded(); diff --git a/Source/WebCore/html/RangeInputType.cpp b/Source/WebCore/html/RangeInputType.cpp index 7a0d3e4..7d0a38c 100644 --- a/Source/WebCore/html/RangeInputType.cpp +++ b/Source/WebCore/html/RangeInputType.cpp @@ -37,6 +37,7 @@ #include "HTMLParserIdioms.h" #include "KeyboardEvent.h" #include "RenderSlider.h" +#include "SliderThumbElement.h" #include "StepRange.h" #include <limits> #include <wtf/MathExtras.h> @@ -192,6 +193,11 @@ void RangeInputType::forwardEvent(Event* event) toRenderSlider(element()->renderer())->forwardEvent(event); } +void RangeInputType::createShadowSubtree() +{ + element()->setShadowRoot(SliderThumbElement::create(element()->document())); +} + RenderObject* RangeInputType::createRenderer(RenderArena* arena, RenderStyle*) const { return new (arena) RenderSlider(element()); diff --git a/Source/WebCore/html/RangeInputType.h b/Source/WebCore/html/RangeInputType.h index 7f341a7..57eb299 100644 --- a/Source/WebCore/html/RangeInputType.h +++ b/Source/WebCore/html/RangeInputType.h @@ -58,6 +58,7 @@ private: virtual void handleKeydownEvent(KeyboardEvent*); virtual void forwardEvent(Event*); virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const; + virtual void createShadowSubtree(); virtual double parseToDouble(const String&, double) const; virtual String serialize(double) const; virtual void accessKeyAction(bool sendToAnyElement); diff --git a/Source/WebCore/html/ValidationMessage.cpp b/Source/WebCore/html/ValidationMessage.cpp index 4418235..2c441c7 100644 --- a/Source/WebCore/html/ValidationMessage.cpp +++ b/Source/WebCore/html/ValidationMessage.cpp @@ -31,10 +31,18 @@ #include "config.h" #include "ValidationMessage.h" +#include "CSSStyleSelector.h" +#include "FormAssociatedElement.h" +#include "HTMLBRElement.h" +#include "HTMLNames.h" +#include "RenderObject.h" +#include "Text.h" #include <wtf/PassOwnPtr.h> namespace WebCore { +using namespace HTMLNames; + ALWAYS_INLINE ValidationMessage::ValidationMessage(FormAssociatedElement* element) : m_element(element) { @@ -42,7 +50,7 @@ ALWAYS_INLINE ValidationMessage::ValidationMessage(FormAssociatedElement* elemen ValidationMessage::~ValidationMessage() { - hideMessage(); + deleteBubbleTree(); } PassOwnPtr<ValidationMessage> ValidationMessage::create(FormAssociatedElement* element) @@ -52,18 +60,105 @@ PassOwnPtr<ValidationMessage> ValidationMessage::create(FormAssociatedElement* e void ValidationMessage::setMessage(const String& message) { - // FIXME: Construct validation message UI if m_message is empty. - + // Don't modify the DOM tree in this context. + // If so, an assertion in Node::isFocusable() fails. + ASSERT(!message.isEmpty()); m_message = message; + if (!m_bubble) + m_timer.set(new Timer<ValidationMessage>(this, &ValidationMessage::buildBubbleTree)); + else + m_timer.set(new Timer<ValidationMessage>(this, &ValidationMessage::setMessageDOMAndStartTimer)); + m_timer->startOneShot(0); +} + +void ValidationMessage::setMessageDOMAndStartTimer(Timer<ValidationMessage>*) +{ + ASSERT(m_bubbleMessage); + m_bubbleMessage->removeAllChildren(); + Vector<String> lines; + m_message.split('\n', lines); + Document* doc = m_bubbleMessage->document(); + ExceptionCode ec = 0; + for (unsigned i = 0; i < lines.size(); ++i) { + if (i) { + m_bubbleMessage->appendChild(HTMLBRElement::create(doc), ec); + m_bubbleMessage->appendChild(Text::create(doc, lines[i]), ec); + } else { + RefPtr<HTMLElement> bold = HTMLElement::create(bTag, doc); + bold->setInnerText(lines[i], ec); + m_bubbleMessage->appendChild(bold.release(), ec); + } + } - m_timer.set(new Timer<ValidationMessage>(this, &ValidationMessage::hideMessage)); - m_timer->startOneShot(6.0); // FIXME: should be <message length> * something. + m_timer.set(new Timer<ValidationMessage>(this, &ValidationMessage::deleteBubbleTree)); + m_timer->startOneShot(max(5.0, m_message.length() / 20.0)); } -void ValidationMessage::hideMessage(Timer<ValidationMessage>*) +class ElementWithPseudoId : public HTMLElement { +public: + static PassRefPtr<HTMLElement> create(Document* doc, const AtomicString& pseudoName) + { + return adoptRef(new ElementWithPseudoId(doc, pseudoName)); + } + +protected: + ElementWithPseudoId(Document* doc, const AtomicString& pseudoName) + : HTMLElement(divTag, doc) + , m_pseudoName(pseudoName) { }; + virtual AtomicString shadowPseudoId() const { return m_pseudoName; } + +private: + AtomicString m_pseudoName; +}; + +void ValidationMessage::buildBubbleTree(Timer<ValidationMessage>*) { - // FIXME: Implement. + HTMLElement* host = toHTMLElement(m_element); + Document* doc = host->document(); + m_bubble = ElementWithPseudoId::create(doc, "-webkit-validation-bubble"); + ExceptionCode ec = 0; + // FIXME: We need a way to host multiple shadow roots in a single node, or + // to inherit an existing shadow tree. + if (host->shadowRoot()) + host->shadowRoot()->appendChild(m_bubble.get(), ec); + else { + host->setShadowRoot(m_bubble); + // FIXME: The following attach() should be unnecessary. + m_bubble->attach(); + } + + m_bubble->appendChild(ElementWithPseudoId::create(doc, "-webkit-validation-bubble-top-outer-arrow"), ec); + m_bubble->appendChild(ElementWithPseudoId::create(doc, "-webkit-validation-bubble-top-inner-arrow"), ec); + m_bubbleMessage = ElementWithPseudoId::create(doc, "-webkit-validation-bubble-message"); + m_bubble->appendChild(m_bubbleMessage, ec); + setMessageDOMAndStartTimer(); + + // FIXME: Use transition to show the bubble. + + // We don't need to adjust the bubble location. The default position is enough. +} + +void ValidationMessage::requestToHideMessage() +{ + // We must not modify the DOM tree in this context by the same reason as setMessage(). + m_timer.set(new Timer<ValidationMessage>(this, &ValidationMessage::deleteBubbleTree)); + m_timer->startOneShot(0); +} + +void ValidationMessage::deleteBubbleTree(Timer<ValidationMessage>*) +{ + if (m_bubble) { + m_bubbleMessage = 0; + HTMLElement* host = toHTMLElement(m_element); + if (m_bubble->isShadowRoot()) + host->setShadowRoot(0); + else { + ExceptionCode ec; + host->shadowRoot()->removeChild(m_bubble.get(), ec); + } + m_bubble = 0; + } m_message = String(); } diff --git a/Source/WebCore/html/ValidationMessage.h b/Source/WebCore/html/ValidationMessage.h index d78e3f3..5fa1f96 100644 --- a/Source/WebCore/html/ValidationMessage.h +++ b/Source/WebCore/html/ValidationMessage.h @@ -34,11 +34,13 @@ #include "Timer.h" #include <wtf/Noncopyable.h> #include <wtf/OwnPtr.h> +#include <wtf/RefPtr.h> #include <wtf/text/WTFString.h> namespace WebCore { class FormAssociatedElement; +class HTMLElement; class ValidationMessage : public Noncopyable { public: @@ -46,14 +48,19 @@ public: ~ValidationMessage(); String message() const { return m_message; } void setMessage(const String&); + void requestToHideMessage(); private: ValidationMessage(FormAssociatedElement*); - void hideMessage(Timer<ValidationMessage>* = 0); + void setMessageDOMAndStartTimer(Timer<ValidationMessage>* = 0); + void buildBubbleTree(Timer<ValidationMessage>*); + void deleteBubbleTree(Timer<ValidationMessage>* = 0); FormAssociatedElement* m_element; String m_message; OwnPtr<Timer<ValidationMessage> > m_timer; + RefPtr<HTMLElement> m_bubble; + RefPtr<HTMLElement> m_bubbleMessage; }; } // namespace WebCore diff --git a/Source/WebCore/html/canvas/WebGLActiveInfo.h b/Source/WebCore/html/canvas/WebGLActiveInfo.h index 4650ea1..e75e1f5 100644 --- a/Source/WebCore/html/canvas/WebGLActiveInfo.h +++ b/Source/WebCore/html/canvas/WebGLActiveInfo.h @@ -26,6 +26,7 @@ #ifndef WebGLActiveInfo_h #define WebGLActiveInfo_h +#include "GraphicsContext3D.h" #include "PlatformString.h" #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> @@ -34,16 +35,16 @@ namespace WebCore { class WebGLActiveInfo : public RefCounted<WebGLActiveInfo> { public: - static PassRefPtr<WebGLActiveInfo> create(const String& name, unsigned type, int size) + static PassRefPtr<WebGLActiveInfo> create(const String& name, GC3Denum type, GC3Dint size) { return adoptRef(new WebGLActiveInfo(name, type, size)); } String name() const { return m_name; } - unsigned type() const { return m_type; } - int size() const { return m_size; } + GC3Denum type() const { return m_type; } + GC3Dint size() const { return m_size; } private: - WebGLActiveInfo(const String& name, unsigned type, int size) + WebGLActiveInfo(const String& name, GC3Denum type, GC3Dint size) : m_name(name) , m_type(type) , m_size(size) @@ -53,8 +54,8 @@ private: ASSERT(size); } String m_name; - unsigned m_type; - int m_size; + GC3Denum m_type; + GC3Dint m_size; }; } diff --git a/Source/WebCore/html/canvas/WebGLBuffer.cpp b/Source/WebCore/html/canvas/WebGLBuffer.cpp index f8c7b38..4566bfa 100644 --- a/Source/WebCore/html/canvas/WebGLBuffer.cpp +++ b/Source/WebCore/html/canvas/WebGLBuffer.cpp @@ -55,13 +55,16 @@ void WebGLBuffer::deleteObjectImpl(Platform3DObject object) context()->graphicsContext3D()->deleteBuffer(object); } -bool WebGLBuffer::associateBufferDataImpl(ArrayBuffer* array, unsigned byteOffset, unsigned byteLength) +bool WebGLBuffer::associateBufferDataImpl(ArrayBuffer* array, GC3Dintptr byteOffset, GC3Dsizeiptr byteLength) { + if (byteLength < 0 || byteOffset < 0) + return false; + if (array && byteLength) { - CheckedInt<uint32_t> checkedOffset(byteOffset); - CheckedInt<uint32_t> checkedLength(byteLength); - CheckedInt<uint32_t> checkedMax = checkedOffset + checkedLength; - if (!checkedMax.valid() || checkedMax.value() > array->byteLength()) + CheckedInt<int32_t> checkedOffset(byteOffset); + CheckedInt<int32_t> checkedLength(byteLength); + CheckedInt<int32_t> checkedMax = checkedOffset + checkedLength; + if (!checkedMax.valid() || checkedMax.value() > static_cast<int32_t>(array->byteLength())) return false; } @@ -94,11 +97,11 @@ bool WebGLBuffer::associateBufferDataImpl(ArrayBuffer* array, unsigned byteOffse } } -bool WebGLBuffer::associateBufferData(int size) +bool WebGLBuffer::associateBufferData(GC3Dsizeiptr size) { if (size < 0) return false; - return associateBufferDataImpl(0, 0, static_cast<unsigned>(size)); + return associateBufferDataImpl(0, 0, size); } bool WebGLBuffer::associateBufferData(ArrayBuffer* array) @@ -115,18 +118,18 @@ bool WebGLBuffer::associateBufferData(ArrayBufferView* array) return associateBufferDataImpl(array->buffer().get(), array->byteOffset(), array->byteLength()); } -bool WebGLBuffer::associateBufferSubDataImpl(long offset, ArrayBuffer* array, unsigned arrayByteOffset, unsigned byteLength) +bool WebGLBuffer::associateBufferSubDataImpl(GC3Dintptr offset, ArrayBuffer* array, GC3Dintptr arrayByteOffset, GC3Dsizeiptr byteLength) { - if (!array || offset < 0) + if (!array || offset < 0 || arrayByteOffset < 0 || byteLength < 0) return false; if (byteLength) { - CheckedInt<uint32_t> checkedBufferOffset(offset); - CheckedInt<uint32_t> checkedArrayOffset(arrayByteOffset); - CheckedInt<uint32_t> checkedLength(byteLength); - CheckedInt<uint32_t> checkedArrayMax = checkedArrayOffset + checkedLength; - CheckedInt<uint32_t> checkedBufferMax = checkedBufferOffset + checkedLength; - if (!checkedArrayMax.valid() || checkedArrayMax.value() > array->byteLength() || !checkedBufferMax.valid() || checkedBufferMax.value() > m_byteLength) + CheckedInt<int32_t> checkedBufferOffset(offset); + CheckedInt<int32_t> checkedArrayOffset(arrayByteOffset); + CheckedInt<int32_t> checkedLength(byteLength); + CheckedInt<int32_t> checkedArrayMax = checkedArrayOffset + checkedLength; + CheckedInt<int32_t> checkedBufferMax = checkedBufferOffset + checkedLength; + if (!checkedArrayMax.valid() || checkedArrayMax.value() > static_cast<int32_t>(array->byteLength()) || !checkedBufferMax.valid() || checkedBufferMax.value() > m_byteLength) return false; } @@ -148,26 +151,26 @@ bool WebGLBuffer::associateBufferSubDataImpl(long offset, ArrayBuffer* array, un } } -bool WebGLBuffer::associateBufferSubData(long offset, ArrayBuffer* array) +bool WebGLBuffer::associateBufferSubData(GC3Dintptr offset, ArrayBuffer* array) { if (!array) return false; return associateBufferSubDataImpl(offset, array, 0, array->byteLength()); } -bool WebGLBuffer::associateBufferSubData(long offset, ArrayBufferView* array) +bool WebGLBuffer::associateBufferSubData(GC3Dintptr offset, ArrayBufferView* array) { if (!array) return false; return associateBufferSubDataImpl(offset, array->buffer().get(), array->byteOffset(), array->byteLength()); } -unsigned WebGLBuffer::byteLength() const +GC3Dsizeiptr WebGLBuffer::byteLength() const { return m_byteLength; } -long WebGLBuffer::getCachedMaxIndex(unsigned long type) +int WebGLBuffer::getCachedMaxIndex(GC3Denum type) { for (size_t i = 0; i < WTF_ARRAY_LENGTH(m_maxIndexCache); ++i) if (m_maxIndexCache[i].type == type) @@ -175,7 +178,7 @@ long WebGLBuffer::getCachedMaxIndex(unsigned long type) return -1; } -void WebGLBuffer::setCachedMaxIndex(unsigned long type, long value) +void WebGLBuffer::setCachedMaxIndex(GC3Denum type, int value) { size_t numEntries = WTF_ARRAY_LENGTH(m_maxIndexCache); for (size_t i = 0; i < numEntries; ++i) @@ -188,7 +191,7 @@ void WebGLBuffer::setCachedMaxIndex(unsigned long type, long value) m_nextAvailableCacheEntry = (m_nextAvailableCacheEntry + 1) % numEntries; } -void WebGLBuffer::setTarget(unsigned long target) +void WebGLBuffer::setTarget(GC3Denum target) { // In WebGL, a buffer is bound to one target in its lifetime if (m_target) diff --git a/Source/WebCore/html/canvas/WebGLBuffer.h b/Source/WebCore/html/canvas/WebGLBuffer.h index af819a3..ec79a2d 100644 --- a/Source/WebCore/html/canvas/WebGLBuffer.h +++ b/Source/WebCore/html/canvas/WebGLBuffer.h @@ -41,23 +41,23 @@ public: static PassRefPtr<WebGLBuffer> create(WebGLRenderingContext*); - bool associateBufferData(int size); + bool associateBufferData(GC3Dsizeiptr size); bool associateBufferData(ArrayBuffer* array); bool associateBufferData(ArrayBufferView* array); - bool associateBufferSubData(long offset, ArrayBuffer* array); - bool associateBufferSubData(long offset, ArrayBufferView* array); + bool associateBufferSubData(GC3Dintptr offset, ArrayBuffer* array); + bool associateBufferSubData(GC3Dintptr offset, ArrayBufferView* array); - unsigned byteLength() const; + GC3Dsizeiptr byteLength() const; const ArrayBuffer* elementArrayBuffer() const { return m_elementArrayBuffer.get(); } // Gets the cached max index for the given type. Returns -1 if // none has been set. - long getCachedMaxIndex(unsigned long type); + int getCachedMaxIndex(GC3Denum type); // Sets the cached max index for the given type. - void setCachedMaxIndex(unsigned long type, long value); + void setCachedMaxIndex(GC3Denum type, int value); - unsigned long getTarget() const { return m_target; } - void setTarget(unsigned long); + GC3Denum getTarget() const { return m_target; } + void setTarget(GC3Denum); bool hasEverBeenBound() const { return object() && m_target; } @@ -69,10 +69,10 @@ protected: private: virtual bool isBuffer() const { return true; } - unsigned long m_target; + GC3Denum m_target; RefPtr<ArrayBuffer> m_elementArrayBuffer; - unsigned m_byteLength; + GC3Dsizeiptr m_byteLength; // Optimization for index validation. For each type of index // (i.e., UNSIGNED_SHORT), cache the maximum index in the @@ -82,22 +82,22 @@ private: // draw call as long as all bound array buffers are at least // that size. struct MaxIndexCacheEntry { - unsigned long type; - long maxIndex; + GC3Denum type; + int maxIndex; }; // OpenGL ES 2.0 only has two valid index types (UNSIGNED_BYTE // and UNSIGNED_SHORT), but might as well leave open the // possibility of adding others. MaxIndexCacheEntry m_maxIndexCache[4]; - unsigned m_nextAvailableCacheEntry; + unsigned int m_nextAvailableCacheEntry; // Clears all of the cached max indices. void clearCachedMaxIndices(); // Helper function called by the three associateBufferData(). - bool associateBufferDataImpl(ArrayBuffer* array, unsigned byteOffset, unsigned byteLength); + bool associateBufferDataImpl(ArrayBuffer* array, GC3Dintptr byteOffset, GC3Dsizeiptr byteLength); // Helper function called by the two associateBufferSubData(). - bool associateBufferSubDataImpl(long offset, ArrayBuffer* array, unsigned arrayByteOffset, unsigned byteLength); + bool associateBufferSubDataImpl(GC3Dintptr offset, ArrayBuffer* array, GC3Dintptr arrayByteOffset, GC3Dsizeiptr byteLength); }; } // namespace WebCore diff --git a/Source/WebCore/html/canvas/WebGLFramebuffer.cpp b/Source/WebCore/html/canvas/WebGLFramebuffer.cpp index a1c3a9a..dbc714b 100644 --- a/Source/WebCore/html/canvas/WebGLFramebuffer.cpp +++ b/Source/WebCore/html/canvas/WebGLFramebuffer.cpp @@ -37,7 +37,7 @@ namespace { // This function is only for depth/stencil/depth_stencil attachment. // Currently we assume these attachments are all renderbuffers. - unsigned long getInternalFormat(WebGLObject* buffer) + GC3Denum getInternalFormat(WebGLObject* buffer) { ASSERT(buffer && buffer->isRenderbuffer()); return (reinterpret_cast<WebGLRenderbuffer*>(buffer))->getInternalFormat(); @@ -82,7 +82,7 @@ WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContext* ctx) setObject(context()->graphicsContext3D()->createFramebuffer()); } -void WebGLFramebuffer::setAttachment(unsigned long attachment, unsigned long texTarget, WebGLTexture* texture, int level) +void WebGLFramebuffer::setAttachment(GC3Denum attachment, GC3Denum texTarget, WebGLTexture* texture, GC3Dint level) { if (!object()) return; @@ -110,7 +110,7 @@ void WebGLFramebuffer::setAttachment(unsigned long attachment, unsigned long tex } } -void WebGLFramebuffer::setAttachment(unsigned long attachment, WebGLRenderbuffer* renderbuffer) +void WebGLFramebuffer::setAttachment(GC3Denum attachment, WebGLRenderbuffer* renderbuffer) { if (!object()) return; @@ -134,7 +134,7 @@ void WebGLFramebuffer::setAttachment(unsigned long attachment, WebGLRenderbuffer } } -WebGLObject* WebGLFramebuffer::getAttachment(unsigned long attachment) const +WebGLObject* WebGLFramebuffer::getAttachment(GC3Denum attachment) const { if (!object()) return 0; @@ -168,7 +168,7 @@ void WebGLFramebuffer::removeAttachment(WebGLObject* attachment) return; } -int WebGLFramebuffer::getWidth() const +GC3Dsizei WebGLFramebuffer::getWidth() const { if (!object() || !isColorAttached()) return 0; @@ -180,7 +180,7 @@ int WebGLFramebuffer::getWidth() const return 0; } -int WebGLFramebuffer::getHeight() const +GC3Dsizei WebGLFramebuffer::getHeight() const { if (!object() || !isColorAttached()) return 0; @@ -192,7 +192,7 @@ int WebGLFramebuffer::getHeight() const return 0; } -unsigned long WebGLFramebuffer::getColorBufferFormat() const +GC3Denum WebGLFramebuffer::getColorBufferFormat() const { if (!object() || !isColorAttached()) return 0; @@ -260,7 +260,7 @@ bool WebGLFramebuffer::initializeRenderbuffers() { ASSERT(object()); bool initColor = false, initDepth = false, initStencil = false; - unsigned long mask = 0; + GC3Dbitfield mask = 0; if (isUninitialized(m_colorAttachment.get())) { initColor = true; mask |= GraphicsContext3D::COLOR_BUFFER_BIT; @@ -287,12 +287,12 @@ bool WebGLFramebuffer::initializeRenderbuffers() if (g3d->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) return false; - float colorClearValue[] = {0, 0, 0, 0}, depthClearValue = 0; - int stencilClearValue = 0; - unsigned char colorMask[] = {0, 0, 0, 0}, depthMask = 0; - unsigned int stencilMask = 0xffffffff; - bool isScissorEnabled = false; - bool isDitherEnabled = false; + GC3Dfloat colorClearValue[] = {0, 0, 0, 0}, depthClearValue = 0; + GC3Dint stencilClearValue = 0; + GC3Dboolean colorMask[] = {0, 0, 0, 0}, depthMask = 0; + GC3Duint stencilMask = 0xffffffff; + GC3Dboolean isScissorEnabled = 0; + GC3Dboolean isDitherEnabled = 0; if (initColor) { g3d->getFloatv(GraphicsContext3D::COLOR_CLEAR_VALUE, colorClearValue); g3d->getBooleanv(GraphicsContext3D::COLOR_WRITEMASK, colorMask); @@ -307,7 +307,7 @@ bool WebGLFramebuffer::initializeRenderbuffers() } if (initStencil) { g3d->getIntegerv(GraphicsContext3D::STENCIL_CLEAR_VALUE, &stencilClearValue); - g3d->getIntegerv(GraphicsContext3D::STENCIL_WRITEMASK, reinterpret_cast<int*>(&stencilMask)); + g3d->getIntegerv(GraphicsContext3D::STENCIL_WRITEMASK, reinterpret_cast<GC3Dint*>(&stencilMask)); g3d->clearStencil(0); g3d->stencilMask(0xffffffff); } diff --git a/Source/WebCore/html/canvas/WebGLFramebuffer.h b/Source/WebCore/html/canvas/WebGLFramebuffer.h index d801904..a1cb86f 100644 --- a/Source/WebCore/html/canvas/WebGLFramebuffer.h +++ b/Source/WebCore/html/canvas/WebGLFramebuffer.h @@ -42,15 +42,15 @@ public: static PassRefPtr<WebGLFramebuffer> create(WebGLRenderingContext*); - void setAttachment(unsigned long attachment, unsigned long texTarget, WebGLTexture*, int level); - void setAttachment(unsigned long attachment, WebGLRenderbuffer*); + void setAttachment(GC3Denum attachment, GC3Denum texTarget, WebGLTexture*, GC3Dint level); + void setAttachment(GC3Denum attachment, WebGLRenderbuffer*); // If an object is attached to the framebuffer, remove it. void removeAttachment(WebGLObject*); - WebGLObject* getAttachment(unsigned long) const; + WebGLObject* getAttachment(GC3Denum) const; - unsigned long getColorBufferFormat() const; - int getWidth() const; - int getHeight() const; + GC3Denum getColorBufferFormat() const; + GC3Dsizei getWidth() const; + GC3Dsizei getHeight() const; // This should always be called before drawArray, drawElements, clear, // readPixels, copyTexImage2D, copyTexSubImage2D if this framebuffer is @@ -90,8 +90,8 @@ private: bool m_hasEverBeenBound; - unsigned long m_texTarget; - int m_texLevel; + GC3Denum m_texTarget; + GC3Dint m_texLevel; }; } // namespace WebCore diff --git a/Source/WebCore/html/canvas/WebGLProgram.cpp b/Source/WebCore/html/canvas/WebGLProgram.cpp index b2c2086..b3fa363 100644 --- a/Source/WebCore/html/canvas/WebGLProgram.cpp +++ b/Source/WebCore/html/canvas/WebGLProgram.cpp @@ -70,7 +70,7 @@ bool WebGLProgram::cacheActiveAttribLocations() if (!m_linkStatus) return false; - int numAttribs = 0; + GC3Dint numAttribs = 0; context3d->getProgramiv(object(), GraphicsContext3D::ACTIVE_ATTRIBUTES, &numAttribs); m_activeAttribLocations.resize(static_cast<size_t>(numAttribs)); for (int i = 0; i < numAttribs; ++i) { @@ -82,21 +82,21 @@ bool WebGLProgram::cacheActiveAttribLocations() return true; } -int WebGLProgram::numActiveAttribLocations() const +unsigned WebGLProgram::numActiveAttribLocations() const { - return static_cast<int>(m_activeAttribLocations.size()); + return m_activeAttribLocations.size(); } -int WebGLProgram::getActiveAttribLocation(int index) const +GC3Dint WebGLProgram::getActiveAttribLocation(GC3Duint index) const { - if (index < 0 || index >= numActiveAttribLocations()) + if (index >= numActiveAttribLocations()) return -1; - return m_activeAttribLocations[static_cast<size_t>(index)]; + return m_activeAttribLocations[index]; } bool WebGLProgram::isUsingVertexAttrib0() const { - for (int ii = 0; ii < numActiveAttribLocations(); ++ii) { + for (unsigned ii = 0; ii < numActiveAttribLocations(); ++ii) { if (!getActiveAttribLocation(ii)) return true; } diff --git a/Source/WebCore/html/canvas/WebGLProgram.h b/Source/WebCore/html/canvas/WebGLProgram.h index 6b89ae5..f2acef8 100644 --- a/Source/WebCore/html/canvas/WebGLProgram.h +++ b/Source/WebCore/html/canvas/WebGLProgram.h @@ -45,15 +45,15 @@ public: // cacheActiveAttribLocation() is only called once after linkProgram() // succeeds. bool cacheActiveAttribLocations(); - int numActiveAttribLocations() const; - int getActiveAttribLocation(int index) const; + unsigned numActiveAttribLocations() const; + GC3Dint getActiveAttribLocation(GC3Duint index) const; bool isUsingVertexAttrib0() const; bool getLinkStatus() const { return m_linkStatus; } void setLinkStatus(bool status) { m_linkStatus = status; } - unsigned long getLinkCount() const { return m_linkCount; } + unsigned getLinkCount() const { return m_linkCount; } // This is to be called everytime after the program is successfully linked. // We don't deal with integer overflow here, assuming in reality a program @@ -72,13 +72,13 @@ protected: private: virtual bool isProgram() const { return true; } - Vector<int> m_activeAttribLocations; + Vector<GC3Dint> m_activeAttribLocations; - bool m_linkStatus; + GC3Dint m_linkStatus; // This is used to track whether a WebGLUniformLocation belongs to this // program or not. - unsigned long m_linkCount; + unsigned m_linkCount; RefPtr<WebGLShader> m_vertexShader; RefPtr<WebGLShader> m_fragmentShader; diff --git a/Source/WebCore/html/canvas/WebGLRenderbuffer.h b/Source/WebCore/html/canvas/WebGLRenderbuffer.h index a432f9d..4b47bf5 100644 --- a/Source/WebCore/html/canvas/WebGLRenderbuffer.h +++ b/Source/WebCore/html/canvas/WebGLRenderbuffer.h @@ -39,20 +39,20 @@ public: static PassRefPtr<WebGLRenderbuffer> create(WebGLRenderingContext*); - void setInternalFormat(unsigned long internalformat) + void setInternalFormat(GC3Denum internalformat) { m_internalFormat = internalformat; m_initialized = false; } - unsigned long getInternalFormat() const { return m_internalFormat; } + GC3Denum getInternalFormat() const { return m_internalFormat; } - void setSize(unsigned long width, unsigned long height) + void setSize(GC3Dsizei width, GC3Dsizei height) { m_width = width; m_height = height; } - unsigned long getWidth() const { return m_width; } - unsigned long getHeight() const { return m_height; } + GC3Dsizei getWidth() const { return m_width; } + GC3Dsizei getHeight() const { return m_height; } void setIsValid(bool isValid) { m_isValid = isValid; } bool isValid() const { return m_isValid; } @@ -72,9 +72,9 @@ protected: private: virtual bool isRenderbuffer() const { return true; } - unsigned long m_internalFormat; + GC3Denum m_internalFormat; bool m_initialized; - unsigned long m_width, m_height; + GC3Dsizei m_width, m_height; bool m_isValid; // This is only false if internalFormat is DEPTH_STENCIL and packed_depth_stencil is not supported. bool m_hasEverBeenBound; diff --git a/Source/WebCore/html/canvas/WebGLRenderingContext.cpp b/Source/WebCore/html/canvas/WebGLRenderingContext.cpp index 4ffd400..c445e2b 100644 --- a/Source/WebCore/html/canvas/WebGLRenderingContext.cpp +++ b/Source/WebCore/html/canvas/WebGLRenderingContext.cpp @@ -74,14 +74,14 @@ namespace { return object ? object->object() : 0; } - void clip1D(long start, long range, long sourceRange, long* clippedStart, long* clippedRange) + void clip1D(GC3Dint start, GC3Dsizei range, GC3Dsizei sourceRange, GC3Dint* clippedStart, GC3Dsizei* clippedRange) { ASSERT(clippedStart && clippedRange); if (start < 0) { range += start; start = 0; } - long end = start + range; + GC3Dint end = start + range; if (end > sourceRange) range -= end - sourceRange; *clippedStart = start; @@ -89,9 +89,9 @@ namespace { } // Returns false if no clipping is necessary, i.e., x, y, width, height stay the same. - bool clip2D(long x, long y, long width, long height, - long sourceWidth, long sourceHeight, - long* clippedX, long* clippedY, long* clippedWidth, long*clippedHeight) + bool clip2D(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, + GC3Dsizei sourceWidth, GC3Dsizei sourceHeight, + GC3Dint* clippedX, GC3Dint* clippedY, GC3Dsizei* clippedWidth, GC3Dsizei*clippedHeight) { ASSERT(clippedX && clippedY && clippedWidth && clippedHeight); clip1D(x, width, sourceWidth, clippedX, clippedWidth); @@ -101,11 +101,12 @@ namespace { // Return true if a character belongs to the ASCII subset as defined in // GLSL ES 1.0 spec section 3.1. + // We make exceptions for " ' `. bool validateCharacter(unsigned char c) { // Printing characters are valid except " $ ` @ \ ' DEL. if (c >= 32 && c <= 126 - && c != '"' && c != '$' && c != '`' && c != '@' && c != '\\' && c != '\'') + && c != '$' && c != '@' && c != '\\') return true; // Horizontal tab, line feed, vertical tab, form feed, carriage return // are also valid. @@ -208,12 +209,12 @@ void WebGLRenderingContext::initializeNewContext() m_stencilFuncMaskBack = 0xFFFFFFFF; m_vertexAttribState.clear(); - int numCombinedTextureImageUnits = 0; + GC3Dint numCombinedTextureImageUnits = 0; m_context->getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedTextureImageUnits); m_textureUnits.clear(); m_textureUnits.resize(numCombinedTextureImageUnits); - int numVertexAttribs = 0; + GC3Dint numVertexAttribs = 0; m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &numVertexAttribs); m_maxVertexAttribs = numVertexAttribs; @@ -300,12 +301,12 @@ void WebGLRenderingContext::reshape(int width, int height) m_context->reshape(width, height); } -int WebGLRenderingContext::sizeInBytes(int type) +unsigned int WebGLRenderingContext::sizeInBytes(GC3Denum type) { return m_context->sizeInBytes(type); } -void WebGLRenderingContext::activeTexture(unsigned long texture, ExceptionCode& ec) +void WebGLRenderingContext::activeTexture(GC3Denum texture, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -333,7 +334,7 @@ void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* sha cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, unsigned long index, const String& name, ExceptionCode& ec) +void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, GC3Duint index, const String& name, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateWebGLObject(program)) @@ -344,7 +345,7 @@ void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, unsigned l cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::bindBuffer(unsigned long target, WebGLBuffer* buffer, ExceptionCode& ec) +void WebGLRenderingContext::bindBuffer(GC3Denum target, WebGLBuffer* buffer, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -374,7 +375,7 @@ void WebGLRenderingContext::bindBuffer(unsigned long target, WebGLBuffer* buffer } -void WebGLRenderingContext::bindFramebuffer(unsigned long target, WebGLFramebuffer* buffer, ExceptionCode& ec) +void WebGLRenderingContext::bindFramebuffer(GC3Denum target, WebGLFramebuffer* buffer, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -394,7 +395,7 @@ void WebGLRenderingContext::bindFramebuffer(unsigned long target, WebGLFramebuff cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::bindRenderbuffer(unsigned long target, WebGLRenderbuffer* renderBuffer, ExceptionCode& ec) +void WebGLRenderingContext::bindRenderbuffer(GC3Denum target, WebGLRenderbuffer* renderBuffer, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -415,7 +416,7 @@ void WebGLRenderingContext::bindRenderbuffer(unsigned long target, WebGLRenderbu } -void WebGLRenderingContext::bindTexture(unsigned long target, WebGLTexture* texture, ExceptionCode& ec) +void WebGLRenderingContext::bindTexture(GC3Denum target, WebGLTexture* texture, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -424,7 +425,7 @@ void WebGLRenderingContext::bindTexture(unsigned long target, WebGLTexture* text m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); return; } - int maxLevel = 0; + GC3Dint maxLevel = 0; if (target == GraphicsContext3D::TEXTURE_2D) { m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; maxLevel = m_maxTextureLevel; @@ -451,7 +452,7 @@ void WebGLRenderingContext::bindTexture(unsigned long target, WebGLTexture* text cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::blendColor(float red, float green, float blue, float alpha) +void WebGLRenderingContext::blendColor(GC3Dfloat red, GC3Dfloat green, GC3Dfloat blue, GC3Dfloat alpha) { if (isContextLost()) return; @@ -459,7 +460,7 @@ void WebGLRenderingContext::blendColor(float red, float green, float blue, float cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::blendEquation(unsigned long mode) +void WebGLRenderingContext::blendEquation(GC3Denum mode) { if (isContextLost() || !validateBlendEquation(mode)) return; @@ -467,7 +468,7 @@ void WebGLRenderingContext::blendEquation(unsigned long mode) cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha) +void WebGLRenderingContext::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha) { if (isContextLost() || !validateBlendEquation(modeRGB) || !validateBlendEquation(modeAlpha)) return; @@ -476,7 +477,7 @@ void WebGLRenderingContext::blendEquationSeparate(unsigned long modeRGB, unsigne } -void WebGLRenderingContext::blendFunc(unsigned long sfactor, unsigned long dfactor) +void WebGLRenderingContext::blendFunc(GC3Denum sfactor, GC3Denum dfactor) { if (isContextLost() || !validateBlendFuncFactors(sfactor, dfactor)) return; @@ -484,7 +485,7 @@ void WebGLRenderingContext::blendFunc(unsigned long sfactor, unsigned long dfact cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha) +void WebGLRenderingContext::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha) { if (isContextLost() || !validateBlendFuncFactors(srcRGB, dstRGB)) return; @@ -492,7 +493,7 @@ void WebGLRenderingContext::blendFuncSeparate(unsigned long srcRGB, unsigned lon cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::bufferData(unsigned long target, int size, unsigned long usage, ExceptionCode& ec) +void WebGLRenderingContext::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -511,7 +512,7 @@ void WebGLRenderingContext::bufferData(unsigned long target, int size, unsigned cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::bufferData(unsigned long target, ArrayBuffer* data, unsigned long usage, ExceptionCode& ec) +void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBuffer* data, GC3Denum usage, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -534,7 +535,7 @@ void WebGLRenderingContext::bufferData(unsigned long target, ArrayBuffer* data, cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage, ExceptionCode& ec) +void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBufferView* data, GC3Denum usage, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -557,7 +558,7 @@ void WebGLRenderingContext::bufferData(unsigned long target, ArrayBufferView* da cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, ArrayBuffer* data, ExceptionCode& ec) +void WebGLRenderingContext::bufferSubData(GC3Denum target, GC3Dintptr offset, ArrayBuffer* data, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -578,7 +579,7 @@ void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, Arr cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, ArrayBufferView* data, ExceptionCode& ec) +void WebGLRenderingContext::bufferSubData(GC3Denum target, GC3Dintptr offset, ArrayBufferView* data, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -599,7 +600,7 @@ void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, Arr cleanupAfterGraphicsCall(false); } -unsigned long WebGLRenderingContext::checkFramebufferStatus(unsigned long target) +GC3Denum WebGLRenderingContext::checkFramebufferStatus(GC3Denum target) { if (isContextLost()) return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; @@ -616,7 +617,7 @@ unsigned long WebGLRenderingContext::checkFramebufferStatus(unsigned long target return result; } -void WebGLRenderingContext::clear(unsigned long mask) +void WebGLRenderingContext::clear(GC3Dbitfield mask) { if (isContextLost()) return; @@ -632,7 +633,7 @@ void WebGLRenderingContext::clear(unsigned long mask) cleanupAfterGraphicsCall(true); } -void WebGLRenderingContext::clearColor(float r, float g, float b, float a) +void WebGLRenderingContext::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b, GC3Dfloat a) { if (isContextLost()) return; @@ -648,7 +649,7 @@ void WebGLRenderingContext::clearColor(float r, float g, float b, float a) cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::clearDepth(float depth) +void WebGLRenderingContext::clearDepth(GC3Dfloat depth) { if (isContextLost()) return; @@ -656,7 +657,7 @@ void WebGLRenderingContext::clearDepth(float depth) cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::clearStencil(long s) +void WebGLRenderingContext::clearStencil(GC3Dint s) { if (isContextLost()) return; @@ -664,7 +665,7 @@ void WebGLRenderingContext::clearStencil(long s) cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::colorMask(bool red, bool green, bool blue, bool alpha) +void WebGLRenderingContext::colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha) { if (isContextLost()) return; @@ -681,7 +682,7 @@ void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode& ec cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, long width, long height, long border) +void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) { if (isContextLost()) return; @@ -705,10 +706,11 @@ void WebGLRenderingContext::copyTexImage2D(unsigned long target, long level, uns if (isResourceSafe()) m_context->copyTexImage2D(target, level, internalformat, x, y, width, height, border); else { - long clippedX, clippedY, clippedWidth, clippedHeight; + GC3Dint clippedX, clippedY; + GC3Dsizei clippedWidth, clippedHeight; if (clip2D(x, y, width, height, getBoundFramebufferWidth(), getBoundFramebufferHeight(), &clippedX, &clippedY, &clippedWidth, &clippedHeight)) { m_context->texImage2DResourceSafe(target, level, internalformat, width, height, border, - internalformat, GraphicsContext3D::UNSIGNED_BYTE); + internalformat, GraphicsContext3D::UNSIGNED_BYTE, m_unpackAlignment); if (clippedWidth > 0 && clippedHeight > 0) { m_context->copyTexSubImage2D(target, level, clippedX - x, clippedY - y, clippedX, clippedY, clippedWidth, clippedHeight); @@ -721,7 +723,7 @@ void WebGLRenderingContext::copyTexImage2D(unsigned long target, long level, uns cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, long width, long height) +void WebGLRenderingContext::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) { if (isContextLost()) return; @@ -747,20 +749,19 @@ void WebGLRenderingContext::copyTexSubImage2D(unsigned long target, long level, if (isResourceSafe()) m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); else { - long clippedX, clippedY, clippedWidth, clippedHeight; + GC3Dint clippedX, clippedY; + GC3Dsizei clippedWidth, clippedHeight; if (clip2D(x, y, width, height, getBoundFramebufferWidth(), getBoundFramebufferHeight(), &clippedX, &clippedY, &clippedWidth, &clippedHeight)) { - unsigned long format = tex->getInternalFormat(target, level); - unsigned long type = tex->getType(target, level); - unsigned int componentsPerPixel = 0; - unsigned int bytesPerComponent = 0; - bool valid = m_context->computeFormatAndTypeParameters(format, type, &componentsPerPixel, &bytesPerComponent); - if (!valid) { - m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); - return; - } + GC3Denum format = tex->getInternalFormat(target, level); + GC3Denum type = tex->getType(target, level); OwnArrayPtr<unsigned char> zero; if (width && height) { - unsigned long size = componentsPerPixel * bytesPerComponent * width * height; + unsigned int size; + GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, height, m_unpackAlignment, &size, 0); + if (error != GraphicsContext3D::NO_ERROR) { + m_context->synthesizeGLError(error); + return; + } zero = adoptArrayPtr(new unsigned char[size]); if (!zero) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); @@ -768,11 +769,7 @@ void WebGLRenderingContext::copyTexSubImage2D(unsigned long target, long level, } memset(zero.get(), 0, size); } - if (zero) - m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, zero.get()); - if (zero) - m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); if (clippedWidth > 0 && clippedHeight > 0) { m_context->copyTexSubImage2D(target, level, xoffset + clippedX - x, yoffset + clippedY - y, clippedX, clippedY, clippedWidth, clippedHeight); @@ -828,7 +825,7 @@ PassRefPtr<WebGLRenderbuffer> WebGLRenderingContext::createRenderbuffer() return o; } -PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(unsigned long type, ExceptionCode& ec) +PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(GC3Denum type, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -838,12 +835,12 @@ PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(unsigned long type, return 0; } - RefPtr<WebGLShader> o = WebGLShader::create(this, static_cast<GraphicsContext3D::WebGLEnumType>(type)); + RefPtr<WebGLShader> o = WebGLShader::create(this, type); addObject(o.get()); return o; } -void WebGLRenderingContext::cullFace(unsigned long mode) +void WebGLRenderingContext::cullFace(GC3Denum mode) { if (isContextLost()) return; @@ -927,7 +924,7 @@ void WebGLRenderingContext::deleteTexture(WebGLTexture* texture) m_framebufferBinding->removeAttachment(texture); } -void WebGLRenderingContext::depthFunc(unsigned long func) +void WebGLRenderingContext::depthFunc(GC3Denum func) { if (isContextLost()) return; @@ -935,7 +932,7 @@ void WebGLRenderingContext::depthFunc(unsigned long func) cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::depthMask(bool flag) +void WebGLRenderingContext::depthMask(GC3Dboolean flag) { if (isContextLost()) return; @@ -943,7 +940,7 @@ void WebGLRenderingContext::depthMask(bool flag) cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::depthRange(float zNear, float zFar) +void WebGLRenderingContext::depthRange(GC3Dfloat zNear, GC3Dfloat zFar) { if (isContextLost()) return; @@ -970,7 +967,7 @@ void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha } -void WebGLRenderingContext::disable(unsigned long cap) +void WebGLRenderingContext::disable(GC3Denum cap) { if (isContextLost() || !validateCapability(cap)) return; @@ -978,7 +975,7 @@ void WebGLRenderingContext::disable(unsigned long cap) cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::disableVertexAttribArray(unsigned long index, ExceptionCode& ec) +void WebGLRenderingContext::disableVertexAttribArray(GC3Duint index, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -997,7 +994,7 @@ void WebGLRenderingContext::disableVertexAttribArray(unsigned long index, Except } } -bool WebGLRenderingContext::validateElementArraySize(unsigned long count, unsigned long type, long offset) +bool WebGLRenderingContext::validateElementArraySize(GC3Dsizei count, GC3Denum type, GC3Dintptr offset) { if (!m_boundElementArrayBuffer) return false; @@ -1005,28 +1002,26 @@ bool WebGLRenderingContext::validateElementArraySize(unsigned long count, unsign if (offset < 0) return false; - unsigned long uoffset = static_cast<unsigned long>(offset); - if (type == GraphicsContext3D::UNSIGNED_SHORT) { // For an unsigned short array, offset must be divisible by 2 for alignment reasons. - if (uoffset & 1) + if (offset % 2) return false; // Make uoffset an element offset. - uoffset /= 2; + offset /= 2; - unsigned long n = m_boundElementArrayBuffer->byteLength() / 2; - if (uoffset > n || count > n - uoffset) + GC3Dsizeiptr n = m_boundElementArrayBuffer->byteLength() / 2; + if (offset > n || count > n - offset) return false; } else if (type == GraphicsContext3D::UNSIGNED_BYTE) { - unsigned long n = m_boundElementArrayBuffer->byteLength(); - if (uoffset > n || count > n - uoffset) + GC3Dsizeiptr n = m_boundElementArrayBuffer->byteLength(); + if (offset > n || count > n - offset) return false; } return true; } -bool WebGLRenderingContext::validateIndexArrayConservative(unsigned long type, long& numElementsRequired) +bool WebGLRenderingContext::validateIndexArrayConservative(GC3Denum type, int& numElementsRequired) { // Performs conservative validation by caching a maximum index of // the given type per element array buffer. If all of the bound @@ -1037,28 +1032,28 @@ bool WebGLRenderingContext::validateIndexArrayConservative(unsigned long type, l if (!m_boundElementArrayBuffer) return false; - unsigned numElements = m_boundElementArrayBuffer->byteLength(); + GC3Dsizeiptr numElements = m_boundElementArrayBuffer->byteLength(); // The case count==0 is already dealt with in drawElements before validateIndexArrayConservative. if (!numElements) return false; const ArrayBuffer* buffer = m_boundElementArrayBuffer->elementArrayBuffer(); ASSERT(buffer); - long maxIndex = m_boundElementArrayBuffer->getCachedMaxIndex(type); + int maxIndex = m_boundElementArrayBuffer->getCachedMaxIndex(type); if (maxIndex < 0) { // Compute the maximum index in the entire buffer for the given type of index. switch (type) { case GraphicsContext3D::UNSIGNED_BYTE: { - const unsigned char* p = static_cast<const unsigned char*>(buffer->data()); - for (unsigned i = 0; i < numElements; i++) - maxIndex = max(maxIndex, static_cast<long>(p[i])); + const GC3Dubyte* p = static_cast<const GC3Dubyte*>(buffer->data()); + for (GC3Dsizeiptr i = 0; i < numElements; i++) + maxIndex = max(maxIndex, static_cast<int>(p[i])); break; } case GraphicsContext3D::UNSIGNED_SHORT: { - numElements /= sizeof(unsigned short); - const unsigned short* p = static_cast<const unsigned short*>(buffer->data()); - for (unsigned i = 0; i < numElements; i++) - maxIndex = max(maxIndex, static_cast<long>(p[i])); + numElements /= sizeof(GC3Dushort); + const GC3Dushort* p = static_cast<const GC3Dushort*>(buffer->data()); + for (GC3Dsizeiptr i = 0; i < numElements; i++) + maxIndex = max(maxIndex, static_cast<int>(p[i])); break; } default: @@ -1077,9 +1072,10 @@ bool WebGLRenderingContext::validateIndexArrayConservative(unsigned long type, l return false; } -bool WebGLRenderingContext::validateIndexArrayPrecise(unsigned long count, unsigned long type, long offset, long& numElementsRequired) +bool WebGLRenderingContext::validateIndexArrayPrecise(GC3Dsizei count, GC3Denum type, GC3Dintptr offset, int& numElementsRequired) { - long lastIndex = -1; + ASSERT(count >= 0 && offset >= 0); + int lastIndex = -1; if (!m_boundElementArrayBuffer) return false; @@ -1092,20 +1088,20 @@ bool WebGLRenderingContext::validateIndexArrayPrecise(unsigned long count, unsig if (!m_boundElementArrayBuffer->elementArrayBuffer()) return false; - unsigned long uoffset = static_cast<unsigned long>(offset); + unsigned long uoffset = offset; unsigned long n = count; if (type == GraphicsContext3D::UNSIGNED_SHORT) { // Make uoffset an element offset. - uoffset /= 2; - const unsigned short* p = static_cast<const unsigned short*>(m_boundElementArrayBuffer->elementArrayBuffer()->data()) + uoffset; + uoffset /= sizeof(GC3Dushort); + const GC3Dushort* p = static_cast<const GC3Dushort*>(m_boundElementArrayBuffer->elementArrayBuffer()->data()) + uoffset; while (n-- > 0) { if (*p > lastIndex) lastIndex = *p; ++p; } } else if (type == GraphicsContext3D::UNSIGNED_BYTE) { - const unsigned char* p = static_cast<const unsigned char*>(m_boundElementArrayBuffer->elementArrayBuffer()->data()) + uoffset; + const GC3Dubyte* p = static_cast<const GC3Dubyte*>(m_boundElementArrayBuffer->elementArrayBuffer()->data()) + uoffset; while (n-- > 0) { if (*p > lastIndex) lastIndex = *p; @@ -1118,7 +1114,7 @@ bool WebGLRenderingContext::validateIndexArrayPrecise(unsigned long count, unsig return numElementsRequired > 0; } -bool WebGLRenderingContext::validateRenderingState(long numElementsRequired) +bool WebGLRenderingContext::validateRenderingState(int numElementsRequired) { if (!m_currentProgram) return false; @@ -1136,7 +1132,7 @@ bool WebGLRenderingContext::validateRenderingState(long numElementsRequired) return true; // Look in each consumed vertex attrib (by the current program) and find the smallest buffer size - long smallestNumElements = LONG_MAX; + int smallestNumElements = INT_MAX; int numActiveAttribLocations = m_currentProgram->numActiveAttribLocations(); for (int i = 0; i < numActiveAttribLocations; ++i) { int loc = m_currentProgram->getActiveAttribLocation(i); @@ -1146,8 +1142,9 @@ bool WebGLRenderingContext::validateRenderingState(long numElementsRequired) // Avoid off-by-one errors in numElements computation. // For the last element, we will only touch the data for the // element and nothing beyond it. - long bytesRemaining = state.bufferBinding->byteLength() - state.offset; - long numElements = 0; + int bytesRemaining = static_cast<int>(state.bufferBinding->byteLength() - state.offset); + int numElements = 0; + ASSERT(state.stride > 0); if (bytesRemaining >= state.bytesPerElement) numElements = 1 + (bytesRemaining - state.bytesPerElement) / state.stride; if (numElements < smallestNumElements) @@ -1156,7 +1153,7 @@ bool WebGLRenderingContext::validateRenderingState(long numElementsRequired) } } - if (smallestNumElements == LONG_MAX) + if (smallestNumElements == INT_MAX) smallestNumElements = 0; return numElementsRequired <= smallestNumElements; @@ -1175,7 +1172,7 @@ bool WebGLRenderingContext::validateWebGLObject(WebGLObject* object) return true; } -void WebGLRenderingContext::drawArrays(unsigned long mode, long first, long count, ExceptionCode& ec) +void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count, ExceptionCode& ec) { UNUSED_PARAM(ec); @@ -1195,9 +1192,9 @@ void WebGLRenderingContext::drawArrays(unsigned long mode, long first, long coun if (!isErrorGeneratedOnOutOfBoundsAccesses()) { // Ensure we have a valid rendering state - CheckedInt<int32_t> checkedFirst(first); - CheckedInt<int32_t> checkedCount(count); - CheckedInt<int32_t> checkedSum = checkedFirst + checkedCount; + CheckedInt<GC3Dint> checkedFirst(first); + CheckedInt<GC3Dint> checkedCount(count); + CheckedInt<GC3Dint> checkedSum = checkedFirst + checkedCount; if (!checkedSum.valid() || !validateRenderingState(checkedSum.value())) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); return; @@ -1227,7 +1224,7 @@ void WebGLRenderingContext::drawArrays(unsigned long mode, long first, long coun cleanupAfterGraphicsCall(true); } -void WebGLRenderingContext::drawElements(unsigned long mode, long count, unsigned long type, long offset, ExceptionCode& ec) +void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, ExceptionCode& ec) { UNUSED_PARAM(ec); @@ -1254,7 +1251,7 @@ void WebGLRenderingContext::drawElements(unsigned long mode, long count, unsigne if (!count) return; - long numElements = 0; + int numElements = 0; if (!isErrorGeneratedOnOutOfBoundsAccesses()) { // Ensure we have a valid rendering state if (!validateElementArraySize(count, type, offset)) { @@ -1297,7 +1294,7 @@ void WebGLRenderingContext::drawElements(unsigned long mode, long count, unsigne cleanupAfterGraphicsCall(true); } -void WebGLRenderingContext::enable(unsigned long cap) +void WebGLRenderingContext::enable(GC3Denum cap) { if (isContextLost() || !validateCapability(cap)) return; @@ -1305,7 +1302,7 @@ void WebGLRenderingContext::enable(unsigned long cap) cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::enableVertexAttribArray(unsigned long index, ExceptionCode& ec) +void WebGLRenderingContext::enableVertexAttribArray(GC3Duint index, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -1341,7 +1338,7 @@ void WebGLRenderingContext::flush() cleanupAfterGraphicsCall(true); } -void WebGLRenderingContext::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, WebGLRenderbuffer* buffer, ExceptionCode& ec) +void WebGLRenderingContext::framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateFramebufferFuncParameters(target, attachment)) @@ -1412,7 +1409,7 @@ void WebGLRenderingContext::framebufferRenderbuffer(unsigned long target, unsign cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, WebGLTexture* texture, long level, ExceptionCode& ec) +void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateFramebufferFuncParameters(target, attachment)) @@ -1437,7 +1434,7 @@ void WebGLRenderingContext::framebufferTexture2D(unsigned long target, unsigned cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::frontFace(unsigned long mode) +void WebGLRenderingContext::frontFace(GC3Denum mode) { if (isContextLost()) return; @@ -1445,7 +1442,7 @@ void WebGLRenderingContext::frontFace(unsigned long mode) cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::generateMipmap(unsigned long target) +void WebGLRenderingContext::generateMipmap(GC3Denum target) { if (isContextLost()) return; @@ -1474,7 +1471,7 @@ void WebGLRenderingContext::generateMipmap(unsigned long target) cleanupAfterGraphicsCall(false); } -PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram* program, unsigned long index, ExceptionCode& ec) +PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram* program, GC3Duint index, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateWebGLObject(program)) @@ -1485,7 +1482,7 @@ PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram* return WebGLActiveInfo::create(info.name, info.type, info.size); } -PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveUniform(WebGLProgram* program, unsigned long index, ExceptionCode& ec) +PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveUniform(WebGLProgram* program, GC3Duint index, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateWebGLObject(program)) @@ -1505,16 +1502,16 @@ bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Web shaderObjects.clear(); if (isContextLost() || !validateWebGLObject(program)) return false; - int numShaders = 0; + GC3Dint numShaders = 0; m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ATTACHED_SHADERS, &numShaders); if (numShaders) { - OwnArrayPtr<unsigned int> shaders(new unsigned int[numShaders]); - int count = 0; + OwnArrayPtr<Platform3DObject> shaders(new Platform3DObject[numShaders]); + GC3Dsizei count = 0; m_context->getAttachedShaders(objectOrZero(program), numShaders, &count, shaders.get()); if (count != numShaders) return false; shaderObjects.resize(numShaders); - for (int ii = 0; ii < numShaders; ++ii) { + for (GC3Dint ii = 0; ii < numShaders; ++ii) { WebGLShader* shader = findShader(shaders[ii]); if (!shader) { shaderObjects.clear(); @@ -1526,7 +1523,7 @@ bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Web return true; } -int WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const String& name) +GC3Dint WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const String& name) { if (isContextLost()) return -1; @@ -1535,7 +1532,7 @@ int WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const String return m_context->getAttribLocation(objectOrZero(program), name); } -WebGLGetInfo WebGLRenderingContext::getBufferParameter(unsigned long target, unsigned long pname, ExceptionCode& ec) +WebGLGetInfo WebGLRenderingContext::getBufferParameter(GC3Denum target, GC3Denum pname, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -1551,7 +1548,7 @@ WebGLGetInfo WebGLRenderingContext::getBufferParameter(unsigned long target, uns } WebGLStateRestorer(this, false); - int value = 0; + GC3Dint value = 0; m_context->getBufferParameteriv(target, pname, &value); if (pname == GraphicsContext3D::BUFFER_SIZE) return WebGLGetInfo(static_cast<long>(value)); @@ -1567,7 +1564,7 @@ PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes() return WebGLContextAttributes::create(m_context->getContextAttributes()); } -unsigned long WebGLRenderingContext::getError() +GC3Denum WebGLRenderingContext::getError() { return m_context->getError(); } @@ -1593,7 +1590,7 @@ WebGLExtension* WebGLRenderingContext::getExtension(const String& name) return 0; } -WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(unsigned long target, unsigned long attachment, unsigned long pname, ExceptionCode& ec) +WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateFramebufferFuncParameters(target, attachment)) @@ -1616,7 +1613,7 @@ WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(unsigned l if (pname != GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { WebGLStateRestorer(this, false); - int value = 0; + GC3Dint value = 0; m_context->getFramebufferAttachmentParameteriv(target, attachment, pname, &value); if (pname == GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) return WebGLGetInfo(static_cast<unsigned long>(value)); @@ -1624,11 +1621,11 @@ WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(unsigned l } WebGLStateRestorer(this, false); - int type = 0; + GC3Dint type = 0; m_context->getFramebufferAttachmentParameteriv(target, attachment, GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type); if (!type) return WebGLGetInfo(); - int value = 0; + GC3Dint value = 0; m_context->getFramebufferAttachmentParameteriv(target, attachment, GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &value); switch (type) { case GraphicsContext3D::RENDERBUFFER: @@ -1641,7 +1638,7 @@ WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(unsigned l } } -WebGLGetInfo WebGLRenderingContext::getParameter(unsigned long pname, ExceptionCode& ec) +WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -1819,7 +1816,7 @@ WebGLGetInfo WebGLRenderingContext::getParameter(unsigned long pname, ExceptionC case GraphicsContext3D::UNPACK_PREMULTIPLY_ALPHA_WEBGL: return WebGLGetInfo(m_unpackPremultiplyAlpha); case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL: - return WebGLGetInfo(m_unpackColorspaceConversion); + return WebGLGetInfo(static_cast<unsigned long>(m_unpackColorspaceConversion)); case GraphicsContext3D::VENDOR: return WebGLGetInfo("Webkit (" + m_context->getString(GraphicsContext3D::VENDOR) + ")"); case GraphicsContext3D::VERSION: @@ -1832,14 +1829,14 @@ WebGLGetInfo WebGLRenderingContext::getParameter(unsigned long pname, ExceptionC } } -WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, unsigned long pname, ExceptionCode& ec) +WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, GC3Denum pname, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateWebGLObject(program)) return WebGLGetInfo(); WebGLStateRestorer(this, false); - int value = 0; + GC3Dint value = 0; switch (pname) { case GraphicsContext3D::DELETE_STATUS: return WebGLGetInfo(program->isDeleted()); @@ -1873,7 +1870,7 @@ String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program, Exception return m_context->getProgramInfoLog(objectOrZero(program)); } -WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(unsigned long target, unsigned long pname, ExceptionCode& ec) +WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(GC3Denum target, GC3Denum pname, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -1911,7 +1908,7 @@ WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(unsigned long targe value = 8; break; case GraphicsContext3D::RENDERBUFFER_INTERNAL_FORMAT: - return WebGLGetInfo(m_renderbufferBinding->getInternalFormat()); + return WebGLGetInfo(static_cast<unsigned long>(m_renderbufferBinding->getInternalFormat())); default: m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); return WebGLGetInfo(); @@ -1920,7 +1917,7 @@ WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(unsigned long targe } WebGLStateRestorer(this, false); - int value = 0; + GC3Dint value = 0; switch (pname) { case GraphicsContext3D::RENDERBUFFER_WIDTH: case GraphicsContext3D::RENDERBUFFER_HEIGHT: @@ -1933,20 +1930,20 @@ WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(unsigned long targe m_context->getRenderbufferParameteriv(target, pname, &value); return WebGLGetInfo(static_cast<long>(value)); case GraphicsContext3D::RENDERBUFFER_INTERNAL_FORMAT: - return WebGLGetInfo(m_renderbufferBinding->getInternalFormat()); + return WebGLGetInfo(static_cast<unsigned long>(m_renderbufferBinding->getInternalFormat())); default: m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); return WebGLGetInfo(); } } -WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, unsigned long pname, ExceptionCode& ec) +WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3Denum pname, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateWebGLObject(shader)) return WebGLGetInfo(); WebGLStateRestorer(this, false); - int value = 0; + GC3Dint value = 0; switch (pname) { case GraphicsContext3D::DELETE_STATUS: return WebGLGetInfo(shader->isDeleted()); @@ -1997,7 +1994,7 @@ Vector<String> WebGLRenderingContext::getSupportedExtensions() return result; } -WebGLGetInfo WebGLRenderingContext::getTexParameter(unsigned long target, unsigned long pname, ExceptionCode& ec) +WebGLGetInfo WebGLRenderingContext::getTexParameter(GC3Denum target, GC3Denum pname, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -2006,7 +2003,7 @@ WebGLGetInfo WebGLRenderingContext::getTexParameter(unsigned long target, unsign if (!tex) return WebGLGetInfo(); WebGLStateRestorer(this, false); - int value = 0; + GC3Dint value = 0; switch (pname) { case GraphicsContext3D::TEXTURE_MAG_FILTER: case GraphicsContext3D::TEXTURE_MIN_FILTER: @@ -2029,13 +2026,13 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); return WebGLGetInfo(); } - long location = uniformLocation->location(); + GC3Dint location = uniformLocation->location(); WebGLStateRestorer(this, false); // FIXME: make this more efficient using WebGLUniformLocation and caching types in it - int activeUniforms = 0; + GC3Dint activeUniforms = 0; m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ACTIVE_UNIFORMS, &activeUniforms); - for (int i = 0; i < activeUniforms; i++) { + for (GC3Dint i = 0; i < activeUniforms; i++) { ActiveInfo info; if (!m_context->getActiveUniform(objectOrZero(program), i, info)) return WebGLGetInfo(); @@ -2043,7 +2040,7 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG if (info.size > 1) info.name = info.name.left(info.name.length() - 3); // If it's an array, we need to iterate through each element, appending "[index]" to the name. - for (int index = 0; index < info.size; ++index) { + for (GC3Dint index = 0; index < info.size; ++index) { String name = info.name; if (info.size > 1 && index >= 1) { name.append('['); @@ -2051,11 +2048,11 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG name.append(']'); } // Now need to look this up by name again to find its location - long loc = m_context->getUniformLocation(objectOrZero(program), name); + GC3Dint loc = m_context->getUniformLocation(objectOrZero(program), name); if (loc == location) { // Found it. Use the type in the ActiveInfo to determine the return type. - GraphicsContext3D::WebGLEnumType baseType; - unsigned length; + GC3Denum baseType; + unsigned int length; switch (info.type) { case GraphicsContext3D::BOOL: baseType = GraphicsContext3D::BOOL; @@ -2125,21 +2122,21 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG } switch (baseType) { case GraphicsContext3D::FLOAT: { - float value[16] = {0}; + GC3Dfloat value[16] = {0}; m_context->getUniformfv(objectOrZero(program), location, value); if (length == 1) return WebGLGetInfo(value[0]); return WebGLGetInfo(Float32Array::create(value, length)); } case GraphicsContext3D::INT: { - int value[4] = {0}; + GC3Dint value[4] = {0}; m_context->getUniformiv(objectOrZero(program), location, value); if (length == 1) return WebGLGetInfo(static_cast<long>(value[0])); return WebGLGetInfo(Int32Array::create(value, length)); } case GraphicsContext3D::BOOL: { - int value[4] = {0}; + GC3Dint value[4] = {0}; m_context->getUniformiv(objectOrZero(program), location, value); if (length > 1) { bool boolValue[16] = {0}; @@ -2168,13 +2165,13 @@ PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL if (!validateString(name)) return 0; WebGLStateRestorer(this, false); - long uniformLocation = m_context->getUniformLocation(objectOrZero(program), name); + GC3Dint uniformLocation = m_context->getUniformLocation(objectOrZero(program), name); if (uniformLocation == -1) return 0; return WebGLUniformLocation::create(program, uniformLocation); } -WebGLGetInfo WebGLRenderingContext::getVertexAttrib(unsigned long index, unsigned long pname, ExceptionCode& ec) +WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pname, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -2203,15 +2200,15 @@ WebGLGetInfo WebGLRenderingContext::getVertexAttrib(unsigned long index, unsigne case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_SIZE: if (index >= m_vertexAttribState.size()) return WebGLGetInfo(static_cast<long>(4)); - return WebGLGetInfo(m_vertexAttribState[index].size); + return WebGLGetInfo(static_cast<long>(m_vertexAttribState[index].size)); case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_STRIDE: if (index >= m_vertexAttribState.size()) return WebGLGetInfo(static_cast<long>(0)); - return WebGLGetInfo(m_vertexAttribState[index].originalStride); + return WebGLGetInfo(static_cast<long>(m_vertexAttribState[index].originalStride)); case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_TYPE: if (index >= m_vertexAttribState.size()) return WebGLGetInfo(static_cast<unsigned long>(GraphicsContext3D::FLOAT)); - return WebGLGetInfo(m_vertexAttribState[index].type); + return WebGLGetInfo(static_cast<unsigned long>(m_vertexAttribState[index].type)); case GraphicsContext3D::CURRENT_VERTEX_ATTRIB: if (index >= m_vertexAttribState.size()) { float value[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; @@ -2224,16 +2221,16 @@ WebGLGetInfo WebGLRenderingContext::getVertexAttrib(unsigned long index, unsigne } } -long WebGLRenderingContext::getVertexAttribOffset(unsigned long index, unsigned long pname) +GC3Dsizeiptr WebGLRenderingContext::getVertexAttribOffset(GC3Duint index, GC3Denum pname) { if (isContextLost()) return 0; - long result = m_context->getVertexAttribOffset(index, pname); + GC3Dsizeiptr result = m_context->getVertexAttribOffset(index, pname); cleanupAfterGraphicsCall(false); return result; } -void WebGLRenderingContext::hint(unsigned long target, unsigned long mode) +void WebGLRenderingContext::hint(GC3Denum target, GC3Denum mode) { if (isContextLost()) return; @@ -2245,13 +2242,13 @@ void WebGLRenderingContext::hint(unsigned long target, unsigned long mode) cleanupAfterGraphicsCall(false); } -bool WebGLRenderingContext::isBuffer(WebGLBuffer* buffer) +GC3Dboolean WebGLRenderingContext::isBuffer(WebGLBuffer* buffer) { if (!buffer || isContextLost()) - return false; + return 0; if (!buffer->hasEverBeenBound()) - return false; + return 0; return m_context->isBuffer(buffer->object()); } @@ -2269,67 +2266,67 @@ bool WebGLRenderingContext::isContextLost() return m_contextLost; } -bool WebGLRenderingContext::isEnabled(unsigned long cap) +GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap) { if (!validateCapability(cap) || isContextLost()) - return false; + return 0; return m_context->isEnabled(cap); } -bool WebGLRenderingContext::isFramebuffer(WebGLFramebuffer* framebuffer) +GC3Dboolean WebGLRenderingContext::isFramebuffer(WebGLFramebuffer* framebuffer) { if (!framebuffer || isContextLost()) - return false; + return 0; if (!framebuffer->hasEverBeenBound()) - return false; + return 0; return m_context->isFramebuffer(framebuffer->object()); } -bool WebGLRenderingContext::isProgram(WebGLProgram* program) +GC3Dboolean WebGLRenderingContext::isProgram(WebGLProgram* program) { if (!program || isContextLost()) - return false; + return 0; return m_context->isProgram(program->object()); } -bool WebGLRenderingContext::isRenderbuffer(WebGLRenderbuffer* renderbuffer) +GC3Dboolean WebGLRenderingContext::isRenderbuffer(WebGLRenderbuffer* renderbuffer) { if (!renderbuffer || isContextLost()) - return false; + return 0; if (!renderbuffer->hasEverBeenBound()) - return false; + return 0; return m_context->isRenderbuffer(renderbuffer->object()); } -bool WebGLRenderingContext::isShader(WebGLShader* shader) +GC3Dboolean WebGLRenderingContext::isShader(WebGLShader* shader) { if (!shader || isContextLost()) - return false; + return 0; return m_context->isShader(shader->object()); } -bool WebGLRenderingContext::isTexture(WebGLTexture* texture) +GC3Dboolean WebGLRenderingContext::isTexture(WebGLTexture* texture) { if (!texture || isContextLost()) - return false; + return 0; if (!texture->hasEverBeenBound()) - return false; + return 0; return m_context->isTexture(texture->object()); } -void WebGLRenderingContext::lineWidth(float width) +void WebGLRenderingContext::lineWidth(GC3Dfloat width) { if (isContextLost()) return; - m_context->lineWidth((float) width); + m_context->lineWidth(width); cleanupAfterGraphicsCall(false); } @@ -2348,7 +2345,7 @@ void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode& ec m_context->linkProgram(objectOrZero(program)); program->increaseLinkCount(); // cache link status - int value = 0; + GC3Dint value = 0; m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::LINK_STATUS, &value); program->setLinkStatus(static_cast<bool>(value)); // Need to cache link status before caching active attribute locations. @@ -2356,7 +2353,7 @@ void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode& ec cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::pixelStorei(unsigned long pname, long param) +void WebGLRenderingContext::pixelStorei(GC3Denum pname, GC3Dint param) { if (isContextLost()) return; @@ -2369,7 +2366,7 @@ void WebGLRenderingContext::pixelStorei(unsigned long pname, long param) break; case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL: if (param == GraphicsContext3D::BROWSER_DEFAULT_WEBGL || param == GraphicsContext3D::NONE) - m_unpackColorspaceConversion = static_cast<unsigned long>(param); + m_unpackColorspaceConversion = static_cast<GC3Denum>(param); else { m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); return; @@ -2379,9 +2376,9 @@ void WebGLRenderingContext::pixelStorei(unsigned long pname, long param) case GraphicsContext3D::UNPACK_ALIGNMENT: if (param == 1 || param == 2 || param == 4 || param == 8) { if (pname == GraphicsContext3D::PACK_ALIGNMENT) - m_packAlignment = static_cast<int>(param); + m_packAlignment = param; else // GraphicsContext3D::UNPACK_ALIGNMENT: - m_unpackAlignment = static_cast<int>(param); + m_unpackAlignment = param; m_context->pixelStorei(pname, param); cleanupAfterGraphicsCall(false); } else { @@ -2395,15 +2392,15 @@ void WebGLRenderingContext::pixelStorei(unsigned long pname, long param) } } -void WebGLRenderingContext::polygonOffset(float factor, float units) +void WebGLRenderingContext::polygonOffset(GC3Dfloat factor, GC3Dfloat units) { if (isContextLost()) return; - m_context->polygonOffset((float) factor, (float) units); + m_context->polygonOffset(factor, units); cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::readPixels(long x, long y, long width, long height, unsigned long format, unsigned long type, ArrayBufferView* pixels, ExceptionCode& ec) +void WebGLRenderingContext::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode& ec) { if (isContextLost()) return; @@ -2412,30 +2409,35 @@ void WebGLRenderingContext::readPixels(long x, long y, long width, long height, return; } // Validate input parameters. - unsigned int componentsPerPixel, bytesPerComponent; - if (!m_context->computeFormatAndTypeParameters(format, type, &componentsPerPixel, &bytesPerComponent)) { - m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); - return; - } if (!pixels) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); return; } - if (width < 0 || height < 0) { - m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); + switch (format) { + case GraphicsContext3D::ALPHA: + case GraphicsContext3D::RGB: + case GraphicsContext3D::RGBA: + break; + default: + m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); return; } - if (format != GraphicsContext3D::RGBA && type != GraphicsContext3D::UNSIGNED_BYTE) { - m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); + switch (type) { + case GraphicsContext3D::UNSIGNED_BYTE: + case GraphicsContext3D::UNSIGNED_SHORT_5_6_5: + case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4: + case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1: + break; + default: + m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); return; } if (format != GraphicsContext3D::RGBA || type != GraphicsContext3D::UNSIGNED_BYTE) { - m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); + m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); return; } // Validate array type against pixel type. - if ((type == GraphicsContext3D::UNSIGNED_BYTE && !pixels->isUnsignedByteArray()) - || (type != GraphicsContext3D::UNSIGNED_BYTE && !pixels->isUnsignedShortArray())) { + if (!pixels->isUnsignedByteArray()) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); return; } @@ -2444,37 +2446,31 @@ void WebGLRenderingContext::readPixels(long x, long y, long width, long height, return; } // Calculate array size, taking into consideration of PACK_ALIGNMENT. - unsigned long bytesPerRow = componentsPerPixel * bytesPerComponent * width; - unsigned long padding = 0; - unsigned long residualBytes = bytesPerRow % m_packAlignment; - if (residualBytes) { - padding = m_packAlignment - residualBytes; - bytesPerRow += padding; - } - // The last row needs no padding. - unsigned long totalBytes = bytesPerRow * height - padding; - unsigned long num = totalBytes / bytesPerComponent; - if (pixels->byteLength() / bytesPerComponent < num) { + unsigned int totalBytesRequired; + unsigned int padding; + GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, height, m_packAlignment, &totalBytesRequired, &padding); + if (error != GraphicsContext3D::NO_ERROR) { + m_context->synthesizeGLError(error); + return; + } + if (pixels->byteLength() < totalBytesRequired) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); return; } void* data = pixels->baseAddress(); m_context->readPixels(x, y, width, height, format, type, data); -#if PLATFORM(CG) +#if OS(DARWIN) // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., // when alpha is off, readPixels should set alpha to 255 instead of 0. - if ((format == GraphicsContext3D::ALPHA || format == GraphicsContext3D::RGBA) && !m_context->getContextAttributes().alpha) { - if (type == GraphicsContext3D::UNSIGNED_BYTE) { - unsigned char* pixels = reinterpret_cast<unsigned char*>(data); - for (long iy = 0; iy < height; ++iy) { - for (long ix = 0; ix < width; ++ix) { - pixels[componentsPerPixel - 1] = 255; - pixels += componentsPerPixel; - } - pixels += padding; + if (!m_context->getContextAttributes().alpha) { + unsigned char* pixels = reinterpret_cast<unsigned char*>(data); + for (GC3Dsizei iy = 0; iy < height; ++iy) { + for (GC3Dsizei ix = 0; ix < width; ++ix) { + pixels[3] = 255; + pixels += 4; } + pixels += padding; } - // FIXME: check whether we need to do the same with UNSIGNED_SHORT. } #endif cleanupAfterGraphicsCall(false); @@ -2488,7 +2484,7 @@ void WebGLRenderingContext::releaseShaderCompiler() cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::renderbufferStorage(unsigned long target, unsigned long internalformat, long width, long height) +void WebGLRenderingContext::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) { if (isContextLost()) return; @@ -2528,15 +2524,15 @@ void WebGLRenderingContext::renderbufferStorage(unsigned long target, unsigned l } } -void WebGLRenderingContext::sampleCoverage(float value, bool invert) +void WebGLRenderingContext::sampleCoverage(GC3Dfloat value, GC3Dboolean invert) { if (isContextLost()) return; - m_context->sampleCoverage((float) value, invert); + m_context->sampleCoverage(value, invert); cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::scissor(long x, long y, long width, long height) +void WebGLRenderingContext::scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) { if (isContextLost()) return; @@ -2557,7 +2553,7 @@ void WebGLRenderingContext::shaderSource(WebGLShader* shader, const String& stri cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::stencilFunc(unsigned long func, long ref, unsigned long mask) +void WebGLRenderingContext::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask) { if (isContextLost()) return; @@ -2571,7 +2567,7 @@ void WebGLRenderingContext::stencilFunc(unsigned long func, long ref, unsigned l cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask) +void WebGLRenderingContext::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask) { if (isContextLost()) return; @@ -2600,7 +2596,7 @@ void WebGLRenderingContext::stencilFuncSeparate(unsigned long face, unsigned lon cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::stencilMask(unsigned long mask) +void WebGLRenderingContext::stencilMask(GC3Duint mask) { if (isContextLost()) return; @@ -2610,7 +2606,7 @@ void WebGLRenderingContext::stencilMask(unsigned long mask) cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::stencilMaskSeparate(unsigned long face, unsigned long mask) +void WebGLRenderingContext::stencilMaskSeparate(GC3Denum face, GC3Duint mask) { if (isContextLost()) return; @@ -2633,7 +2629,7 @@ void WebGLRenderingContext::stencilMaskSeparate(unsigned long face, unsigned lon cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass) +void WebGLRenderingContext::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass) { if (isContextLost()) return; @@ -2641,7 +2637,7 @@ void WebGLRenderingContext::stencilOp(unsigned long fail, unsigned long zfail, u cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass) +void WebGLRenderingContext::stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass) { if (isContextLost()) return; @@ -2649,9 +2645,9 @@ void WebGLRenderingContext::stencilOpSeparate(unsigned long face, unsigned long cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsigned internalformat, - int width, int height, unsigned border, - unsigned format, unsigned type, void* pixels, ExceptionCode& ec) +void WebGLRenderingContext::texImage2DBase(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Dsizei width, GC3Dsizei height, GC3Dint border, + GC3Denum format, GC3Denum type, void* pixels, ExceptionCode& ec) { // FIXME: For now we ignore any errors returned ec = 0; @@ -2668,7 +2664,7 @@ void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsi } if (!pixels && !isResourceSafe()) { bool succeed = m_context->texImage2DResourceSafe(target, level, internalformat, width, height, - border, format, type); + border, format, type, m_unpackAlignment); if (!succeed) return; } else { @@ -2679,8 +2675,8 @@ void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsi cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::texImage2DImpl(unsigned target, unsigned level, unsigned internalformat, - unsigned format, unsigned type, Image* image, +void WebGLRenderingContext::texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Denum format, GC3Denum type, Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode& ec) { ec = 0; @@ -2697,9 +2693,9 @@ void WebGLRenderingContext::texImage2DImpl(unsigned target, unsigned level, unsi m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); } -void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat, - int width, int height, unsigned border, - unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode& ec) +void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Dsizei width, GC3Dsizei height, GC3Dint border, + GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode& ec) { if (isContextLost() || !validateTexFuncData(width, height, format, type, pixels)) return; @@ -2724,8 +2720,8 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); } -void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat, - unsigned format, unsigned type, ImageData* pixels, ExceptionCode& ec) +void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionCode& ec) { ec = 0; if (isContextLost()) @@ -2743,8 +2739,8 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); } -void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat, - unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode& ec) +void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionCode& ec) { ec = 0; if (isContextLost()) @@ -2758,8 +2754,8 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned m_unpackFlipY, m_unpackPremultiplyAlpha, ec); } -void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat, - unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode& ec) +void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionCode& ec) { ec = 0; if (isContextLost()) @@ -2792,8 +2788,8 @@ PassRefPtr<Image> WebGLRenderingContext::videoFrameToImage(HTMLVideoElement* vid return buf->copyImage(); } -void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat, - unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode& ec) +void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionCode& ec) { ec = 0; if (isContextLost()) @@ -2804,7 +2800,7 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned texImage2DImpl(target, level, internalformat, format, type, image.get(), m_unpackFlipY, m_unpackPremultiplyAlpha, ec); } -void WebGLRenderingContext::texParameter(unsigned long target, unsigned long pname, float paramf, int parami, bool isFloat) +void WebGLRenderingContext::texParameter(GC3Denum target, GC3Denum pname, GC3Dfloat paramf, GC3Dint parami, bool isFloat) { if (isContextLost()) return; @@ -2837,19 +2833,19 @@ void WebGLRenderingContext::texParameter(unsigned long target, unsigned long pna cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::texParameterf(unsigned target, unsigned pname, float param) +void WebGLRenderingContext::texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat param) { texParameter(target, pname, param, 0, true); } -void WebGLRenderingContext::texParameteri(unsigned target, unsigned pname, int param) +void WebGLRenderingContext::texParameteri(GC3Denum target, GC3Denum pname, GC3Dint param) { texParameter(target, pname, 0, param, false); } -void WebGLRenderingContext::texSubImage2DBase(unsigned target, unsigned level, int xoffset, int yoffset, - int width, int height, - unsigned format, unsigned type, void* pixels, ExceptionCode& ec) +void WebGLRenderingContext::texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Dsizei width, GC3Dsizei height, + GC3Denum format, GC3Denum type, void* pixels, ExceptionCode& ec) { // FIXME: For now we ignore any errors returned ec = 0; @@ -2865,8 +2861,8 @@ void WebGLRenderingContext::texSubImage2DBase(unsigned target, unsigned level, i cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::texSubImage2DImpl(unsigned target, unsigned level, int xoffset, int yoffset, - unsigned format, unsigned type, +void WebGLRenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Denum format, GC3Denum type, Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode& ec) { ec = 0; @@ -2881,9 +2877,9 @@ void WebGLRenderingContext::texSubImage2DImpl(unsigned target, unsigned level, i format, type, data.data(), ec); } -void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, int xoffset, int yoffset, - int width, int height, - unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode& ec) +void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Dsizei width, GC3Dsizei height, + GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode& ec) { if (isContextLost() || !validateTexFuncData(width, height, format, type, pixels)) return; @@ -2907,8 +2903,8 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, int x m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment); } -void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, int xoffset, int yoffset, - unsigned format, unsigned type, ImageData* pixels, ExceptionCode& ec) +void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionCode& ec) { ec = 0; if (isContextLost()) @@ -2922,8 +2918,8 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, int x format, type, data.data(), ec); } -void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, int xoffset, int yoffset, - unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode& ec) +void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionCode& ec) { ec = 0; if (isContextLost()) @@ -2937,8 +2933,8 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, int x m_unpackFlipY, m_unpackPremultiplyAlpha, ec); } -void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, int xoffset, int yoffset, - unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode& ec) +void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionCode& ec) { ec = 0; if (isContextLost()) @@ -2952,8 +2948,8 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, int x m_unpackFlipY, m_unpackPremultiplyAlpha, ec); } -void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, int xoffset, int yoffset, - unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode& ec) +void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionCode& ec) { ec = 0; if (isContextLost()) @@ -2964,7 +2960,7 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, int x texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), m_unpackFlipY, m_unpackPremultiplyAlpha, ec); } -void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, float x, ExceptionCode& ec) +void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, GC3Dfloat x, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !location) @@ -2989,7 +2985,7 @@ void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, Flo cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec) +void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformParameters(location, v, size, 1)) @@ -2999,7 +2995,7 @@ void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, flo cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, int x, ExceptionCode& ec) +void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, GC3Dint x, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !location) @@ -3024,7 +3020,7 @@ void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec) +void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformParameters(location, v, size, 1)) @@ -3034,7 +3030,7 @@ void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, int cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, float x, float y, ExceptionCode& ec) +void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !location) @@ -3059,7 +3055,7 @@ void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, Flo cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec) +void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformParameters(location, v, size, 2)) @@ -3069,7 +3065,7 @@ void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, flo cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, int x, int y, ExceptionCode& ec) +void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !location) @@ -3094,7 +3090,7 @@ void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec) +void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformParameters(location, v, size, 2)) @@ -3104,7 +3100,7 @@ void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, int cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, float x, float y, float z, ExceptionCode& ec) +void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !location) @@ -3129,7 +3125,7 @@ void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, Flo cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec) +void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformParameters(location, v, size, 3)) @@ -3139,7 +3135,7 @@ void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, flo cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, int x, int y, int z, ExceptionCode& ec) +void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y, GC3Dint z, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !location) @@ -3164,7 +3160,7 @@ void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec) +void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformParameters(location, v, size, 3)) @@ -3174,7 +3170,7 @@ void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, int cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, float x, float y, float z, float w, ExceptionCode& ec) +void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !location) @@ -3199,7 +3195,7 @@ void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, Flo cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec) +void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformParameters(location, v, size, 4)) @@ -3209,7 +3205,7 @@ void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, flo cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, int x, int y, int z, int w, ExceptionCode& ec) +void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !location) @@ -3234,7 +3230,7 @@ void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec) +void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformParameters(location, v, size, 4)) @@ -3244,7 +3240,7 @@ void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, int cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec) +void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, 4)) @@ -3253,7 +3249,7 @@ void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec) +void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, size, 4)) @@ -3262,7 +3258,7 @@ void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec) +void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, 9)) @@ -3271,7 +3267,7 @@ void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec) +void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, size, 9)) @@ -3280,7 +3276,7 @@ void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec) +void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, 16)) @@ -3289,7 +3285,7 @@ void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* locatio cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec) +void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, size, 16)) @@ -3332,67 +3328,67 @@ void WebGLRenderingContext::validateProgram(WebGLProgram* program, ExceptionCode cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::vertexAttrib1f(unsigned long index, float v0) +void WebGLRenderingContext::vertexAttrib1f(GC3Duint index, GC3Dfloat v0) { vertexAttribfImpl(index, 1, v0, 0.0f, 0.0f, 1.0f); } -void WebGLRenderingContext::vertexAttrib1fv(unsigned long index, Float32Array* v) +void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, Float32Array* v) { vertexAttribfvImpl(index, v, 1); } -void WebGLRenderingContext::vertexAttrib1fv(unsigned long index, float* v, int size) +void WebGLRenderingContext::vertexAttrib1fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size) { vertexAttribfvImpl(index, v, size, 1); } -void WebGLRenderingContext::vertexAttrib2f(unsigned long index, float v0, float v1) +void WebGLRenderingContext::vertexAttrib2f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1) { vertexAttribfImpl(index, 2, v0, v1, 0.0f, 1.0f); } -void WebGLRenderingContext::vertexAttrib2fv(unsigned long index, Float32Array* v) +void WebGLRenderingContext::vertexAttrib2fv(GC3Duint index, Float32Array* v) { vertexAttribfvImpl(index, v, 2); } -void WebGLRenderingContext::vertexAttrib2fv(unsigned long index, float* v, int size) +void WebGLRenderingContext::vertexAttrib2fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size) { vertexAttribfvImpl(index, v, size, 2); } -void WebGLRenderingContext::vertexAttrib3f(unsigned long index, float v0, float v1, float v2) +void WebGLRenderingContext::vertexAttrib3f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2) { vertexAttribfImpl(index, 3, v0, v1, v2, 1.0f); } -void WebGLRenderingContext::vertexAttrib3fv(unsigned long index, Float32Array* v) +void WebGLRenderingContext::vertexAttrib3fv(GC3Duint index, Float32Array* v) { vertexAttribfvImpl(index, v, 3); } -void WebGLRenderingContext::vertexAttrib3fv(unsigned long index, float* v, int size) +void WebGLRenderingContext::vertexAttrib3fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size) { vertexAttribfvImpl(index, v, size, 3); } -void WebGLRenderingContext::vertexAttrib4f(unsigned long index, float v0, float v1, float v2, float v3) +void WebGLRenderingContext::vertexAttrib4f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) { vertexAttribfImpl(index, 4, v0, v1, v2, v3); } -void WebGLRenderingContext::vertexAttrib4fv(unsigned long index, Float32Array* v) +void WebGLRenderingContext::vertexAttrib4fv(GC3Duint index, Float32Array* v) { vertexAttribfvImpl(index, v, 4); } -void WebGLRenderingContext::vertexAttrib4fv(unsigned long index, float* v, int size) +void WebGLRenderingContext::vertexAttrib4fv(GC3Duint index, GC3Dfloat* v, GC3Dsizei size) { vertexAttribfvImpl(index, v, size, 4); } -void WebGLRenderingContext::vertexAttribPointer(unsigned long index, long size, unsigned long type, bool normalized, long stride, long offset, ExceptionCode& ec) +void WebGLRenderingContext::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset, ExceptionCode& ec) { UNUSED_PARAM(ec); if (isContextLost()) @@ -3421,8 +3417,8 @@ void WebGLRenderingContext::vertexAttribPointer(unsigned long index, long size, return; } // Determine the number of elements the bound buffer can hold, given the offset, size, type and stride - long typeSize = sizeInBytes(type); - if (typeSize <= 0) { + unsigned int typeSize = sizeInBytes(type); + if (!typeSize) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); return; } @@ -3430,12 +3426,12 @@ void WebGLRenderingContext::vertexAttribPointer(unsigned long index, long size, m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); return; } - long bytesPerElement = size * typeSize; + GC3Dsizei bytesPerElement = size * typeSize; if (index >= m_vertexAttribState.size()) m_vertexAttribState.resize(index + 1); - long validatedStride = stride ? stride : bytesPerElement; + GC3Dsizei validatedStride = stride ? stride : bytesPerElement; m_vertexAttribState[index].bufferBinding = m_boundArrayBuffer; m_vertexAttribState[index].bytesPerElement = bytesPerElement; @@ -3449,7 +3445,7 @@ void WebGLRenderingContext::vertexAttribPointer(unsigned long index, long size, cleanupAfterGraphicsCall(false); } -void WebGLRenderingContext::viewport(long x, long y, long width, long height) +void WebGLRenderingContext::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) { if (isContextLost()) return; @@ -3577,20 +3573,20 @@ WebGLShader* WebGLRenderingContext::findShader(Platform3DObject obj) return 0; } -WebGLGetInfo WebGLRenderingContext::getBooleanParameter(unsigned long pname) +WebGLGetInfo WebGLRenderingContext::getBooleanParameter(GC3Denum pname) { - unsigned char value = 0; + GC3Dboolean value = 0; m_context->getBooleanv(pname, &value); return WebGLGetInfo(static_cast<bool>(value)); } -WebGLGetInfo WebGLRenderingContext::getBooleanArrayParameter(unsigned long pname) +WebGLGetInfo WebGLRenderingContext::getBooleanArrayParameter(GC3Denum pname) { if (pname != GraphicsContext3D::COLOR_WRITEMASK) { notImplemented(); return WebGLGetInfo(0, 0); } - unsigned char value[4] = {0}; + GC3Dboolean value[4] = {0}; m_context->getBooleanv(pname, value); bool boolValue[4]; for (int ii = 0; ii < 4; ++ii) @@ -3598,36 +3594,36 @@ WebGLGetInfo WebGLRenderingContext::getBooleanArrayParameter(unsigned long pname return WebGLGetInfo(boolValue, 4); } -WebGLGetInfo WebGLRenderingContext::getFloatParameter(unsigned long pname) +WebGLGetInfo WebGLRenderingContext::getFloatParameter(GC3Denum pname) { - float value = 0; + GC3Dfloat value = 0; m_context->getFloatv(pname, &value); - return WebGLGetInfo(static_cast<float>(value)); + return WebGLGetInfo(value); } -WebGLGetInfo WebGLRenderingContext::getIntParameter(unsigned long pname) +WebGLGetInfo WebGLRenderingContext::getIntParameter(GC3Denum pname) { return getLongParameter(pname); } -WebGLGetInfo WebGLRenderingContext::getLongParameter(unsigned long pname) +WebGLGetInfo WebGLRenderingContext::getLongParameter(GC3Denum pname) { - int value = 0; + GC3Dint value = 0; m_context->getIntegerv(pname, &value); return WebGLGetInfo(static_cast<long>(value)); } -WebGLGetInfo WebGLRenderingContext::getUnsignedLongParameter(unsigned long pname) +WebGLGetInfo WebGLRenderingContext::getUnsignedLongParameter(GC3Denum pname) { - int value = 0; + GC3Dint value = 0; m_context->getIntegerv(pname, &value); - unsigned int uValue = static_cast<unsigned int>(value); + GC3Duint uValue = static_cast<GC3Duint>(value); return WebGLGetInfo(static_cast<unsigned long>(uValue)); } -WebGLGetInfo WebGLRenderingContext::getWebGLFloatArrayParameter(unsigned long pname) +WebGLGetInfo WebGLRenderingContext::getWebGLFloatArrayParameter(GC3Denum pname) { - float value[4] = {0}; + GC3Dfloat value[4] = {0}; m_context->getFloatv(pname, value); unsigned length = 0; switch (pname) { @@ -3646,9 +3642,9 @@ WebGLGetInfo WebGLRenderingContext::getWebGLFloatArrayParameter(unsigned long pn return WebGLGetInfo(Float32Array::create(value, length)); } -WebGLGetInfo WebGLRenderingContext::getWebGLIntArrayParameter(unsigned long pname) +WebGLGetInfo WebGLRenderingContext::getWebGLIntArrayParameter(GC3Denum pname) { - int value[4] = {0}; + GC3Dint value[4] = {0}; m_context->getIntegerv(pname, value); unsigned length = 0; switch (pname) { @@ -3722,8 +3718,8 @@ void WebGLRenderingContext::createFallbackBlackTextures1x1() m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, 0); } -bool WebGLRenderingContext::isTexInternalFormatColorBufferCombinationValid(unsigned long texInternalFormat, - unsigned long colorBufferFormat) +bool WebGLRenderingContext::isTexInternalFormatColorBufferCombinationValid(GC3Denum texInternalFormat, + GC3Denum colorBufferFormat) { switch (colorBufferFormat) { case GraphicsContext3D::ALPHA: @@ -3741,7 +3737,7 @@ bool WebGLRenderingContext::isTexInternalFormatColorBufferCombinationValid(unsig return false; } -unsigned long WebGLRenderingContext::getBoundFramebufferColorFormat() +GC3Denum WebGLRenderingContext::getBoundFramebufferColorFormat() { if (m_framebufferBinding && m_framebufferBinding->object()) return m_framebufferBinding->getColorBufferFormat(); @@ -3764,7 +3760,7 @@ int WebGLRenderingContext::getBoundFramebufferHeight() return m_context->getInternalFramebufferSize().height(); } -WebGLTexture* WebGLRenderingContext::validateTextureBinding(unsigned long target, bool useSixEnumsForCubeMap) +WebGLTexture* WebGLRenderingContext::validateTextureBinding(GC3Denum target, bool useSixEnumsForCubeMap) { WebGLTexture* tex = 0; switch (target) { @@ -3799,7 +3795,7 @@ WebGLTexture* WebGLRenderingContext::validateTextureBinding(unsigned long target return tex; } -bool WebGLRenderingContext::validateSize(long x, long y) +bool WebGLRenderingContext::validateSize(GC3Dint x, GC3Dint y) { if (x < 0 || y < 0) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); @@ -3819,7 +3815,7 @@ bool WebGLRenderingContext::validateString(const String& string) return true; } -bool WebGLRenderingContext::validateTexFuncFormatAndType(unsigned long format, unsigned long type) +bool WebGLRenderingContext::validateTexFuncFormatAndType(GC3Denum format, GC3Denum type) { switch (format) { case GraphicsContext3D::ALPHA: @@ -3884,7 +3880,7 @@ bool WebGLRenderingContext::validateTexFuncFormatAndType(unsigned long format, u return true; } -bool WebGLRenderingContext::validateTexFuncLevel(unsigned long target, long level) +bool WebGLRenderingContext::validateTexFuncLevel(GC3Denum target, GC3Dint level) { if (level < 0) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); @@ -3914,10 +3910,10 @@ bool WebGLRenderingContext::validateTexFuncLevel(unsigned long target, long leve return true; } -bool WebGLRenderingContext::validateTexFuncParameters(unsigned long target, long level, - unsigned long internalformat, - long width, long height, long border, - unsigned long format, unsigned long type) +bool WebGLRenderingContext::validateTexFuncParameters(GC3Denum target, GC3Dint level, + GC3Denum internalformat, + GC3Dsizei width, GC3Dsizei height, GC3Dint border, + GC3Denum format, GC3Denum type) { // We absolutely have to validate the format and type combination. // The texImage2D entry points taking HTMLImage, etc. will produce @@ -3966,8 +3962,8 @@ bool WebGLRenderingContext::validateTexFuncParameters(unsigned long target, long return true; } -bool WebGLRenderingContext::validateTexFuncData(long width, long height, - unsigned long format, unsigned long type, +bool WebGLRenderingContext::validateTexFuncData(GC3Dsizei width, GC3Dsizei height, + GC3Denum format, GC3Denum type, ArrayBufferView* pixels) { if (!pixels) @@ -4001,20 +3997,12 @@ bool WebGLRenderingContext::validateTexFuncData(long width, long height, ASSERT_NOT_REACHED(); } - unsigned int componentsPerPixel, bytesPerComponent; - if (!m_context->computeFormatAndTypeParameters(format, type, &componentsPerPixel, &bytesPerComponent)) { - m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); + unsigned int totalBytesRequired; + GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, height, m_unpackAlignment, &totalBytesRequired, 0); + if (error != GraphicsContext3D::NO_ERROR) { + m_context->synthesizeGLError(error); return false; } - - if (!width || !height) - return true; - unsigned int validRowBytes = width * componentsPerPixel * bytesPerComponent; - unsigned int totalRowBytes = validRowBytes; - unsigned int remainder = validRowBytes % m_unpackAlignment; - if (remainder) - totalRowBytes += (m_unpackAlignment - remainder); - unsigned int totalBytesRequired = (height - 1) * totalRowBytes + validRowBytes; if (pixels->byteLength() < totalBytesRequired) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); return false; @@ -4022,7 +4010,7 @@ bool WebGLRenderingContext::validateTexFuncData(long width, long height, return true; } -bool WebGLRenderingContext::validateDrawMode(unsigned long mode) +bool WebGLRenderingContext::validateDrawMode(GC3Denum mode) { switch (mode) { case GraphicsContext3D::POINTS: @@ -4048,7 +4036,7 @@ bool WebGLRenderingContext::validateStencilSettings() return true; } -bool WebGLRenderingContext::validateStencilFunc(unsigned long func) +bool WebGLRenderingContext::validateStencilFunc(GC3Denum func) { switch (func) { case GraphicsContext3D::NEVER: @@ -4072,7 +4060,7 @@ void WebGLRenderingContext::printWarningToConsole(const String& message) message, 0, canvas()->document()->url().string()); } -bool WebGLRenderingContext::validateFramebufferFuncParameters(unsigned long target, unsigned long attachment) +bool WebGLRenderingContext::validateFramebufferFuncParameters(GC3Denum target, GC3Denum attachment) { if (target != GraphicsContext3D::FRAMEBUFFER) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); @@ -4091,7 +4079,7 @@ bool WebGLRenderingContext::validateFramebufferFuncParameters(unsigned long targ return true; } -bool WebGLRenderingContext::validateBlendEquation(unsigned long mode) +bool WebGLRenderingContext::validateBlendEquation(GC3Denum mode) { switch (mode) { case GraphicsContext3D::FUNC_ADD: @@ -4104,7 +4092,7 @@ bool WebGLRenderingContext::validateBlendEquation(unsigned long mode) } } -bool WebGLRenderingContext::validateBlendFuncFactors(unsigned long src, unsigned long dst) +bool WebGLRenderingContext::validateBlendFuncFactors(GC3Denum src, GC3Denum dst) { if (((src == GraphicsContext3D::CONSTANT_COLOR || src == GraphicsContext3D::ONE_MINUS_CONSTANT_COLOR) && (dst == GraphicsContext3D::CONSTANT_ALPHA || dst == GraphicsContext3D::ONE_MINUS_CONSTANT_ALPHA)) @@ -4116,7 +4104,7 @@ bool WebGLRenderingContext::validateBlendFuncFactors(unsigned long src, unsigned return true; } -bool WebGLRenderingContext::validateCapability(unsigned long cap) +bool WebGLRenderingContext::validateCapability(GC3Denum cap) { switch (cap) { case GraphicsContext3D::BLEND: @@ -4135,7 +4123,7 @@ bool WebGLRenderingContext::validateCapability(unsigned long cap) } } -bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, Float32Array* v, int requiredMinSize) +bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei requiredMinSize) { if (!v) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); @@ -4144,7 +4132,7 @@ bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation return validateUniformMatrixParameters(location, false, v->data(), v->length(), requiredMinSize); } -bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, Int32Array* v, int requiredMinSize) +bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, Int32Array* v, GC3Dsizei requiredMinSize) { if (!v) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); @@ -4153,12 +4141,12 @@ bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation return validateUniformMatrixParameters(location, false, v->data(), v->length(), requiredMinSize); } -bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, void* v, int size, int requiredMinSize) +bool WebGLRenderingContext::validateUniformParameters(const WebGLUniformLocation* location, void* v, GC3Dsizei size, GC3Dsizei requiredMinSize) { return validateUniformMatrixParameters(location, false, v, size, requiredMinSize); } -bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, Float32Array* v, int requiredMinSize) +bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, GC3Dsizei requiredMinSize) { if (!v) { m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); @@ -4167,7 +4155,7 @@ bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLo return validateUniformMatrixParameters(location, transpose, v->data(), v->length(), requiredMinSize); } -bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, void* v, int size, int requiredMinSize) +bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLocation* location, GC3Dboolean transpose, void* v, GC3Dsizei size, GC3Dsizei requiredMinSize) { if (!location) return false; @@ -4190,7 +4178,7 @@ bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLo return true; } -WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(unsigned long target, unsigned long usage) +WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(GC3Denum target, GC3Denum usage) { WebGLBuffer* buffer = 0; switch (target) { @@ -4218,7 +4206,7 @@ WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(unsigned long t return 0; } -void WebGLRenderingContext::vertexAttribfImpl(unsigned long index, int expectedSize, float v0, float v1, float v2, float v3) +void WebGLRenderingContext::vertexAttribfImpl(GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) { if (isContextLost()) return; @@ -4252,7 +4240,7 @@ void WebGLRenderingContext::vertexAttribfImpl(unsigned long index, int expectedS m_vertexAttribState[index].value[3] = v3; } -void WebGLRenderingContext::vertexAttribfvImpl(unsigned long index, Float32Array* v, int expectedSize) +void WebGLRenderingContext::vertexAttribfvImpl(GC3Duint index, Float32Array* v, GC3Dsizei expectedSize) { if (isContextLost()) return; @@ -4263,7 +4251,7 @@ void WebGLRenderingContext::vertexAttribfvImpl(unsigned long index, Float32Array vertexAttribfvImpl(index, v->data(), v->length(), expectedSize); } -void WebGLRenderingContext::vertexAttribfvImpl(unsigned long index, float* v, int size, int expectedSize) +void WebGLRenderingContext::vertexAttribfvImpl(GC3Duint index, GC3Dfloat* v, GC3Dsizei size, GC3Dsizei expectedSize) { if (isContextLost()) return; @@ -4321,21 +4309,21 @@ void WebGLRenderingContext::initVertexAttrib0() m_vertexAttrib0BufferValue[3] = 1.0f; } -bool WebGLRenderingContext::simulateVertexAttrib0(long numVertex) +bool WebGLRenderingContext::simulateVertexAttrib0(GC3Dsizei numVertex) { const VertexAttribState& state = m_vertexAttribState[0]; if (state.enabled || !m_currentProgram || !m_currentProgram->object() || !m_currentProgram->isUsingVertexAttrib0()) return false; m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_vertexAttrib0Buffer->object()); - long bufferDataSize = (numVertex + 1) * 4 * sizeof(float); + GC3Dsizeiptr bufferDataSize = (numVertex + 1) * 4 * sizeof(GC3Dfloat); if (bufferDataSize > m_vertexAttrib0BufferSize || state.value[0] != m_vertexAttrib0BufferValue[0] || state.value[1] != m_vertexAttrib0BufferValue[1] || state.value[2] != m_vertexAttrib0BufferValue[2] || state.value[3] != m_vertexAttrib0BufferValue[3]) { - OwnArrayPtr<float> bufferData(new float[(numVertex + 1) * 4]); - for (long ii = 0; ii < numVertex + 1; ++ii) { + OwnArrayPtr<GC3Dfloat> bufferData(new GC3Dfloat[(numVertex + 1) * 4]); + for (GC3Dsizei ii = 0; ii < numVertex + 1; ++ii) { bufferData[ii * 4] = state.value[0]; bufferData[ii * 4 + 1] = state.value[1]; bufferData[ii * 4 + 2] = state.value[2]; @@ -4348,7 +4336,7 @@ bool WebGLRenderingContext::simulateVertexAttrib0(long numVertex) m_vertexAttrib0BufferValue[2] = state.value[2]; m_vertexAttrib0BufferValue[3] = state.value[3]; } - m_context->vertexAttribPointer(0, 4, GraphicsContext3D::FLOAT, false, 0, 0); + m_context->vertexAttribPointer(0, 4, GraphicsContext3D::FLOAT, 0, 0, 0); return true; } diff --git a/Source/WebCore/html/canvas/WebGLRenderingContext.h b/Source/WebCore/html/canvas/WebGLRenderingContext.h index c40847f..d9b738c 100644 --- a/Source/WebCore/html/canvas/WebGLRenderingContext.h +++ b/Source/WebCore/html/canvas/WebGLRenderingContext.h @@ -68,47 +68,47 @@ public: virtual bool isAccelerated() const { return true; } virtual bool paintsIntoCanvasBuffer() const; - void activeTexture(unsigned long texture, ExceptionCode& ec); + void activeTexture(GC3Denum texture, ExceptionCode& ec); void attachShader(WebGLProgram*, WebGLShader*, ExceptionCode& ec); - void bindAttribLocation(WebGLProgram*, unsigned long index, const String& name, ExceptionCode& ec); - void bindBuffer(unsigned long target, WebGLBuffer*, ExceptionCode& ec); - void bindFramebuffer(unsigned long target, WebGLFramebuffer*, ExceptionCode& ec); - void bindRenderbuffer(unsigned long target, WebGLRenderbuffer*, ExceptionCode& ec); - void bindTexture(unsigned long target, WebGLTexture*, ExceptionCode& ec); - void blendColor(float red, float green, float blue, float alpha); - void blendEquation(unsigned long mode); - void blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha); - void blendFunc(unsigned long sfactor, unsigned long dfactor); - void blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha); - - void bufferData(unsigned long target, int size, unsigned long usage, ExceptionCode&); - void bufferData(unsigned long target, ArrayBuffer* data, unsigned long usage, ExceptionCode&); - void bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage, ExceptionCode&); - void bufferSubData(unsigned long target, long offset, ArrayBuffer* data, ExceptionCode&); - void bufferSubData(unsigned long target, long offset, ArrayBufferView* data, ExceptionCode&); - - unsigned long checkFramebufferStatus(unsigned long target); - void clear(unsigned long mask); - void clearColor(float red, float green, float blue, float alpha); - void clearDepth(float); - void clearStencil(long); - void colorMask(bool red, bool green, bool blue, bool alpha); + void bindAttribLocation(WebGLProgram*, GC3Duint index, const String& name, ExceptionCode& ec); + void bindBuffer(GC3Denum target, WebGLBuffer*, ExceptionCode& ec); + void bindFramebuffer(GC3Denum target, WebGLFramebuffer*, ExceptionCode& ec); + void bindRenderbuffer(GC3Denum target, WebGLRenderbuffer*, ExceptionCode& ec); + void bindTexture(GC3Denum target, WebGLTexture*, ExceptionCode& ec); + void blendColor(GC3Dfloat red, GC3Dfloat green, GC3Dfloat blue, GC3Dfloat alpha); + void blendEquation(GC3Denum mode); + void blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha); + void blendFunc(GC3Denum sfactor, GC3Denum dfactor); + void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha); + + void bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage, ExceptionCode&); + void bufferData(GC3Denum target, ArrayBuffer* data, GC3Denum usage, ExceptionCode&); + void bufferData(GC3Denum target, ArrayBufferView* data, GC3Denum usage, ExceptionCode&); + void bufferSubData(GC3Denum target, GC3Dintptr offset, ArrayBuffer* data, ExceptionCode&); + void bufferSubData(GC3Denum target, GC3Dintptr offset, ArrayBufferView* data, ExceptionCode&); + + GC3Denum checkFramebufferStatus(GC3Denum target); + void clear(GC3Dbitfield mask); + void clearColor(GC3Dfloat red, GC3Dfloat green, GC3Dfloat blue, GC3Dfloat alpha); + void clearDepth(GC3Dfloat); + void clearStencil(GC3Dint); + void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha); void compileShader(WebGLShader*, ExceptionCode& ec); - // void compressedTexImage2D(unsigned long target, long level, unsigned long internalformat, unsigned long width, unsigned long height, long border, unsigned long imageSize, const void* data); - // void compressedTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, unsigned long width, unsigned long height, unsigned long format, unsigned long imageSize, const void* data); + // void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data); + // void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data); - void copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, long width, long height, long border); - void copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, long width, long height); + void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border); + void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height); PassRefPtr<WebGLBuffer> createBuffer(); PassRefPtr<WebGLFramebuffer> createFramebuffer(); PassRefPtr<WebGLProgram> createProgram(); PassRefPtr<WebGLRenderbuffer> createRenderbuffer(); - PassRefPtr<WebGLShader> createShader(unsigned long type, ExceptionCode&); + PassRefPtr<WebGLShader> createShader(GC3Denum type, ExceptionCode&); PassRefPtr<WebGLTexture> createTexture(); - void cullFace(unsigned long mode); + void cullFace(GC3Denum mode); void deleteBuffer(WebGLBuffer*); void deleteFramebuffer(WebGLFramebuffer*); @@ -117,173 +117,155 @@ public: void deleteShader(WebGLShader*); void deleteTexture(WebGLTexture*); - void depthFunc(unsigned long); - void depthMask(bool); - void depthRange(float zNear, float zFar); + void depthFunc(GC3Denum); + void depthMask(GC3Dboolean); + void depthRange(GC3Dfloat zNear, GC3Dfloat zFar); void detachShader(WebGLProgram*, WebGLShader*, ExceptionCode&); - void disable(unsigned long cap); - void disableVertexAttribArray(unsigned long index, ExceptionCode&); - void drawArrays(unsigned long mode, long first, long count, ExceptionCode&); - void drawElements(unsigned long mode, long count, unsigned long type, long offset, ExceptionCode&); + void disable(GC3Denum cap); + void disableVertexAttribArray(GC3Duint index, ExceptionCode&); + void drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count, ExceptionCode&); + void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, ExceptionCode&); - void enable(unsigned long cap); - void enableVertexAttribArray(unsigned long index, ExceptionCode&); + void enable(GC3Denum cap); + void enableVertexAttribArray(GC3Duint index, ExceptionCode&); void finish(); void flush(); - void framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, WebGLRenderbuffer*, ExceptionCode& ec); - void framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, WebGLTexture*, long level, ExceptionCode& ec); - void frontFace(unsigned long mode); - void generateMipmap(unsigned long target); - - PassRefPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, unsigned long index, ExceptionCode&); - PassRefPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, unsigned long index, ExceptionCode&); + void framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, WebGLRenderbuffer*, ExceptionCode& ec); + void framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, WebGLTexture*, GC3Dint level, ExceptionCode& ec); + void frontFace(GC3Denum mode); + void generateMipmap(GC3Denum target); + PassRefPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GC3Duint index, ExceptionCode&); + PassRefPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GC3Duint index, ExceptionCode&); bool getAttachedShaders(WebGLProgram*, Vector<WebGLShader*>&, ExceptionCode&); - - int getAttribLocation(WebGLProgram*, const String& name); - - WebGLGetInfo getBufferParameter(unsigned long target, unsigned long pname, ExceptionCode&); - + GC3Dint getAttribLocation(WebGLProgram*, const String& name); + WebGLGetInfo getBufferParameter(GC3Denum target, GC3Denum pname, ExceptionCode&); PassRefPtr<WebGLContextAttributes> getContextAttributes(); - - unsigned long getError(); - + GC3Denum getError(); WebGLExtension* getExtension(const String& name); - - WebGLGetInfo getFramebufferAttachmentParameter(unsigned long target, unsigned long attachment, unsigned long pname, ExceptionCode&); - - WebGLGetInfo getParameter(unsigned long pname, ExceptionCode&); - - WebGLGetInfo getProgramParameter(WebGLProgram*, unsigned long pname, ExceptionCode&); - + WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode&); + WebGLGetInfo getParameter(GC3Denum pname, ExceptionCode&); + WebGLGetInfo getProgramParameter(WebGLProgram*, GC3Denum pname, ExceptionCode&); String getProgramInfoLog(WebGLProgram*, ExceptionCode& ec); - - WebGLGetInfo getRenderbufferParameter(unsigned long target, unsigned long pname, ExceptionCode&); - - WebGLGetInfo getShaderParameter(WebGLShader*, unsigned long pname, ExceptionCode& ec); - + WebGLGetInfo getRenderbufferParameter(GC3Denum target, GC3Denum pname, ExceptionCode&); + WebGLGetInfo getShaderParameter(WebGLShader*, GC3Denum pname, ExceptionCode& ec); String getShaderInfoLog(WebGLShader*, ExceptionCode& ec); // TBD - // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); + // void glGetShaderPrecisionFormat (GC3Denum shadertype, GC3Denum precisiontype, GC3Dint* range, GC3Dint* precision); String getShaderSource(WebGLShader*, ExceptionCode&); - Vector<String> getSupportedExtensions(); - - WebGLGetInfo getTexParameter(unsigned long target, unsigned long pname, ExceptionCode&); - + WebGLGetInfo getTexParameter(GC3Denum target, GC3Denum pname, ExceptionCode&); WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*, ExceptionCode&); - PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const String&, ExceptionCode&); + WebGLGetInfo getVertexAttrib(GC3Duint index, GC3Denum pname, ExceptionCode&); + GC3Dsizeiptr getVertexAttribOffset(GC3Duint index, GC3Denum pname); - WebGLGetInfo getVertexAttrib(unsigned long index, unsigned long pname, ExceptionCode&); - - long getVertexAttribOffset(unsigned long index, unsigned long pname); - - void hint(unsigned long target, unsigned long mode); - bool isBuffer(WebGLBuffer*); + void hint(GC3Denum target, GC3Denum mode); + GC3Dboolean isBuffer(WebGLBuffer*); bool isContextLost(); - bool isEnabled(unsigned long cap); - bool isFramebuffer(WebGLFramebuffer*); - bool isProgram(WebGLProgram*); - bool isRenderbuffer(WebGLRenderbuffer*); - bool isShader(WebGLShader*); - bool isTexture(WebGLTexture*); - void lineWidth(float); + GC3Dboolean isEnabled(GC3Denum cap); + GC3Dboolean isFramebuffer(WebGLFramebuffer*); + GC3Dboolean isProgram(WebGLProgram*); + GC3Dboolean isRenderbuffer(WebGLRenderbuffer*); + GC3Dboolean isShader(WebGLShader*); + GC3Dboolean isTexture(WebGLTexture*); + + void lineWidth(GC3Dfloat); void linkProgram(WebGLProgram*, ExceptionCode&); - void pixelStorei(unsigned long pname, long param); - void polygonOffset(float factor, float units); - void readPixels(long x, long y, long width, long height, unsigned long format, unsigned long type, ArrayBufferView* pixels, ExceptionCode&); + void pixelStorei(GC3Denum pname, GC3Dint param); + void polygonOffset(GC3Dfloat factor, GC3Dfloat units); + void readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode&); void releaseShaderCompiler(); - void renderbufferStorage(unsigned long target, unsigned long internalformat, long width, long height); - void sampleCoverage(float value, bool invert); - void scissor(long x, long y, long width, long height); + void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height); + void sampleCoverage(GC3Dfloat value, GC3Dboolean invert); + void scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height); void shaderSource(WebGLShader*, const String&, ExceptionCode&); - void stencilFunc(unsigned long func, long ref, unsigned long mask); - void stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask); - void stencilMask(unsigned long); - void stencilMaskSeparate(unsigned long face, unsigned long mask); - void stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass); - void stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass); - - void texImage2D(unsigned target, unsigned level, unsigned internalformat, - int width, int height, unsigned border, - unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode&); - void texImage2D(unsigned target, unsigned level, unsigned internalformat, - unsigned format, unsigned type, ImageData* pixels, ExceptionCode&); - void texImage2D(unsigned target, unsigned level, unsigned internalformat, - unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode&); - void texImage2D(unsigned target, unsigned level, unsigned internalformat, - unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode&); - void texImage2D(unsigned target, unsigned level, unsigned internalformat, - unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode&); - - void texParameterf(unsigned target, unsigned pname, float param); - void texParameteri(unsigned target, unsigned pname, int param); - - void texSubImage2D(unsigned target, unsigned level, int xoffset, int yoffset, - int width, int height, - unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode&); - void texSubImage2D(unsigned target, unsigned level, int xoffset, int yoffset, - unsigned format, unsigned type, ImageData* pixels, ExceptionCode&); - void texSubImage2D(unsigned target, unsigned level, int xoffset, int yoffset, - unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode&); - void texSubImage2D(unsigned target, unsigned level, int xoffset, int yoffset, - unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode&); - void texSubImage2D(unsigned target, unsigned level, int xoffset, int yoffset, - unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode&); - - void uniform1f(const WebGLUniformLocation* location, float x, ExceptionCode&); + void stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask); + void stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask); + void stencilMask(GC3Duint); + void stencilMaskSeparate(GC3Denum face, GC3Duint mask); + void stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass); + void stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass); + + void texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Dsizei width, GC3Dsizei height, GC3Dint border, + GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode&); + void texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionCode&); + void texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionCode&); + void texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionCode&); + void texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionCode&); + + void texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat param); + void texParameteri(GC3Denum target, GC3Denum pname, GC3Dint param); + + void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Dsizei width, GC3Dsizei height, + GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode&); + void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionCode&); + void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionCode&); + void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionCode&); + void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionCode&); + + void uniform1f(const WebGLUniformLocation* location, GC3Dfloat x, ExceptionCode&); void uniform1fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&); - void uniform1fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&); - void uniform1i(const WebGLUniformLocation* location, int x, ExceptionCode&); + void uniform1fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode&); + void uniform1i(const WebGLUniformLocation* location, GC3Dint x, 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 uniform1iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode&); + void uniform2f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y, ExceptionCode&); void uniform2fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&); - void uniform2fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&); - void uniform2i(const WebGLUniformLocation* location, int x, int y, ExceptionCode&); + void uniform2fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode&); + void uniform2i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y, 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 uniform2iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode&); + void uniform3f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, ExceptionCode&); void uniform3fv(const WebGLUniformLocation* location, Float32Array* 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 uniform3fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode&); + void uniform3i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y, GC3Dint z, 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 uniform3iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode&); + void uniform4f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w, ExceptionCode&); void uniform4fv(const WebGLUniformLocation* location, Float32Array* 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 uniform4fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode&); + void uniform4i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w, 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, Float32Array* value, ExceptionCode&); - void uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&); - void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, Float32Array* value, ExceptionCode&); - void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&); - void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, Float32Array* value, ExceptionCode&); - void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&); + void uniform4iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode&); + void uniformMatrix2fv(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* value, ExceptionCode&); + void uniformMatrix2fv(const WebGLUniformLocation* location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size, ExceptionCode&); + void uniformMatrix3fv(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* value, ExceptionCode&); + void uniformMatrix3fv(const WebGLUniformLocation* location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size, ExceptionCode&); + void uniformMatrix4fv(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* value, ExceptionCode&); + void uniformMatrix4fv(const WebGLUniformLocation* location, GC3Dboolean transpose, GC3Dfloat* value, GC3Dsizei size, ExceptionCode&); void useProgram(WebGLProgram*, ExceptionCode&); void validateProgram(WebGLProgram*, ExceptionCode&); - void vertexAttrib1f(unsigned long index, float x); - void vertexAttrib1fv(unsigned long index, Float32Array* values); - void vertexAttrib1fv(unsigned long index, float* values, int size); - void vertexAttrib2f(unsigned long index, float x, float y); - void vertexAttrib2fv(unsigned long index, Float32Array* values); - void vertexAttrib2fv(unsigned long index, float* values, int size); - void vertexAttrib3f(unsigned long index, float x, float y, float z); - void vertexAttrib3fv(unsigned long index, Float32Array* values); - void vertexAttrib3fv(unsigned long index, float* values, int size); - void vertexAttrib4f(unsigned long index, float x, float y, float z, float w); - void vertexAttrib4fv(unsigned long index, Float32Array* values); - void vertexAttrib4fv(unsigned long index, float* values, int size); - void vertexAttribPointer(unsigned long index, long size, unsigned long type, bool normalized, - long stride, long offset, ExceptionCode&); - - void viewport(long x, long y, long width, long height); + void vertexAttrib1f(GC3Duint index, GC3Dfloat x); + void vertexAttrib1fv(GC3Duint index, Float32Array* values); + void vertexAttrib1fv(GC3Duint index, GC3Dfloat* values, GC3Dsizei size); + void vertexAttrib2f(GC3Duint index, GC3Dfloat x, GC3Dfloat y); + void vertexAttrib2fv(GC3Duint index, Float32Array* values); + void vertexAttrib2fv(GC3Duint index, GC3Dfloat* values, GC3Dsizei size); + void vertexAttrib3f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z); + void vertexAttrib3fv(GC3Duint index, Float32Array* values); + void vertexAttrib3fv(GC3Duint index, GC3Dfloat* values, GC3Dsizei size); + void vertexAttrib4f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w); + void vertexAttrib4fv(GC3Duint index, Float32Array* values); + void vertexAttrib4fv(GC3Duint index, GC3Dfloat* values, GC3Dsizei size); + void vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, + GC3Dsizei stride, GC3Dintptr offset, ExceptionCode&); + + void viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height); void forceLostContext(); void onLostContext(); @@ -338,18 +320,18 @@ public: // Helper to return the size in bytes of OpenGL data types // like GL_FLOAT, GL_INT, etc. - int sizeInBytes(int type); + unsigned int sizeInBytes(GC3Denum type); // Basic validation of count and offset against number of elements in element array buffer - bool validateElementArraySize(unsigned long count, unsigned long type, long offset); + bool validateElementArraySize(GC3Dsizei count, GC3Denum type, GC3Dintptr offset); // Conservative but quick index validation - bool validateIndexArrayConservative(unsigned long type, long& numElementsRequired); + bool validateIndexArrayConservative(GC3Denum type, int& numElementsRequired); // Precise but slow index validation -- only done if conservative checks fail - bool validateIndexArrayPrecise(unsigned long count, unsigned long type, long offset, long& numElementsRequired); + bool validateIndexArrayPrecise(GC3Dsizei count, GC3Denum type, GC3Dintptr offset, int& numElementsRequired); // If numElements <= 0, we only check if each enabled vertex attribute is bound to a buffer. - bool validateRenderingState(long numElements); + bool validateRenderingState(int numElements); bool validateWebGLObject(WebGLObject* object); @@ -401,21 +383,21 @@ public: bool enabled; RefPtr<WebGLBuffer> bufferBinding; - long bytesPerElement; - long size; - unsigned long type; + GC3Dsizei bytesPerElement; + GC3Dint size; + GC3Denum type; bool normalized; - long stride; - long originalStride; - long offset; - float value[4]; + GC3Dsizei stride; + GC3Dsizei originalStride; + GC3Dintptr offset; + GC3Dfloat value[4]; }; Vector<VertexAttribState> m_vertexAttribState; unsigned m_maxVertexAttribs; RefPtr<WebGLBuffer> m_vertexAttrib0Buffer; long m_vertexAttrib0BufferSize; - float m_vertexAttrib0BufferValue[4]; + GC3Dfloat m_vertexAttrib0BufferValue[4]; RefPtr<WebGLProgram> m_currentProgram; RefPtr<WebGLFramebuffer> m_framebufferBinding; @@ -444,23 +426,23 @@ public: }; LRUImageBufferCache m_videoCache; - int m_maxTextureSize; - int m_maxCubeMapTextureSize; - int m_maxTextureLevel; - int m_maxCubeMapTextureLevel; + GC3Dint m_maxTextureSize; + GC3Dint m_maxCubeMapTextureSize; + GC3Dint m_maxTextureLevel; + GC3Dint m_maxCubeMapTextureLevel; - int m_packAlignment; - int m_unpackAlignment; + GC3Dint m_packAlignment; + GC3Dint m_unpackAlignment; bool m_unpackFlipY; bool m_unpackPremultiplyAlpha; - unsigned long m_unpackColorspaceConversion; + GC3Denum m_unpackColorspaceConversion; bool m_contextLost; GraphicsContext3D::Attributes m_attributes; long m_stencilBits; - unsigned long m_stencilMask, m_stencilMaskBack; - long m_stencilFuncRef, m_stencilFuncRefBack; // Note that these are the user specified values, not the internal clamped value. - unsigned long m_stencilFuncMask, m_stencilFuncMaskBack; + GC3Duint m_stencilMask, m_stencilMaskBack; + GC3Dint m_stencilFuncRef, m_stencilFuncRefBack; // Note that these are the user specified values, not the internal clamped value. + GC3Duint m_stencilFuncMask, m_stencilFuncMaskBack; bool m_isGLES2Compliant; bool m_isGLES2NPOTStrict; @@ -473,26 +455,26 @@ public: RefPtr<WebKitLoseContext> m_webkitLoseContext; // Helpers for getParameter and others - WebGLGetInfo getBooleanParameter(unsigned long pname); - WebGLGetInfo getBooleanArrayParameter(unsigned long pname); - WebGLGetInfo getFloatParameter(unsigned long pname); - WebGLGetInfo getIntParameter(unsigned long pname); - WebGLGetInfo getLongParameter(unsigned long pname); - WebGLGetInfo getUnsignedLongParameter(unsigned long pname); - WebGLGetInfo getWebGLFloatArrayParameter(unsigned long pname); - WebGLGetInfo getWebGLIntArrayParameter(unsigned long pname); - - void texImage2DBase(unsigned target, unsigned level, unsigned internalformat, - int width, int height, unsigned border, - unsigned format, unsigned type, void* pixels, ExceptionCode&); - void texImage2DImpl(unsigned target, unsigned level, unsigned internalformat, - unsigned format, unsigned type, Image* image, + WebGLGetInfo getBooleanParameter(GC3Denum pname); + WebGLGetInfo getBooleanArrayParameter(GC3Denum pname); + WebGLGetInfo getFloatParameter(GC3Denum pname); + WebGLGetInfo getIntParameter(GC3Denum pname); + WebGLGetInfo getLongParameter(GC3Denum pname); + WebGLGetInfo getUnsignedLongParameter(GC3Denum pname); + WebGLGetInfo getWebGLFloatArrayParameter(GC3Denum pname); + WebGLGetInfo getWebGLIntArrayParameter(GC3Denum pname); + + void texImage2DBase(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Dsizei width, GC3Dsizei height, GC3Dint border, + GC3Denum format, GC3Denum type, void* pixels, ExceptionCode&); + void texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, + GC3Denum format, GC3Denum type, Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode&); - void texSubImage2DBase(unsigned target, unsigned level, int xoffset, int yoffset, - int width, int height, - unsigned format, unsigned type, void* pixels, ExceptionCode&); - void texSubImage2DImpl(unsigned target, unsigned level, int xoffset, int yoffset, - unsigned format, unsigned type, + void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Dsizei width, GC3Dsizei height, + GC3Denum format, GC3Denum type, void* pixels, ExceptionCode&); + void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, + GC3Denum format, GC3Denum type, Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode&); void handleNPOTTextures(bool prepareToDraw); @@ -502,11 +484,11 @@ public: // Helper function for copyTex{Sub}Image, check whether the internalformat // and the color buffer format of the current bound framebuffer combination // is valid. - bool isTexInternalFormatColorBufferCombinationValid(unsigned long texInternalFormat, - unsigned long colorBufferFormat); + bool isTexInternalFormatColorBufferCombinationValid(GC3Denum texInternalFormat, + GC3Denum colorBufferFormat); // Helper function to get the bound framebuffer's color buffer format. - unsigned long getBoundFramebufferColorFormat(); + GC3Denum getBoundFramebufferColorFormat(); // Helper function to get the bound framebuffer's width. int getBoundFramebufferWidth(); @@ -516,7 +498,7 @@ public: // Helper function to check if size is non-negative. // Generate GL error and return false for negative inputs; otherwise, return true. - bool validateSize(long x, long y); + bool validateSize(GC3Dint x, GC3Dint y); // Helper function to check if all characters in the string belong to the // ASCII subset as defined in GLSL ES 1.0 spec section 3.1. @@ -525,41 +507,41 @@ public: // Helper function to check target and texture bound to the target. // Generate GL errors and return 0 if target is invalid or texture bound is // null. Otherwise, return the texture bound to the target. - WebGLTexture* validateTextureBinding(unsigned long target, bool useSixEnumsForCubeMap); + WebGLTexture* validateTextureBinding(GC3Denum target, bool useSixEnumsForCubeMap); // Helper function to check input format/type for functions {copy}Tex{Sub}Image. // Generates GL error and returns false if parameters are invalid. - bool validateTexFuncFormatAndType(unsigned long format, unsigned long type); + bool validateTexFuncFormatAndType(GC3Denum format, GC3Denum type); // Helper function to check input level for functions {copy}Tex{Sub}Image. // Generates GL error and returns false if level is invalid. - bool validateTexFuncLevel(unsigned long target, long level); + bool validateTexFuncLevel(GC3Denum target, GC3Dint level); // Helper function to check input parameters for functions {copy}Tex{Sub}Image. // Generates GL error and returns false if parameters are invalid. - bool validateTexFuncParameters(unsigned long target, long level, - unsigned long internalformat, - long width, long height, long border, - unsigned long format, unsigned long type); + bool validateTexFuncParameters(GC3Denum target, GC3Dint level, + GC3Denum internalformat, + GC3Dsizei width, GC3Dsizei height, GC3Dint border, + GC3Denum format, GC3Denum type); // Helper function to validate that the given ArrayBufferView // is of the correct type and contains enough data for the texImage call. // Generates GL error and returns false if parameters are invalid. - bool validateTexFuncData(long width, long height, - unsigned long format, unsigned long type, + bool validateTexFuncData(GC3Dsizei width, GC3Dsizei height, + GC3Denum format, GC3Denum type, ArrayBufferView* pixels); // Helper function to validate mode for draw{Arrays/Elements}. - bool validateDrawMode(unsigned long); + bool validateDrawMode(GC3Denum); // Helper function to validate if front/back stencilMask and stencilFunc settings are the same. bool validateStencilSettings(); // Helper function to validate stencil func. - bool validateStencilFunc(unsigned long); + bool validateStencilFunc(GC3Denum); // Helper function for texParameterf and texParameteri. - void texParameter(unsigned long target, unsigned long pname, float parami, int paramf, bool isFloat); + void texParameter(GC3Denum target, GC3Denum pname, GC3Dfloat parami, GC3Dint paramf, bool isFloat); // Helper function to print warnings to console. Currently // used only to warn about use of obsolete functions. @@ -567,36 +549,36 @@ public: // Helper function to validate input parameters for framebuffer functions. // Generate GL error if parameters are illegal. - bool validateFramebufferFuncParameters(unsigned long target, unsigned long attachment); + bool validateFramebufferFuncParameters(GC3Denum target, GC3Denum attachment); // Helper function to validate blend equation mode. - bool validateBlendEquation(unsigned long); + bool validateBlendEquation(GC3Denum); // Helper function to validate blend func factors. - bool validateBlendFuncFactors(unsigned long src, unsigned long dst); + bool validateBlendFuncFactors(GC3Denum src, GC3Denum dst); // Helper function to validate a GL capability. - bool validateCapability(unsigned long); + bool validateCapability(GC3Denum); // Helper function to validate input parameters for uniform functions. - bool validateUniformParameters(const WebGLUniformLocation* location, Float32Array* v, int mod); - bool validateUniformParameters(const WebGLUniformLocation* location, Int32Array* v, int mod); - bool validateUniformParameters(const WebGLUniformLocation* location, void* v, int size, int mod); - bool validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, Float32Array* v, int mod); - bool validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, void* v, int size, int mod); + bool validateUniformParameters(const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei mod); + bool validateUniformParameters(const WebGLUniformLocation* location, Int32Array* v, GC3Dsizei mod); + bool validateUniformParameters(const WebGLUniformLocation* location, void* v, GC3Dsizei size, GC3Dsizei mod); + bool validateUniformMatrixParameters(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, GC3Dsizei mod); + bool validateUniformMatrixParameters(const WebGLUniformLocation* location, GC3Dboolean transpose, void* v, GC3Dsizei size, GC3Dsizei mod); // Helper function to validate parameters for bufferData. // Return the current bound buffer to target, or 0 if parameters are invalid. - WebGLBuffer* validateBufferDataParameters(unsigned long target, unsigned long usage); + WebGLBuffer* validateBufferDataParameters(GC3Denum target, GC3Denum usage); // Helper functions for vertexAttribNf{v}. - void vertexAttribfImpl(unsigned long index, int expectedSize, float v0, float v1, float v2, float v3); - void vertexAttribfvImpl(unsigned long index, Float32Array* v, int expectedSize); - void vertexAttribfvImpl(unsigned long index, float* v, int size, int expectedSize); + void vertexAttribfImpl(GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3); + void vertexAttribfvImpl(GC3Duint index, Float32Array* v, GC3Dsizei expectedSize); + void vertexAttribfvImpl(GC3Duint index, GC3Dfloat* v, GC3Dsizei size, GC3Dsizei expectedSize); // Helpers for simulating vertexAttrib0 void initVertexAttrib0(); - bool simulateVertexAttrib0(long numVertex); + bool simulateVertexAttrib0(GC3Dsizei numVertex); void restoreStatesAfterVertexAttrib0Simulation(); friend class WebGLStateRestorer; diff --git a/Source/WebCore/html/canvas/WebGLShader.cpp b/Source/WebCore/html/canvas/WebGLShader.cpp index 4f8bf68..a07023f 100644 --- a/Source/WebCore/html/canvas/WebGLShader.cpp +++ b/Source/WebCore/html/canvas/WebGLShader.cpp @@ -33,12 +33,12 @@ namespace WebCore { -PassRefPtr<WebGLShader> WebGLShader::create(WebGLRenderingContext* ctx, GraphicsContext3D::WebGLEnumType type) +PassRefPtr<WebGLShader> WebGLShader::create(WebGLRenderingContext* ctx, GC3Denum type) { return adoptRef(new WebGLShader(ctx, type)); } -WebGLShader::WebGLShader(WebGLRenderingContext* ctx, GraphicsContext3D::WebGLEnumType type) +WebGLShader::WebGLShader(WebGLRenderingContext* ctx, GC3Denum type) : WebGLObject(ctx) , m_type(type) { diff --git a/Source/WebCore/html/canvas/WebGLShader.h b/Source/WebCore/html/canvas/WebGLShader.h index c0c41df..5deaf20 100644 --- a/Source/WebCore/html/canvas/WebGLShader.h +++ b/Source/WebCore/html/canvas/WebGLShader.h @@ -37,18 +37,18 @@ class WebGLShader : public WebGLObject { public: virtual ~WebGLShader() { deleteObject(); } - static PassRefPtr<WebGLShader> create(WebGLRenderingContext*, GraphicsContext3D::WebGLEnumType); + static PassRefPtr<WebGLShader> create(WebGLRenderingContext*, GC3Denum); - GraphicsContext3D::WebGLEnumType getType() const { return m_type; } + GC3Denum getType() const { return m_type; } private: - WebGLShader(WebGLRenderingContext*, GraphicsContext3D::WebGLEnumType); + WebGLShader(WebGLRenderingContext*, GC3Denum); virtual void deleteObjectImpl(Platform3DObject); virtual bool isShader() const { return true; } - GraphicsContext3D::WebGLEnumType m_type; + GC3Denum m_type; }; } // namespace WebCore diff --git a/Source/WebCore/html/canvas/WebGLTexture.cpp b/Source/WebCore/html/canvas/WebGLTexture.cpp index 2982e51..a57500f 100644 --- a/Source/WebCore/html/canvas/WebGLTexture.cpp +++ b/Source/WebCore/html/canvas/WebGLTexture.cpp @@ -53,7 +53,7 @@ WebGLTexture::WebGLTexture(WebGLRenderingContext* ctx) setObject(context()->graphicsContext3D()->createTexture()); } -void WebGLTexture::setTarget(unsigned long target, int maxLevel) +void WebGLTexture::setTarget(GC3Denum target, GC3Dint maxLevel) { if (!object()) return; @@ -75,7 +75,7 @@ void WebGLTexture::setTarget(unsigned long target, int maxLevel) } } -void WebGLTexture::setParameteri(unsigned long pname, int param) +void WebGLTexture::setParameteri(GC3Denum pname, GC3Dint param) { if (!object() || !m_target) return; @@ -124,15 +124,15 @@ void WebGLTexture::setParameteri(unsigned long pname, int param) update(); } -void WebGLTexture::setParameterf(unsigned long pname, float param) +void WebGLTexture::setParameterf(GC3Denum pname, GC3Dfloat param) { if (!object() || !m_target) return; - int iparam = static_cast<int>(param); + GC3Dint iparam = static_cast<GC3Dint>(param); setParameteri(pname, iparam); } -void WebGLTexture::setLevelInfo(unsigned long target, int level, unsigned long internalFormat, int width, int height, unsigned long type) +void WebGLTexture::setLevelInfo(GC3Denum target, GC3Dint level, GC3Denum internalFormat, GC3Dsizei width, GC3Dsizei height, GC3Denum type) { if (!object() || !m_target) return; @@ -154,10 +154,10 @@ void WebGLTexture::generateMipmapLevelInfo() if (!m_isComplete) { for (size_t ii = 0; ii < m_info.size(); ++ii) { const LevelInfo& info0 = m_info[ii][0]; - int width = info0.width; - int height = info0.height; - int levelCount = computeLevelCount(width, height); - for (int level = 1; level < levelCount; ++level) { + GC3Dsizei width = info0.width; + GC3Dsizei height = info0.height; + GC3Dint levelCount = computeLevelCount(width, height); + for (GC3Dint level = 1; level < levelCount; ++level) { width = std::max(1, width >> 1); height = std::max(1, height >> 1); LevelInfo& info = m_info[ii][level]; @@ -169,7 +169,7 @@ void WebGLTexture::generateMipmapLevelInfo() m_needToUseBlackTexture = false; } -unsigned long WebGLTexture::getInternalFormat(unsigned long target, int level) const +GC3Denum WebGLTexture::getInternalFormat(GC3Denum target, GC3Dint level) const { const LevelInfo* info = getLevelInfo(target, level); if (!info) @@ -177,7 +177,7 @@ unsigned long WebGLTexture::getInternalFormat(unsigned long target, int level) c return info->internalFormat; } -unsigned long WebGLTexture::getType(unsigned long target, int level) const +GC3Denum WebGLTexture::getType(GC3Denum target, GC3Dint level) const { const LevelInfo* info = getLevelInfo(target, level); if (!info) @@ -185,7 +185,7 @@ unsigned long WebGLTexture::getType(unsigned long target, int level) const return info->type; } -int WebGLTexture::getWidth(unsigned long target, int level) const +GC3Dsizei WebGLTexture::getWidth(GC3Denum target, GC3Dint level) const { const LevelInfo* info = getLevelInfo(target, level); if (!info) @@ -193,7 +193,7 @@ int WebGLTexture::getWidth(unsigned long target, int level) const return info->width; } -int WebGLTexture::getHeight(unsigned long target, int level) const +GC3Dsizei WebGLTexture::getHeight(GC3Denum target, GC3Dint level) const { const LevelInfo* info = getLevelInfo(target, level); if (!info) @@ -201,8 +201,9 @@ int WebGLTexture::getHeight(unsigned long target, int level) const return info->height; } -bool WebGLTexture::isNPOT(unsigned width, unsigned height) +bool WebGLTexture::isNPOT(GC3Dsizei width, GC3Dsizei height) { + ASSERT(width >= 0 && height >= 0); if (!width || !height) return false; if ((width & (width - 1)) || (height & (height - 1))) @@ -229,7 +230,7 @@ void WebGLTexture::deleteObjectImpl(Platform3DObject object) context()->graphicsContext3D()->deleteTexture(object); } -int WebGLTexture::mapTargetToIndex(unsigned long target) const +int WebGLTexture::mapTargetToIndex(GC3Denum target) const { if (m_target == GraphicsContext3D::TEXTURE_2D) { if (target == GraphicsContext3D::TEXTURE_2D) @@ -268,17 +269,17 @@ bool WebGLTexture::canGenerateMipmaps() return true; } -int WebGLTexture::computeLevelCount(int width, int height) +GC3Dint WebGLTexture::computeLevelCount(GC3Dsizei width, GC3Dsizei height) { // return 1 + log2Floor(std::max(width, height)); - int n = std::max(width, height); + GC3Dsizei n = std::max(width, height); if (n <= 0) return 0; - int log = 0; - int value = n; + GC3Dint log = 0; + GC3Dsizei value = n; for (int ii = 4; ii >= 0; --ii) { int shift = (1 << ii); - int x = (value >> shift); + GC3Dsizei x = (value >> shift); if (x) { value = x; log += shift; @@ -299,7 +300,7 @@ void WebGLTexture::update() } m_isComplete = true; const LevelInfo& first = m_info[0][0]; - int levelCount = computeLevelCount(first.width, first.height); + GC3Dint levelCount = computeLevelCount(first.width, first.height); if (levelCount < 1) m_isComplete = false; else { @@ -311,9 +312,9 @@ void WebGLTexture::update() m_isComplete = false; break; } - int width = info0.width; - int height = info0.height; - for (int level = 1; level < levelCount; ++level) { + GC3Dsizei width = info0.width; + GC3Dsizei height = info0.height; + for (GC3Dint level = 1; level < levelCount; ++level) { width = std::max(1, width >> 1); height = std::max(1, height >> 1); const LevelInfo& info = m_info[ii][level]; @@ -338,14 +339,14 @@ void WebGLTexture::update() m_needToUseBlackTexture = true; } -const WebGLTexture::LevelInfo* WebGLTexture::getLevelInfo(unsigned long target, int level) const +const WebGLTexture::LevelInfo* WebGLTexture::getLevelInfo(GC3Denum target, GC3Dint level) const { if (!object() || !m_target) return 0; int targetIndex = mapTargetToIndex(target); if (targetIndex < 0 || targetIndex >= static_cast<int>(m_info.size())) return 0; - if (level < 0 || level >= static_cast<int>(m_info[targetIndex].size())) + if (level < 0 || level >= static_cast<GC3Dint>(m_info[targetIndex].size())) return 0; return &(m_info[targetIndex][level]); } diff --git a/Source/WebCore/html/canvas/WebGLTexture.h b/Source/WebCore/html/canvas/WebGLTexture.h index 419c94d..27eb8ee 100644 --- a/Source/WebCore/html/canvas/WebGLTexture.h +++ b/Source/WebCore/html/canvas/WebGLTexture.h @@ -40,25 +40,25 @@ public: static PassRefPtr<WebGLTexture> create(WebGLRenderingContext*); - void setTarget(unsigned long target, int maxLevel); - void setParameteri(unsigned long pname, int param); - void setParameterf(unsigned long pname, float param); + void setTarget(GC3Denum target, GC3Dint maxLevel); + void setParameteri(GC3Denum pname, GC3Dint param); + void setParameterf(GC3Denum pname, GC3Dfloat param); int getMinFilter() const { return m_minFilter; } - void setLevelInfo(unsigned long target, int level, unsigned long internalFormat, int width, int height, unsigned long type); + void setLevelInfo(GC3Denum target, GC3Dint level, GC3Denum internalFormat, GC3Dsizei width, GC3Dsizei height, GC3Denum type); bool canGenerateMipmaps(); // Generate all level information. void generateMipmapLevelInfo(); - unsigned long getInternalFormat(unsigned long target, int level) const; - unsigned long getType(unsigned long target, int level) const; - int getWidth(unsigned long target, int level) const; - int getHeight(unsigned long target, int level) const; + GC3Denum getInternalFormat(GC3Denum target, GC3Dint level) const; + GC3Denum getType(GC3Denum target, GC3Dint level) const; + GC3Dsizei getWidth(GC3Denum target, GC3Dint level) const; + GC3Dsizei getHeight(GC3Denum target, GC3Dint level) const; // Whether width/height is NotPowerOfTwo. - static bool isNPOT(unsigned, unsigned); + static bool isNPOT(GC3Dsizei, GC3Dsizei); bool isNPOT() const; // Determine if texture sampling should always return [0, 0, 0, 1] (OpenGL ES 2.0 Sec 3.8.2). @@ -66,7 +66,7 @@ public: bool hasEverBeenBound() const { return object() && m_target; } - static int computeLevelCount(int width, int height); + static GC3Dint computeLevelCount(GC3Dsizei width, GC3Dsizei height); protected: WebGLTexture(WebGLRenderingContext*); @@ -85,7 +85,7 @@ private: { } - void setInfo(unsigned long internalFmt, int w, int h, unsigned long tp) + void setInfo(GC3Denum internalFmt, GC3Dsizei w, GC3Dsizei h, GC3Denum tp) { valid = true; internalFormat = internalFmt; @@ -95,26 +95,26 @@ private: } bool valid; - unsigned long internalFormat; - int width; - int height; - unsigned long type; + GC3Denum internalFormat; + GC3Dsizei width; + GC3Dsizei height; + GC3Denum type; }; virtual bool isTexture() const { return true; } void update(); - int mapTargetToIndex(unsigned long) const; + int mapTargetToIndex(GC3Denum) const; - const LevelInfo* getLevelInfo(unsigned long target, int level) const; + const LevelInfo* getLevelInfo(GC3Denum target, GC3Dint level) const; - unsigned long m_target; + GC3Denum m_target; - int m_minFilter; - int m_magFilter; - int m_wrapS; - int m_wrapT; + GC3Denum m_minFilter; + GC3Denum m_magFilter; + GC3Denum m_wrapS; + GC3Denum m_wrapT; Vector<Vector<LevelInfo> > m_info; diff --git a/Source/WebCore/html/canvas/WebGLUniformLocation.cpp b/Source/WebCore/html/canvas/WebGLUniformLocation.cpp index e67b09a..a8220b0 100644 --- a/Source/WebCore/html/canvas/WebGLUniformLocation.cpp +++ b/Source/WebCore/html/canvas/WebGLUniformLocation.cpp @@ -32,12 +32,12 @@ namespace WebCore { -PassRefPtr<WebGLUniformLocation> WebGLUniformLocation::create(WebGLProgram* program, long location) +PassRefPtr<WebGLUniformLocation> WebGLUniformLocation::create(WebGLProgram* program, GC3Dint location) { return adoptRef(new WebGLUniformLocation(program, location)); } -WebGLUniformLocation::WebGLUniformLocation(WebGLProgram* program, long location) +WebGLUniformLocation::WebGLUniformLocation(WebGLProgram* program, GC3Dint location) : m_program(program) , m_location(location) { @@ -54,7 +54,7 @@ WebGLProgram* WebGLUniformLocation::program() const return m_program.get(); } -long WebGLUniformLocation::location() const +GC3Dint WebGLUniformLocation::location() const { // If the program has been linked again, then this UniformLocation is no // longer valid. diff --git a/Source/WebCore/html/canvas/WebGLUniformLocation.h b/Source/WebCore/html/canvas/WebGLUniformLocation.h index f8ce699..3ef9fa8 100644 --- a/Source/WebCore/html/canvas/WebGLUniformLocation.h +++ b/Source/WebCore/html/canvas/WebGLUniformLocation.h @@ -39,19 +39,19 @@ class WebGLUniformLocation : public RefCounted<WebGLUniformLocation> { public: virtual ~WebGLUniformLocation() { } - static PassRefPtr<WebGLUniformLocation> create(WebGLProgram* program, long location); + static PassRefPtr<WebGLUniformLocation> create(WebGLProgram* program, GC3Dint location); WebGLProgram* program() const; - long location() const; + GC3Dint location() const; protected: - WebGLUniformLocation(WebGLProgram* program, long location); + WebGLUniformLocation(WebGLProgram* program, GC3Dint location); private: RefPtr<WebGLProgram> m_program; - long m_location; - unsigned long m_linkCount; + GC3Dint m_location; + unsigned m_linkCount; }; } // namespace WebCore diff --git a/Source/WebCore/html/shadow/SliderThumbElement.cpp b/Source/WebCore/html/shadow/SliderThumbElement.cpp index d29d257..0402e89 100644 --- a/Source/WebCore/html/shadow/SliderThumbElement.cpp +++ b/Source/WebCore/html/shadow/SliderThumbElement.cpp @@ -37,6 +37,7 @@ #include "Frame.h" #include "MouseEvent.h" #include "RenderSlider.h" +#include "RenderTheme.h" #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) #include "TouchEvent.h" @@ -44,14 +45,58 @@ namespace WebCore { +// FIXME: Find a way to cascade appearance (see the layout method) and get rid of this class. +class RenderSliderThumb : public RenderBlock { +public: + RenderSliderThumb(Node*); + virtual void layout(); +}; + + +RenderSliderThumb::RenderSliderThumb(Node* node) + : RenderBlock(node) +{ +} + +void RenderSliderThumb::layout() +{ + // FIXME: Hard-coding this cascade of appearance is bad, because it's something + // that CSS usually does. We need to find a way to express this in CSS. + RenderStyle* parentStyle = parent()->style(); + if (parentStyle->appearance() == SliderVerticalPart) + style()->setAppearance(SliderThumbVerticalPart); + else if (parentStyle->appearance() == SliderHorizontalPart) + style()->setAppearance(SliderThumbHorizontalPart); + else if (parentStyle->appearance() == MediaSliderPart) + style()->setAppearance(MediaSliderThumbPart); + else if (parentStyle->appearance() == MediaVolumeSliderPart) + style()->setAppearance(MediaVolumeSliderThumbPart); + + if (style()->hasAppearance()) { + // FIXME: This should pass the style, not the renderer, to the theme. + theme()->adjustSliderThumbSize(this); + } + RenderBlock::layout(); +} + +RenderObject* SliderThumbElement::createRenderer(RenderArena* arena, RenderStyle*) +{ + return new (arena) RenderSliderThumb(this); +} + void SliderThumbElement::defaultEventHandler(Event* event) { +<<<<<<< HEAD if (!event->isMouseEvent() #if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS) && !event->isTouchEvent() #endif ) { ShadowBlockElement::defaultEventHandler(event); +======= + if (!event->isMouseEvent()) { + HTMLDivElement::defaultEventHandler(event); +>>>>>>> WebKit.org @ r75993 return; } @@ -126,7 +171,7 @@ void SliderThumbElement::defaultEventHandler(Event* event) } } - ShadowBlockElement::defaultEventHandler(event); + HTMLDivElement::defaultEventHandler(event); } void SliderThumbElement::detach() @@ -135,7 +180,7 @@ void SliderThumbElement::detach() if (Frame* frame = document()->frame()) frame->eventHandler()->setCapturingMouseEventsNode(0); } - ShadowBlockElement::detach(); + HTMLDivElement::detach(); } } diff --git a/Source/WebCore/html/shadow/SliderThumbElement.h b/Source/WebCore/html/shadow/SliderThumbElement.h index 8205746..7219186 100644 --- a/Source/WebCore/html/shadow/SliderThumbElement.h +++ b/Source/WebCore/html/shadow/SliderThumbElement.h @@ -33,7 +33,9 @@ #define SliderThumbElement_h #include "FloatPoint.h" -#include "ShadowElement.h" +#include "HTMLDivElement.h" +#include "HTMLNames.h" +#include "RenderStyleConstants.h" #include <wtf/Forward.h> namespace WebCore { @@ -42,34 +44,47 @@ class HTMLElement; class Event; class FloatPoint; -class SliderThumbElement : public ShadowBlockElement { +class SliderThumbElement : public HTMLDivElement { public: - static PassRefPtr<SliderThumbElement> create(HTMLElement* shadowParent); + static PassRefPtr<SliderThumbElement> create(Document*); bool inDragMode() const { return m_inDragMode; } virtual void defaultEventHandler(Event*); virtual void detach(); + virtual AtomicString shadowPseudoId() const; -private: - SliderThumbElement(HTMLElement* shadowParent); +private: + SliderThumbElement(Document*); + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); FloatPoint m_offsetToThumb; bool m_inDragMode; }; -inline SliderThumbElement::SliderThumbElement(HTMLElement* shadowParent) - : ShadowBlockElement(shadowParent) +inline SliderThumbElement::SliderThumbElement(Document* document) + : HTMLDivElement(HTMLNames::divTag, document) , m_inDragMode(false) { } -inline PassRefPtr<SliderThumbElement> SliderThumbElement::create(HTMLElement* shadowParent) +inline PassRefPtr<SliderThumbElement> SliderThumbElement::create(Document* document) { - return adoptRef(new SliderThumbElement(shadowParent)); + return adoptRef(new SliderThumbElement(document)); } +inline AtomicString SliderThumbElement::shadowPseudoId() const +{ + DEFINE_STATIC_LOCAL(AtomicString, sliderThumb, ("-webkit-slider-thumb")); + return sliderThumb; } +inline SliderThumbElement* toSliderThumbElement(Node* node) +{ + ASSERT(!node || node->isHTMLElement()); + return static_cast<SliderThumbElement*>(node); +} + +} #endif |