diff options
author | Andrei Popescu <andreip@google.com> | 2009-08-20 12:01:05 +0100 |
---|---|---|
committer | Andrei Popescu <andreip@google.com> | 2009-08-20 12:01:05 +0100 |
commit | a47ceaee54843b761108a6c9157c62e8ea5f05f3 (patch) | |
tree | 5e73e0f60d525b566e7818223a5aabd6cd9ebcc8 /WebCore/html | |
parent | 666ce90734aced48a6dbbce4b87ae20b6f32d065 (diff) | |
parent | 0edbbe41d651e00d026675c1544d3b81b52f166b (diff) | |
download | external_webkit-a47ceaee54843b761108a6c9157c62e8ea5f05f3.zip external_webkit-a47ceaee54843b761108a6c9157c62e8ea5f05f3.tar.gz external_webkit-a47ceaee54843b761108a6c9157c62e8ea5f05f3.tar.bz2 |
Merge commit 'goog/master-webkit-merge' into eclair-merge
Diffstat (limited to 'WebCore/html')
150 files changed, 3147 insertions, 892 deletions
diff --git a/WebCore/html/DOMDataGridDataSource.cpp b/WebCore/html/DOMDataGridDataSource.cpp new file mode 100644 index 0000000..aa44d8c --- /dev/null +++ b/WebCore/html/DOMDataGridDataSource.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(DATAGRID) + +#include "DOMDataGridDataSource.h" + +namespace WebCore { + +DOMDataGridDataSource::DOMDataGridDataSource() +{ +} + +DOMDataGridDataSource::~DOMDataGridDataSource() +{ +} + +} // namespace WebCore + +#endif // ENABLE(DATAGRID) diff --git a/WebCore/html/DOMDataGridDataSource.h b/WebCore/html/DOMDataGridDataSource.h new file mode 100644 index 0000000..2ce2ab8 --- /dev/null +++ b/WebCore/html/DOMDataGridDataSource.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DOMDataGridDataSource_h +#define DOMDataGridDataSource_h + +#if ENABLE(DATAGRID) + +#include "DataGridDataSource.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class HTMLDataGridElement; + +class DOMDataGridDataSource : public DataGridDataSource { +public: + static PassRefPtr<DOMDataGridDataSource> create() + { + return adoptRef(new DOMDataGridDataSource); + } + + virtual ~DOMDataGridDataSource(); + + virtual bool isDOMDataGridDataSource() const { return true; } + +private: + DOMDataGridDataSource(); +}; + +inline DOMDataGridDataSource* asDOMDataGridDataSource(DataGridDataSource* dataSource) +{ + ASSERT(dataSource->isDOMDataGridDataSource()); + return static_cast<DOMDataGridDataSource*>(dataSource); +} + +inline const DOMDataGridDataSource* asDOMDataGridDataSource(const DataGridDataSource* dataSource) +{ + ASSERT(dataSource->isDOMDataGridDataSource()); + return static_cast<const DOMDataGridDataSource*>(dataSource); +} + +} // namespace WebCore + +#endif // ENABLE(DATAGRID) +#endif // DOMDataGridDataSource_h diff --git a/WebCore/html/DataGridColumn.cpp b/WebCore/html/DataGridColumn.cpp new file mode 100644 index 0000000..7810c86 --- /dev/null +++ b/WebCore/html/DataGridColumn.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(DATAGRID) + +#include "DataGridColumn.h" + +#include "DataGridColumnList.h" + +namespace WebCore { + +void DataGridColumn::setPrimary(bool primary) +{ + if (m_primary != primary) { + m_primary = primary; + if (m_columns) + m_columns->primaryColumnChanged(this); + } +} + +void DataGridColumn::columnChanged() +{ + if (m_columns) + m_columns->setDataGridNeedsLayout(); +} + +} // namespace WebCore + +#endif diff --git a/WebCore/html/DataGridColumn.h b/WebCore/html/DataGridColumn.h new file mode 100644 index 0000000..3d480a9 --- /dev/null +++ b/WebCore/html/DataGridColumn.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DataGridColumn_h +#define DataGridColumn_h + +#if ENABLE(DATAGRID) + +#include "AtomicString.h" +#include "RenderStyle.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + +class DataGridColumnList; + +class DataGridColumn : public RefCounted<DataGridColumn> { +public: + static PassRefPtr<DataGridColumn> create(const String& columnID, const String& label, const String& type, bool primary, unsigned short sortable) + { + return adoptRef(new DataGridColumn(columnID, label, type, primary, sortable)); + } + + const AtomicString& id() const { return m_id; } + void setId(const AtomicString& id) { m_id = id; columnChanged(); } + + const AtomicString& label() const { return m_label; } + void setLabel(const AtomicString& label) { m_label = label; columnChanged(); } + + const AtomicString& type() const { return m_type; } + void setType(const AtomicString& type) { m_type = type; columnChanged(); } + + unsigned short sortable() const { return m_sortable; } + void setSortable(unsigned short sortable) { m_sortable = sortable; columnChanged(); } + + unsigned short sortDirection() const { return m_sortDirection; } + void setSortDirection(unsigned short sortDirection) { m_sortDirection = sortDirection; columnChanged(); } + + bool primary() const { return m_primary; } + void setPrimary(bool); + + void setColumnList(DataGridColumnList* list) + { + m_columns = list; + m_columnStyle = 0; + m_headerStyle = 0; + m_rect = IntRect(); + } + + RenderStyle* columnStyle() const { return m_columnStyle.get(); } + void setColumnStyle(PassRefPtr<RenderStyle> style) { m_columnStyle = style; } + + RenderStyle* headerStyle() const { return m_headerStyle.get(); } + void setHeaderStyle(PassRefPtr<RenderStyle> style) { m_headerStyle = style; } + + const IntRect& rect() const { return m_rect; } + void setRect(const IntRect& rect) { m_rect = rect; } + +private: + DataGridColumn(const String& columnID, const String& label, const String& type, bool primary, unsigned short sortable) + : m_columns(0) + , m_id(columnID) + , m_label(label) + , m_type(type) + , m_primary(primary) + , m_sortable(sortable) + , m_sortDirection(0) + { + } + + void columnChanged(); + + DataGridColumnList* m_columns; // Not refcounted. The columns list will null out our reference when it goes away. + + AtomicString m_id; + AtomicString m_label; + AtomicString m_type; + + bool m_primary; + + unsigned short m_sortable; + unsigned short m_sortDirection; + + RefPtr<RenderStyle> m_columnStyle; // The style used to render the column background behind the row cells. + RefPtr<RenderStyle> m_headerStyle; // The style used to render the column header above the row cells. + + IntRect m_rect; +}; + +} // namespace WebCore + +#endif + +#endif // DataGridColumn_h diff --git a/WebCore/html/DataGridColumn.idl b/WebCore/html/DataGridColumn.idl new file mode 100644 index 0000000..f566325 --- /dev/null +++ b/WebCore/html/DataGridColumn.idl @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +module html { + + interface [ + GenerateConstructor, + Conditional=DATAGRID + ] DataGridColumn { + attribute DOMString id; // The identifier for the column. + attribute DOMString label; // The text to display in the column. + attribute DOMString type; // The type of data displayed in this column. + + const unsigned short NEVER_SORTED = 0; + const unsigned short ALWAYS_SORTED = 1; + const unsigned short SOMETIMES_SORTED = 2; + attribute unsigned short sortable; // Whether or not the column can be sorted. + + const unsigned short NATURAL_SORT = 0; + const unsigned short SORT_ASCENDING = 1; + const unsigned short SORC_DESCENDING = 2; + attribute unsigned short sortDirection; // The sort direction for the column. Valid values are ascending, descending and natural (no sort applied). + + attribute boolean primary; // Whether or not this is the primary column of the tree (this will be where the disclosure triangle and connecting tree lines will display) + }; + +} diff --git a/WebCore/html/DataGridColumnList.cpp b/WebCore/html/DataGridColumnList.cpp new file mode 100644 index 0000000..9613402 --- /dev/null +++ b/WebCore/html/DataGridColumnList.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(DATAGRID) + +#include "AtomicString.h" +#include "DataGridColumnList.h" +#include "HTMLDataGridElement.h" +#include "PlatformString.h" +#include "RenderObject.h" + +namespace WebCore { + +DataGridColumnList::DataGridColumnList(HTMLDataGridElement* dataGrid) + : m_dataGrid(dataGrid) +{ +} + +DataGridColumnList::~DataGridColumnList() +{ + clear(); +} + +DataGridColumn* DataGridColumnList::itemWithName(const AtomicString& name) const +{ + unsigned length = m_columns.size(); + for (unsigned i = 0; i < length; ++i) { + if (m_columns[i]->id() == name) + return m_columns[i].get(); + } + return 0; +} + +void DataGridColumnList::setDataGridNeedsLayout() +{ + // Mark the datagrid as needing layout. + if (dataGrid() && dataGrid()->renderer()) + dataGrid()->renderer()->setNeedsLayout(true); +} + +DataGridColumn* DataGridColumnList::add(const String& id, const String& label, const String& type, bool primary, unsigned short sortable) +{ + return add(DataGridColumn::create(id, label, type, primary, sortable).get()); +} + +DataGridColumn* DataGridColumnList::add(DataGridColumn* column) +{ + if (column->primary()) + m_primaryColumn = column; + m_columns.append(column); + column->setColumnList(this); + setDataGridNeedsLayout(); + return column; +} + +void DataGridColumnList::remove(DataGridColumn* col) +{ + size_t index = m_columns.find(col); + if (index == notFound) + return; + m_columns.remove(index); + if (col == m_primaryColumn) + m_primaryColumn = 0; + if (col == m_sortColumn) + m_sortColumn = 0; + col->setColumnList(0); + setDataGridNeedsLayout(); +} + +void DataGridColumnList::move(DataGridColumn* col, unsigned long index) +{ + size_t colIndex = m_columns.find(col); + if (colIndex == notFound) + return; + m_columns.insert(index, col); + setDataGridNeedsLayout(); +} + +void DataGridColumnList::clear() +{ + unsigned length = m_columns.size(); + for (unsigned i = 0; i < length; ++i) + m_columns[i]->setColumnList(0); + m_columns.clear(); + m_primaryColumn = 0; + m_sortColumn = 0; + setDataGridNeedsLayout(); +} + +void DataGridColumnList::primaryColumnChanged(DataGridColumn* col) +{ + if (col->primary()) + m_primaryColumn = col; + else if (m_primaryColumn = col) + m_primaryColumn = 0; + + setDataGridNeedsLayout(); +} + +} // namespace WebCore + +#endif diff --git a/WebCore/html/DataGridColumnList.h b/WebCore/html/DataGridColumnList.h new file mode 100644 index 0000000..ed72863 --- /dev/null +++ b/WebCore/html/DataGridColumnList.h @@ -0,0 +1,63 @@ +#ifndef DataGridColumnList_h +#define DataGridColumnList_h + +#if ENABLE(DATAGRID) + +#include "DataGridColumn.h" + +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/Vector.h> + +namespace WebCore { + +class AtomicString; +class HTMLDataGridElement; + +class DataGridColumnList : public RefCounted<DataGridColumnList> { + friend class DataGridColumn; +public: + static PassRefPtr<DataGridColumnList> create(HTMLDataGridElement* grid) + { + return adoptRef(new DataGridColumnList(grid)); + } + + ~DataGridColumnList(); + + unsigned length() const { return m_columns.size(); } + + DataGridColumn* item(unsigned index) const { return m_columns[index].get(); } + DataGridColumn* itemWithName(const AtomicString&) const; + + DataGridColumn* primaryColumn() const { return m_primaryColumn.get(); } + + DataGridColumn* sortColumn() const { return m_sortColumn.get(); } + + DataGridColumn* add(const String& id, const String& label, const String& type, bool primary, unsigned short sortable); + DataGridColumn* add(DataGridColumn*); + void remove(DataGridColumn*); + void move(DataGridColumn*, unsigned long index); + void clear(); + + HTMLDataGridElement* dataGrid() const { return m_dataGrid; } + void clearDataGrid() { m_dataGrid = 0; } + + void setDataGridNeedsLayout(); + +private: + DataGridColumnList(HTMLDataGridElement*); + + void primaryColumnChanged(DataGridColumn*); + + HTMLDataGridElement* m_dataGrid; // Weak reference. Will be nulled out when our tree goes away. + + Vector<RefPtr<DataGridColumn> > m_columns; + RefPtr<DataGridColumn> m_primaryColumn; + RefPtr<DataGridColumn> m_sortColumn; +}; + +} // namespace WebCore + +#endif + +#endif // DataGridColumnList_h diff --git a/WebCore/html/DataGridColumnList.idl b/WebCore/html/DataGridColumnList.idl new file mode 100644 index 0000000..1a59f43 --- /dev/null +++ b/WebCore/html/DataGridColumnList.idl @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +module html { + + interface [ + GenerateConstructor, + HasIndexGetter, + HasNameGetter, + Conditional=DATAGRID + ] DataGridColumnList { + DataGridColumn item(in [IsIndex] unsigned long index); + readonly attribute unsigned long length; + + readonly attribute DataGridColumn sortColumn; + readonly attribute DataGridColumn primaryColumn; + + DataGridColumn add(in DOMString id, in DOMString label, in DOMString type, in boolean primary, in unsigned short sortable); + void remove(in DataGridColumn column); + void move(in DataGridColumn column, in unsigned long index); + void clear(); + }; + +} diff --git a/WebCore/html/DataGridDataSource.h b/WebCore/html/DataGridDataSource.h new file mode 100644 index 0000000..2ab1f5b --- /dev/null +++ b/WebCore/html/DataGridDataSource.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DataGridDataSource_h +#define DataGridDataSource_h + +#if ENABLE(DATAGRID) + +#include <wtf/RefCounted.h> + +namespace WebCore { + +class HTMLDataGridElement; + +class DataGridDataSource : public RefCounted<DataGridDataSource> { +public: + virtual ~DataGridDataSource() { } + + virtual bool isDOMDataGridDataSource() const { return false; } + virtual bool isJSDataGridDataSource() const { return false; } +}; + +} // namespace WebCore + +#endif + +#endif // DataGridDataSource_h diff --git a/WebCore/html/HTMLAnchorElement.cpp b/WebCore/html/HTMLAnchorElement.cpp index 354f9f0..1515460 100644 --- a/WebCore/html/HTMLAnchorElement.cpp +++ b/WebCore/html/HTMLAnchorElement.cpp @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Simon Hausmann <hausmann@kde.org> - * Copyright (C) 2003, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * (C) 2006 Graham Dennis (graham.dennis@gmail.com) * * This library is free software; you can redistribute it and/or @@ -24,51 +24,36 @@ #include "config.h" #include "HTMLAnchorElement.h" -#include "CSSHelper.h" #include "DNS.h" -#include "Document.h" -#include "Event.h" -#include "EventHandler.h" #include "EventNames.h" #include "Frame.h" -#include "FrameLoader.h" -#include "FrameLoaderClient.h" #include "HTMLImageElement.h" #include "HTMLNames.h" #include "KeyboardEvent.h" #include "MappedAttribute.h" #include "MouseEvent.h" -#include "MutationEvent.h" #include "Page.h" -#include "RenderBox.h" #include "RenderImage.h" -#include "ResourceRequest.h" -#include "SelectionController.h" #include "Settings.h" -#include "UIEvent.h" namespace WebCore { using namespace HTMLNames; -HTMLAnchorElement::HTMLAnchorElement(Document* doc) - : HTMLElement(aTag, doc) +HTMLAnchorElement::HTMLAnchorElement(Document* document) + : HTMLElement(aTag, document) , m_rootEditableElementForSelectionOnMouseDown(0) , m_wasShiftKeyDownOnMouseDown(false) { } -HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document* doc) - : HTMLElement(tagName, doc) +HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document* document) + : HTMLElement(tagName, document) , m_rootEditableElementForSelectionOnMouseDown(0) , m_wasShiftKeyDownOnMouseDown(false) { } -HTMLAnchorElement::~HTMLAnchorElement() -{ -} - bool HTMLAnchorElement::supportsFocus() const { if (isContentEditable()) @@ -194,7 +179,7 @@ void HTMLAnchorElement::defaultEventHandler(Event* evt) return; } - String url = parseURL(getAttribute(hrefAttr)); + String url = deprecatedParseURL(getAttribute(hrefAttr)); ASSERT(evt->target()); ASSERT(evt->target()->toNode()); @@ -249,7 +234,7 @@ void HTMLAnchorElement::setActive(bool down, bool pause) if (Settings* settings = document()->settings()) editableLinkBehavior = settings->editableLinkBehavior(); - switch(editableLinkBehavior) { + switch (editableLinkBehavior) { default: case EditableLinkDefaultBehavior: case EditableLinkAlwaysLive: @@ -283,7 +268,7 @@ void HTMLAnchorElement::parseMappedAttribute(MappedAttribute *attr) if (wasLink != isLink()) setNeedsStyleRecalc(); if (isLink()) { - String parsedURL = parseURL(attr->value()); + String parsedURL = deprecatedParseURL(attr->value()); if (document()->isDNSPrefetchEnabled()) { if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "https") || parsedURL.startsWith("//")) prefetchDNS(document()->completeURL(parsedURL).host()); @@ -320,34 +305,15 @@ bool HTMLAnchorElement::canStartSelection() const return isContentEditable(); } -const AtomicString& HTMLAnchorElement::accessKey() const -{ - return getAttribute(accesskeyAttr); -} - -void HTMLAnchorElement::setAccessKey(const AtomicString& value) -{ - setAttribute(accesskeyAttr, value); -} - -const AtomicString& HTMLAnchorElement::charset() const -{ - return getAttribute(charsetAttr); -} - -void HTMLAnchorElement::setCharset(const AtomicString& value) -{ - setAttribute(charsetAttr, value); -} - -const AtomicString& HTMLAnchorElement::coords() const -{ - return getAttribute(coordsAttr); -} - -void HTMLAnchorElement::setCoords(const AtomicString& value) +bool HTMLAnchorElement::draggable() const { - setAttribute(coordsAttr, value); + // Should be draggable if we have an href attribute. + const AtomicString& value = getAttribute(draggableAttr); + if (equalIgnoringCase(value, "true")) + return true; + if (equalIgnoringCase(value, "false")) + return false; + return hasAttribute(hrefAttr); } KURL HTMLAnchorElement::href() const @@ -360,56 +326,11 @@ void HTMLAnchorElement::setHref(const AtomicString& value) setAttribute(hrefAttr, value); } -const AtomicString& HTMLAnchorElement::hreflang() const -{ - return getAttribute(hreflangAttr); -} - -void HTMLAnchorElement::setHreflang(const AtomicString& value) -{ - setAttribute(hreflangAttr, value); -} - const AtomicString& HTMLAnchorElement::name() const { return getAttribute(nameAttr); } -void HTMLAnchorElement::setName(const AtomicString& value) -{ - setAttribute(nameAttr, value); -} - -const AtomicString& HTMLAnchorElement::rel() const -{ - return getAttribute(relAttr); -} - -void HTMLAnchorElement::setRel(const AtomicString& value) -{ - setAttribute(relAttr, value); -} - -const AtomicString& HTMLAnchorElement::rev() const -{ - return getAttribute(revAttr); -} - -void HTMLAnchorElement::setRev(const AtomicString& value) -{ - setAttribute(revAttr, value); -} - -const AtomicString& HTMLAnchorElement::shape() const -{ - return getAttribute(shapeAttr); -} - -void HTMLAnchorElement::setShape(const AtomicString& value) -{ - setAttribute(shapeAttr, value); -} - short HTMLAnchorElement::tabIndex() const { // Skip the supportsFocus check in HTMLElement. @@ -421,25 +342,10 @@ String HTMLAnchorElement::target() const return getAttribute(targetAttr); } -void HTMLAnchorElement::setTarget(const AtomicString& value) -{ - setAttribute(targetAttr, value); -} - -const AtomicString& HTMLAnchorElement::type() const -{ - return getAttribute(typeAttr); -} - -void HTMLAnchorElement::setType(const AtomicString& value) -{ - setAttribute(typeAttr, value); -} - String HTMLAnchorElement::hash() const { - String ref = href().ref(); - return ref.isEmpty() ? "" : "#" + ref; + String fragmentIdentifier = href().fragmentIdentifier(); + return fragmentIdentifier.isEmpty() ? "" : "#" + fragmentIdentifier; } String HTMLAnchorElement::host() const @@ -497,7 +403,7 @@ bool HTMLAnchorElement::isLiveLink() const if (Settings* settings = document()->settings()) editableLinkBehavior = settings->editableLinkBehavior(); - switch(editableLinkBehavior) { + switch (editableLinkBehavior) { default: case EditableLinkDefaultBehavior: case EditableLinkAlwaysLive: diff --git a/WebCore/html/HTMLAnchorElement.h b/WebCore/html/HTMLAnchorElement.h index dd4b6f9..7779bed 100644 --- a/WebCore/html/HTMLAnchorElement.h +++ b/WebCore/html/HTMLAnchorElement.h @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Simon Hausmann <hausmann@kde.org> - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -32,72 +32,44 @@ class HTMLAnchorElement : public HTMLElement { public: HTMLAnchorElement(Document*); HTMLAnchorElement(const QualifiedName&, Document*); - ~HTMLAnchorElement(); - - virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } - virtual int tagPriority() const { return 1; } - - virtual bool supportsFocus() const; - virtual bool isMouseFocusable() const; - virtual bool isKeyboardFocusable(KeyboardEvent*) const; - virtual bool isFocusable() const; - virtual void parseMappedAttribute(MappedAttribute*); - virtual void defaultEventHandler(Event*); - virtual void setActive(bool active = true, bool pause = false); - virtual void accessKeyAction(bool fullAction); - virtual bool isURLAttribute(Attribute*) const; - - virtual bool canStartSelection() const; - - const AtomicString& accessKey() const; - void setAccessKey(const AtomicString&); - - const AtomicString& charset() const; - void setCharset(const AtomicString&); - - const AtomicString& coords() const; - void setCoords(const AtomicString&); KURL href() const; void setHref(const AtomicString&); - const AtomicString& hreflang() const; - void setHreflang(const AtomicString&); - const AtomicString& name() const; - void setName(const AtomicString&); - - const AtomicString& rel() const; - void setRel(const AtomicString&); - - const AtomicString& rev() const; - void setRev(const AtomicString&); - - const AtomicString& shape() const; - void setShape(const AtomicString&); - - virtual short tabIndex() const; - - virtual String target() const; - void setTarget(const AtomicString&); - - const AtomicString& type() const; - void setType(const AtomicString&); String hash() const; String host() const; String hostname() const; + virtual bool isFocusable() const; String pathname() const; String port() const; String protocol() const; String search() const; String text() const; - + String toString() const; bool isLiveLink() const; +protected: + virtual void parseMappedAttribute(MappedAttribute*); + private: + virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } + virtual int tagPriority() const { return 1; } + virtual bool supportsFocus() const; + virtual bool isMouseFocusable() const; + virtual bool isKeyboardFocusable(KeyboardEvent*) const; + virtual void defaultEventHandler(Event*); + virtual void setActive(bool active = true, bool pause = false); + virtual void accessKeyAction(bool fullAction); + virtual bool isURLAttribute(Attribute*) const; + virtual bool canStartSelection() const; + virtual String target() const; + virtual short tabIndex() const; + virtual bool draggable() const; + Element* m_rootEditableElementForSelectionOnMouseDown; bool m_wasShiftKeyDownOnMouseDown; }; diff --git a/WebCore/html/HTMLAnchorElement.idl b/WebCore/html/HTMLAnchorElement.idl index c2dda3d..057358e 100644 --- a/WebCore/html/HTMLAnchorElement.idl +++ b/WebCore/html/HTMLAnchorElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 Apple Inc. + * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> * * This library is free software; you can redistribute it and/or @@ -25,17 +25,17 @@ module html { InterfaceUUID=0c74cef8-b1f7-4b44-83a9-8deeb376a257, ImplementationUUID=30f797d5-d145-498e-a126-d8e9ddeedea3 ] HTMLAnchorElement : HTMLElement { - attribute [ConvertNullToNullString] DOMString accessKey; - attribute [ConvertNullToNullString] DOMString charset; - attribute [ConvertNullToNullString] DOMString coords; - attribute [ConvertNullToNullString] DOMString href; - attribute [ConvertNullToNullString] DOMString hreflang; - attribute [ConvertNullToNullString] DOMString name; - attribute [ConvertNullToNullString] DOMString rel; - attribute [ConvertNullToNullString] DOMString rev; - attribute [ConvertNullToNullString] DOMString shape; - attribute [ConvertNullToNullString] DOMString target; - attribute [ConvertNullToNullString] DOMString type; + attribute [ConvertNullToNullString, Reflect=accesskey] DOMString accessKey; + attribute [ConvertNullToNullString, Reflect] DOMString charset; + attribute [ConvertNullToNullString, Reflect] DOMString coords; + attribute [ConvertNullToNullString, ReflectURL] DOMString href; + attribute [ConvertNullToNullString, Reflect] DOMString hreflang; + attribute [ConvertNullToNullString, Reflect] DOMString name; + attribute [ConvertNullToNullString, Reflect] DOMString rel; + attribute [ConvertNullToNullString, Reflect] DOMString rev; + attribute [ConvertNullToNullString, Reflect] DOMString shape; + attribute [ConvertNullToNullString, Reflect] DOMString target; + attribute [ConvertNullToNullString, Reflect] DOMString type; // IE Extensions readonly attribute DOMString hash; diff --git a/WebCore/html/HTMLAppletElement.cpp b/WebCore/html/HTMLAppletElement.cpp index 13dd911..dfa2597 100644 --- a/WebCore/html/HTMLAppletElement.cpp +++ b/WebCore/html/HTMLAppletElement.cpp @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Stefan Schimanski (1Stein@gmx.de) - * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) * * This library is free software; you can redistribute it and/or @@ -24,14 +24,11 @@ #include "config.h" #include "HTMLAppletElement.h" -#include "Frame.h" #include "HTMLDocument.h" #include "HTMLNames.h" #include "MappedAttribute.h" #include "RenderApplet.h" -#include "RenderInline.h" #include "Settings.h" -#include "ScriptController.h" namespace WebCore { @@ -43,10 +40,6 @@ HTMLAppletElement::HTMLAppletElement(const QualifiedName& tagName, Document* doc ASSERT(hasTagName(appletTag)); } -HTMLAppletElement::~HTMLAppletElement() -{ -} - void HTMLAppletElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == altAttr || @@ -148,7 +141,7 @@ RenderWidget* HTMLAppletElement::renderWidgetForJSBindings() const if (!settings || !settings->isJavaEnabled()) return 0; - RenderApplet* applet = static_cast<RenderApplet*>(renderer()); + RenderApplet* applet = toRenderApplet(renderer()); if (applet) applet->createWidgetIfNecessary(); @@ -163,46 +156,6 @@ void HTMLAppletElement::finishParsingChildren() renderer()->setNeedsLayout(true); // This will cause it to create its widget & the Java applet } -String HTMLAppletElement::alt() const -{ - return getAttribute(altAttr); -} - -void HTMLAppletElement::setAlt(const String &value) -{ - setAttribute(altAttr, value); -} - -String HTMLAppletElement::archive() const -{ - return getAttribute(archiveAttr); -} - -void HTMLAppletElement::setArchive(const String &value) -{ - setAttribute(archiveAttr, value); -} - -String HTMLAppletElement::code() const -{ - return getAttribute(codeAttr); -} - -void HTMLAppletElement::setCode(const String &value) -{ - setAttribute(codeAttr, value); -} - -String HTMLAppletElement::codeBase() const -{ - return getAttribute(codebaseAttr); -} - -void HTMLAppletElement::setCodeBase(const String &value) -{ - setAttribute(codebaseAttr, value); -} - String HTMLAppletElement::hspace() const { return getAttribute(hspaceAttr); @@ -213,16 +166,6 @@ void HTMLAppletElement::setHspace(const String &value) setAttribute(hspaceAttr, value); } -String HTMLAppletElement::object() const -{ - return getAttribute(objectAttr); -} - -void HTMLAppletElement::setObject(const String &value) -{ - setAttribute(objectAttr, value); -} - String HTMLAppletElement::vspace() const { return getAttribute(vspaceAttr); diff --git a/WebCore/html/HTMLAppletElement.h b/WebCore/html/HTMLAppletElement.h index 26d8126..c616bb4 100644 --- a/WebCore/html/HTMLAppletElement.h +++ b/WebCore/html/HTMLAppletElement.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) - * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2006, 2008, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -30,12 +30,17 @@ namespace WebCore { class HTMLFormElement; class HTMLImageLoader; -class HTMLAppletElement : public HTMLPlugInElement -{ +class HTMLAppletElement : public HTMLPlugInElement { public: HTMLAppletElement(const QualifiedName&, Document*); - ~HTMLAppletElement(); + String hspace() const; + void setHspace(const String&); + + String vspace() const; + void setVspace(const String&); + +private: virtual int tagPriority() const { return 1; } virtual void parseMappedAttribute(MappedAttribute*); @@ -46,33 +51,11 @@ public: virtual RenderWidget* renderWidgetForJSBindings() const; - String alt() const; - void setAlt(const String&); - - String archive() const; - void setArchive(const String&); - - String code() const; - void setCode(const String&); - - String codeBase() const; - void setCodeBase(const String&); - - String hspace() const; - void setHspace(const String&); - - String object() const; - void setObject(const String&); - - String vspace() const; - void setVspace(const String&); - void setupApplet() const; virtual void insertedIntoDocument(); virtual void removedFromDocument(); -private: AtomicString m_id; }; diff --git a/WebCore/html/HTMLAppletElement.idl b/WebCore/html/HTMLAppletElement.idl index 95f03a7..cc923ca 100644 --- a/WebCore/html/HTMLAppletElement.idl +++ b/WebCore/html/HTMLAppletElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> * * This library is free software; you can redistribute it and/or @@ -22,32 +22,32 @@ module html { interface [ GenerateConstructor, - CustomPutFunction, - CustomGetOwnPropertySlot, + DelegatingPutFunction, + DelegatingGetOwnPropertySlot, CustomCall, HasOverridingNameGetter, InterfaceUUID=9b5cb4a8-c156-4b55-afdb-c60938a4d1b1, ImplementationUUID=56544372-675e-40dd-ba39-fa708a4c7678 ] HTMLAppletElement : HTMLElement { - attribute [ConvertNullToNullString] DOMString align; - attribute [ConvertNullToNullString] DOMString alt; - attribute [ConvertNullToNullString] DOMString archive; - attribute [ConvertNullToNullString] DOMString code; - attribute [ConvertNullToNullString] DOMString codeBase; - attribute [ConvertNullToNullString] DOMString height; + attribute [ConvertNullToNullString, Reflect] DOMString align; + attribute [ConvertNullToNullString, Reflect] DOMString alt; + attribute [ConvertNullToNullString, Reflect] DOMString archive; + attribute [ConvertNullToNullString, Reflect] DOMString code; + attribute [ConvertNullToNullString, Reflect=codebase] DOMString codeBase; + attribute [ConvertNullToNullString, Reflect] DOMString height; #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - attribute [ConvertNullToNullString] DOMString hspace; + attribute [ConvertNullToNullString, Reflect] DOMString hspace; #else attribute [ConvertFromString] long hspace; #endif - attribute [ConvertNullToNullString] DOMString name; - attribute [ConvertNullToNullString] DOMString object; + attribute [ConvertNullToNullString, Reflect] DOMString name; + attribute [ConvertNullToNullString, Reflect] DOMString object; #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT - attribute [ConvertNullToNullString] DOMString vspace; + attribute [ConvertNullToNullString, Reflect] DOMString vspace; #else attribute [ConvertFromString] long vspace; #endif - attribute [ConvertNullToNullString] DOMString width; + attribute [ConvertNullToNullString, Reflect] DOMString width; }; } diff --git a/WebCore/html/HTMLAreaElement.cpp b/WebCore/html/HTMLAreaElement.cpp index 2f7c1a5..b878a1a 100644 --- a/WebCore/html/HTMLAreaElement.cpp +++ b/WebCore/html/HTMLAreaElement.cpp @@ -22,11 +22,8 @@ #include "config.h" #include "HTMLAreaElement.h" -#include "Document.h" -#include "FloatRect.h" #include "HTMLNames.h" #include "HitTestResult.h" -#include "Length.h" #include "MappedAttribute.h" #include "Path.h" #include "RenderObject.h" @@ -52,7 +49,7 @@ HTMLAreaElement::~HTMLAreaElement() delete [] m_coords; } -void HTMLAreaElement::parseMappedAttribute(MappedAttribute *attr) +void HTMLAreaElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == shapeAttr) { if (equalIgnoringCase(attr->value(), "default")) @@ -152,46 +149,11 @@ Path HTMLAreaElement::getRegion(const IntSize& size) const return path; } -const AtomicString& HTMLAreaElement::accessKey() const -{ - return getAttribute(accesskeyAttr); -} - -void HTMLAreaElement::setAccessKey(const AtomicString& value) -{ - setAttribute(accesskeyAttr, value); -} - -const AtomicString& HTMLAreaElement::alt() const -{ - return getAttribute(altAttr); -} - -void HTMLAreaElement::setAlt(const AtomicString& value) -{ - setAttribute(altAttr, value); -} - -const AtomicString& HTMLAreaElement::coords() const -{ - return getAttribute(coordsAttr); -} - -void HTMLAreaElement::setCoords(const AtomicString& value) -{ - setAttribute(coordsAttr, value); -} - KURL HTMLAreaElement::href() const { return document()->completeURL(getAttribute(hrefAttr)); } -void HTMLAreaElement::setHref(const AtomicString& value) -{ - setAttribute(hrefAttr, value); -} - bool HTMLAreaElement::noHref() const { return !getAttribute(nohrefAttr).isNull(); @@ -202,16 +164,6 @@ void HTMLAreaElement::setNoHref(bool noHref) setAttribute(nohrefAttr, noHref ? "" : 0); } -const AtomicString& HTMLAreaElement::shape() const -{ - return getAttribute(shapeAttr); -} - -void HTMLAreaElement::setShape(const AtomicString& value) -{ - setAttribute(shapeAttr, value); -} - bool HTMLAreaElement::isFocusable() const { return HTMLElement::isFocusable(); @@ -222,9 +174,4 @@ String HTMLAreaElement::target() const return getAttribute(targetAttr); } -void HTMLAreaElement::setTarget(const AtomicString& value) -{ - setAttribute(targetAttr, value); -} - } diff --git a/WebCore/html/HTMLAreaElement.h b/WebCore/html/HTMLAreaElement.h index 19533b1..fffd45e 100644 --- a/WebCore/html/HTMLAreaElement.h +++ b/WebCore/html/HTMLAreaElement.h @@ -34,43 +34,26 @@ class Path; class HTMLAreaElement : public HTMLAnchorElement { public: HTMLAreaElement(const QualifiedName&, Document*); - ~HTMLAreaElement(); - - virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } - virtual int tagPriority() const { return 0; } - - virtual void parseMappedAttribute(MappedAttribute*); + virtual ~HTMLAreaElement(); bool isDefault() const { return m_shape == Default; } bool mapMouseEvent(int x, int y, const IntSize&, HitTestResult&); - virtual IntRect getRect(RenderObject*) const; - - const AtomicString& accessKey() const; - void setAccessKey(const AtomicString&); - - const AtomicString& alt() const; - void setAlt(const AtomicString&); - - const AtomicString& coords() const; - void setCoords(const AtomicString&); + IntRect getRect(RenderObject*) const; KURL href() const; - void setHref(const AtomicString&); bool noHref() const; void setNoHref(bool); - const AtomicString& shape() const; - void setShape(const AtomicString&); - +private: + virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } + virtual int tagPriority() const { return 0; } + virtual void parseMappedAttribute(MappedAttribute*); virtual bool isFocusable() const; - virtual String target() const; - void setTarget(const AtomicString&); -private: enum Shape { Default, Poly, Rect, Circle, Unknown }; Path getRegion(const IntSize&) const; diff --git a/WebCore/html/HTMLAreaElement.idl b/WebCore/html/HTMLAreaElement.idl index d80ebed..53239c6 100644 --- a/WebCore/html/HTMLAreaElement.idl +++ b/WebCore/html/HTMLAreaElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> * * This library is free software; you can redistribute it and/or @@ -25,13 +25,13 @@ module html { InterfaceUUID=aac98729-47d3-4623-8c5b-004783af5bd6, ImplementationUUID=f0631a41-5f55-40e5-a879-c09e663c26ba ] HTMLAreaElement : HTMLElement { - attribute [ConvertNullToNullString] DOMString accessKey; - attribute [ConvertNullToNullString] DOMString alt; - attribute [ConvertNullToNullString] DOMString coords; - attribute [ConvertNullToNullString] DOMString href; + attribute [ConvertNullToNullString, Reflect=accesskey] DOMString accessKey; + attribute [ConvertNullToNullString, Reflect] DOMString alt; + attribute [ConvertNullToNullString, Reflect] DOMString coords; + attribute [ConvertNullToNullString, ReflectURL] DOMString href; attribute boolean noHref; - attribute [ConvertNullToNullString] DOMString shape; - attribute [ConvertNullToNullString] DOMString target; + attribute [ConvertNullToNullString, Reflect] DOMString shape; + attribute [ConvertNullToNullString, Reflect] DOMString target; // IE Extensions readonly attribute DOMString hash; diff --git a/WebCore/html/HTMLAttributeNames.in b/WebCore/html/HTMLAttributeNames.in index 7caf0e5..05c0cb7 100644 --- a/WebCore/html/HTMLAttributeNames.in +++ b/WebCore/html/HTMLAttributeNames.in @@ -15,13 +15,19 @@ archive aria-activedescendant aria-checked aria-describedby +aria-disabled +aria-hidden +aria-label aria-labeledby aria-labelledby aria-level aria-pressed +aria-readonly +aria-required aria-valuemax aria-valuemin aria-valuenow +aria-valuetext autobuffer autocomplete autofocus @@ -65,9 +71,12 @@ defer dir direction disabled +draggable enctype end +expanded face +focused for frame frameborder @@ -80,6 +89,7 @@ hspace http_equiv id incremental +indeterminate ismap keytype label @@ -115,6 +125,8 @@ onbeforecut onbeforepaste onbeforeunload onblur +oncanplay +oncanplaythrough onchange onclick oncontextmenu @@ -128,13 +140,20 @@ ondragleave ondragover ondragstart ondrop +ondurationchange +onemptied +onended onerror onfocus +onhashchange oninput onkeydown onkeypress onkeyup onload +onloadeddata +onloadedmetadata +onloadstart onmousedown onmousemove onmouseout @@ -144,14 +163,24 @@ onmousewheel ononline onoffline onpaste +onpause +onplay +onplaying +onprogress +onratechange onreset onresize onscroll onsearch +onseeked +onseeking onselect onselectstart +onstalled onstorage +onsuspend onsubmit +ontimeupdate /* #if ENABLE(TOUCH_EVENTS) // Android */ ontouchstart ontouchmove @@ -159,18 +188,24 @@ ontouchend ontouchcancel /* #endif */ onunload +onvolumechange +onwaiting onwebkitanimationstart onwebkitanimationiteration onwebkitanimationend onwebkittransitionend +pattern placeholder pluginurl poster precision +primary profile +progress prompt readonly rel +required results rev role @@ -185,6 +220,8 @@ scrolling selected shape size +sortable +sortdirection span spellcheck src diff --git a/WebCore/html/HTMLAudioElement.h b/WebCore/html/HTMLAudioElement.h index de390cf..1dbe44f 100644 --- a/WebCore/html/HTMLAudioElement.h +++ b/WebCore/html/HTMLAudioElement.h @@ -32,8 +32,7 @@ namespace WebCore { -class HTMLAudioElement : public HTMLMediaElement -{ +class HTMLAudioElement : public HTMLMediaElement { public: HTMLAudioElement(const QualifiedName&, Document*); diff --git a/WebCore/html/HTMLBRElement.cpp b/WebCore/html/HTMLBRElement.cpp index 6f86e6a..dbd8eba 100644 --- a/WebCore/html/HTMLBRElement.cpp +++ b/WebCore/html/HTMLBRElement.cpp @@ -1,8 +1,8 @@ -/** +/* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Simon Hausmann <hausmann@kde.org> - * Copyright (C) 2003, 2006 Apple Computer, Inc. + * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -38,10 +38,6 @@ HTMLBRElement::HTMLBRElement(const QualifiedName& tagName, Document *doc) ASSERT(hasTagName(brTag)); } -HTMLBRElement::~HTMLBRElement() -{ -} - bool HTMLBRElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const { if (attrName == clearAttr) { @@ -52,7 +48,7 @@ bool HTMLBRElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEnt return HTMLElement::mapToEntry(attrName, result); } -void HTMLBRElement::parseMappedAttribute(MappedAttribute *attr) +void HTMLBRElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == clearAttr) { // If the string is empty, then don't add the clear property. @@ -76,14 +72,4 @@ RenderObject* HTMLBRElement::createRenderer(RenderArena* arena, RenderStyle* sty return new (arena) RenderBR(this); } -String HTMLBRElement::clear() const -{ - return getAttribute(clearAttr); -} - -void HTMLBRElement::setClear(const String &value) -{ - setAttribute(clearAttr, value); -} - } diff --git a/WebCore/html/HTMLBRElement.h b/WebCore/html/HTMLBRElement.h index 982a646..6b20b37 100644 --- a/WebCore/html/HTMLBRElement.h +++ b/WebCore/html/HTMLBRElement.h @@ -2,6 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Simon Hausmann <hausmann@kde.org> + * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -19,6 +20,7 @@ * Boston, MA 02110-1301, USA. * */ + #ifndef HTMLBRElement_h #define HTMLBRElement_h @@ -28,22 +30,18 @@ namespace WebCore { class String; -class HTMLBRElement : public HTMLElement -{ +class HTMLBRElement : public HTMLElement { public: HTMLBRElement(const QualifiedName&, Document*); - ~HTMLBRElement(); - + +private: virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } virtual int tagPriority() const { return 0; } virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const; - virtual void parseMappedAttribute(MappedAttribute *attr); + virtual void parseMappedAttribute(MappedAttribute*); - virtual RenderObject *createRenderer(RenderArena*, RenderStyle*); - - String clear() const; - void setClear(const String&); + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); }; } //namespace diff --git a/WebCore/html/HTMLBRElement.idl b/WebCore/html/HTMLBRElement.idl index 79e05ed..6d626ff 100644 --- a/WebCore/html/HTMLBRElement.idl +++ b/WebCore/html/HTMLBRElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,7 +24,7 @@ module html { InterfaceUUID=e84b14bc-b0aa-431f-83c4-fcc297e354b0, ImplementationUUID=c10d45a4-b042-45d0-b170-6ac7173ee823 ] HTMLBRElement : HTMLElement { - attribute [ConvertNullToNullString] DOMString clear; + attribute [ConvertNullToNullString, Reflect] DOMString clear; }; } diff --git a/WebCore/html/HTMLBaseElement.cpp b/WebCore/html/HTMLBaseElement.cpp index a278908..613a0f7 100644 --- a/WebCore/html/HTMLBaseElement.cpp +++ b/WebCore/html/HTMLBaseElement.cpp @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2003, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -26,29 +26,25 @@ #include "CSSHelper.h" #include "Document.h" #include "Frame.h" -#include "FrameLoader.h" #include "HTMLNames.h" -#include "KURL.h" #include "MappedAttribute.h" +#include "XSSAuditor.h" namespace WebCore { using namespace HTMLNames; -HTMLBaseElement::HTMLBaseElement(const QualifiedName& qName, Document* doc) - : HTMLElement(qName, doc) +HTMLBaseElement::HTMLBaseElement(const QualifiedName& qName, Document* document) + : HTMLElement(qName, document) { ASSERT(hasTagName(baseTag)); } -HTMLBaseElement::~HTMLBaseElement() -{ -} - void HTMLBaseElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == hrefAttr) { - m_href = parseURL(attr->value()); + m_hrefAttrValue = attr->value(); + m_href = deprecatedParseURL(attr->value()); process(); } else if (attr->name() == targetAttr) { m_target = attr->value(); @@ -67,8 +63,8 @@ void HTMLBaseElement::removedFromDocument() { HTMLElement::removedFromDocument(); - // Since the document doesn't have a base element... - // (This will break in the case of multiple base elements, but that's not valid anyway (?)) + // Since the document doesn't have a base element, clear the base URL and target. + // FIXME: This does not handle the case of multiple base elements correctly. document()->setBaseElementURL(KURL()); document()->setBaseElementTarget(String()); } @@ -78,23 +74,13 @@ void HTMLBaseElement::process() if (!inDocument()) return; - if (!m_href.isEmpty()) + if (!m_href.isEmpty() && (!document()->frame() || document()->frame()->script()->xssAuditor()->canSetBaseElementURL(m_hrefAttrValue))) document()->setBaseElementURL(KURL(document()->url(), m_href)); if (!m_target.isEmpty()) document()->setBaseElementTarget(m_target); - // ### should changing a document's base URL dynamically automatically update all images, stylesheets etc? -} - -void HTMLBaseElement::setHref(const String &value) -{ - setAttribute(hrefAttr, value); -} - -void HTMLBaseElement::setTarget(const String &value) -{ - setAttribute(targetAttr, value); + // FIXME: Changing a document's base URL should probably automatically update the resolved relative URLs of all images, stylesheets, etc. } } diff --git a/WebCore/html/HTMLBaseElement.h b/WebCore/html/HTMLBaseElement.h index f068851..d413bec 100644 --- a/WebCore/html/HTMLBaseElement.h +++ b/WebCore/html/HTMLBaseElement.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) - * Copyright (C) 2003 Apple Computer, Inc. + * Copyright (C) 2003, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -19,6 +19,7 @@ * Boston, MA 02110-1301, USA. * */ + #ifndef HTMLBaseElement_h #define HTMLBaseElement_h @@ -26,16 +27,14 @@ namespace WebCore { -class HTMLBaseElement : public HTMLElement -{ +class HTMLBaseElement : public HTMLElement { public: HTMLBaseElement(const QualifiedName&, Document*); - ~HTMLBaseElement(); +private: virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } virtual int tagPriority() const { return 0; } - String href() const { return m_href; } virtual String target() const { return m_target; } virtual void parseMappedAttribute(MappedAttribute*); @@ -47,7 +46,7 @@ public: void setHref(const String&); void setTarget(const String&); -protected: + String m_hrefAttrValue; String m_href; String m_target; }; diff --git a/WebCore/html/HTMLBaseElement.idl b/WebCore/html/HTMLBaseElement.idl index 76025fa..b7385ec 100644 --- a/WebCore/html/HTMLBaseElement.idl +++ b/WebCore/html/HTMLBaseElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,8 +24,8 @@ module html { InterfaceUUID=e4112bea-13de-40f6-93d0-41e285ae1491, ImplementationUUID=23cec074-660f-490a-996d-167d66c164d5 ] HTMLBaseElement : HTMLElement { - attribute [ConvertNullToNullString] DOMString href; - attribute [ConvertNullToNullString] DOMString target; + attribute [ConvertNullToNullString, Reflect] DOMString href; + attribute [ConvertNullToNullString, Reflect] DOMString target; }; } diff --git a/WebCore/html/HTMLBaseFontElement.cpp b/WebCore/html/HTMLBaseFontElement.cpp index ef08822..9acbf73 100644 --- a/WebCore/html/HTMLBaseFontElement.cpp +++ b/WebCore/html/HTMLBaseFontElement.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) - * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -19,40 +19,22 @@ * Boston, MA 02110-1301, USA. * */ + #include "config.h" #include "HTMLBaseFontElement.h" + #include "HTMLNames.h" namespace WebCore { using namespace HTMLNames; -HTMLBaseFontElement::HTMLBaseFontElement(const QualifiedName& tagName, Document* doc) - : HTMLElement(tagName, doc) +HTMLBaseFontElement::HTMLBaseFontElement(const QualifiedName& tagName, Document* document) + : HTMLElement(tagName, document) { ASSERT(hasTagName(basefontTag)); } -String HTMLBaseFontElement::color() const -{ - return getAttribute(colorAttr); -} - -void HTMLBaseFontElement::setColor(const String &value) -{ - setAttribute(colorAttr, value); -} - -String HTMLBaseFontElement::face() const -{ - return getAttribute(faceAttr); -} - -void HTMLBaseFontElement::setFace(const String &value) -{ - setAttribute(faceAttr, value); -} - int HTMLBaseFontElement::size() const { return getAttribute(sizeAttr).toInt(); diff --git a/WebCore/html/HTMLBaseFontElement.h b/WebCore/html/HTMLBaseFontElement.h index 0c9a9fd..e76d07f 100644 --- a/WebCore/html/HTMLBaseFontElement.h +++ b/WebCore/html/HTMLBaseFontElement.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) - * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -19,6 +19,7 @@ * Boston, MA 02110-1301, USA. * */ + #ifndef HTMLBaseFontElement_h #define HTMLBaseFontElement_h @@ -26,24 +27,18 @@ namespace WebCore { -class HTMLBaseFontElement : public HTMLElement -{ +class HTMLBaseFontElement : public HTMLElement { public: - HTMLBaseFontElement(const QualifiedName&, Document* doc); - - virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } - virtual int tagPriority() const { return 0; } - - String color() const; - void setColor(const String &); - - String face() const; - void setFace(const String &); + HTMLBaseFontElement(const QualifiedName&, Document*); int size() const; void setSize(int); + +private: + virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } + virtual int tagPriority() const { return 0; } }; -} //namespace +} // namespace #endif diff --git a/WebCore/html/HTMLBaseFontElement.idl b/WebCore/html/HTMLBaseFontElement.idl index f09c9d7..665f124 100644 --- a/WebCore/html/HTMLBaseFontElement.idl +++ b/WebCore/html/HTMLBaseFontElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,8 +24,8 @@ module html { InterfaceUUID=434b1be5-408e-45b5-be83-c70e11e9bb37, ImplementationUUID=1dc8508e-53c4-4e7e-93c0-16772372b2dc ] HTMLBaseFontElement : HTMLElement { - attribute [ConvertNullToNullString] DOMString color; - attribute [ConvertNullToNullString] DOMString face; + attribute [ConvertNullToNullString, Reflect] DOMString color; + attribute [ConvertNullToNullString, Reflect] DOMString face; #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C attribute [ConvertToString] DOMString size; // this changed to a long, but our existing API is a string #else diff --git a/WebCore/html/HTMLBlockquoteElement.cpp b/WebCore/html/HTMLBlockquoteElement.cpp index 682063c..c064ad3 100644 --- a/WebCore/html/HTMLBlockquoteElement.cpp +++ b/WebCore/html/HTMLBlockquoteElement.cpp @@ -1,7 +1,7 @@ -/** +/* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) - * Copyright (C) 2003 Apple Computer, Inc. + * Copyright (C) 2003, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -19,6 +19,7 @@ * Boston, MA 02110-1301, USA. * */ + #include "config.h" #include "HTMLBlockquoteElement.h" @@ -28,24 +29,10 @@ namespace WebCore { using namespace HTMLNames; -HTMLBlockquoteElement::HTMLBlockquoteElement(const QualifiedName& tagName, Document* doc) - : HTMLElement(tagName, doc) +HTMLBlockquoteElement::HTMLBlockquoteElement(const QualifiedName& tagName, Document* document) + : HTMLElement(tagName, document) { ASSERT(hasTagName(blockquoteTag)); } -HTMLBlockquoteElement::~HTMLBlockquoteElement() -{ -} - -String HTMLBlockquoteElement::cite() const -{ - return getAttribute(citeAttr); -} - -void HTMLBlockquoteElement::setCite(const String &value) -{ - setAttribute(citeAttr, value); -} - } diff --git a/WebCore/html/HTMLBlockquoteElement.h b/WebCore/html/HTMLBlockquoteElement.h index 7b5ee21..f27d258 100644 --- a/WebCore/html/HTMLBlockquoteElement.h +++ b/WebCore/html/HTMLBlockquoteElement.h @@ -1,6 +1,7 @@ /* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) + * Copyright (C) 2009 Apple Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -29,13 +30,10 @@ namespace WebCore { class HTMLBlockquoteElement : public HTMLElement { public: HTMLBlockquoteElement(const QualifiedName&, Document*); - ~HTMLBlockquoteElement(); +private: virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } virtual int tagPriority() const { return 5; } - - String cite() const; - void setCite(const String&); }; } // namespace WebCore diff --git a/WebCore/html/HTMLBlockquoteElement.idl b/WebCore/html/HTMLBlockquoteElement.idl index d135fcd..f6463dd 100644 --- a/WebCore/html/HTMLBlockquoteElement.idl +++ b/WebCore/html/HTMLBlockquoteElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,7 +24,7 @@ module html { InterfaceUUID=902d9011-c6d6-4363-b6fe-bd2d28ef553b, ImplementationUUID=345db946-ba9c-44b9-87fd-06083aa472e4 ] HTMLBlockquoteElement : HTMLElement { - attribute [ConvertNullToNullString] DOMString cite; + attribute [ConvertNullToNullString, Reflect] DOMString cite; }; } diff --git a/WebCore/html/HTMLBodyElement.cpp b/WebCore/html/HTMLBodyElement.cpp index 119a06a..c8ae037 100644 --- a/WebCore/html/HTMLBodyElement.cpp +++ b/WebCore/html/HTMLBodyElement.cpp @@ -3,7 +3,7 @@ * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Simon Hausmann (hausmann@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,13 +24,9 @@ #include "config.h" #include "HTMLBodyElement.h" -#include "CSSHelper.h" -#include "CSSMutableStyleDeclaration.h" -#include "CSSPropertyNames.h" #include "CSSStyleSelector.h" #include "CSSStyleSheet.h" #include "CSSValueKeywords.h" -#include "Document.h" #include "EventNames.h" #include "Frame.h" #include "FrameView.h" @@ -48,8 +44,8 @@ namespace WebCore { using namespace HTMLNames; -HTMLBodyElement::HTMLBodyElement(const QualifiedName& tagName, Document* doc) - : HTMLElement(tagName, doc) +HTMLBodyElement::HTMLBodyElement(const QualifiedName& tagName, Document* document) + : HTMLElement(tagName, document) { ASSERT(hasTagName(bodyTag)); } @@ -94,7 +90,7 @@ bool HTMLBodyElement::mapToEntry(const QualifiedName& attrName, MappedAttributeE void HTMLBodyElement::parseMappedAttribute(MappedAttribute *attr) { if (attr->name() == backgroundAttr) { - String url = parseURL(attr->value()); + String url = deprecatedParseURL(attr->value()); if (!url.isEmpty()) addCSSImageProperty(attr, CSSPropertyBackgroundImage, document()->completeURL(url).string()); } else if (attr->name() == marginwidthAttr || attr->name() == leftmarginAttr) { @@ -148,6 +144,8 @@ void HTMLBodyElement::parseMappedAttribute(MappedAttribute *attr) document()->setWindowAttributeEventListener(eventNames().blurEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == onfocusAttr) document()->setWindowAttributeEventListener(eventNames().focusEvent, createAttributeEventListener(document()->frame(), attr)); + else if (attr->name() == onhashchangeAttr) + document()->setWindowAttributeEventListener(eventNames().hashchangeEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == onresizeAttr) document()->setWindowAttributeEventListener(eventNames().resizeEvent, createAttributeEventListener(document()->frame(), attr)); else if (attr->name() == onscrollAttr) @@ -215,16 +213,6 @@ void HTMLBodyElement::setALink(const String& value) setAttribute(alinkAttr, value); } -String HTMLBodyElement::background() const -{ - return getAttribute(backgroundAttr); -} - -void HTMLBodyElement::setBackground(const String& value) -{ - setAttribute(backgroundAttr, value); -} - String HTMLBodyElement::bgColor() const { return getAttribute(bgcolorAttr); @@ -336,7 +324,7 @@ void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const { HTMLElement::addSubresourceAttributeURLs(urls); - addSubresourceURL(urls, document()->completeURL(background())); + addSubresourceURL(urls, document()->completeURL(getAttribute(backgroundAttr))); } void HTMLBodyElement::didMoveToNewOwnerDocument() @@ -351,4 +339,114 @@ void HTMLBodyElement::didMoveToNewOwnerDocument() HTMLElement::didMoveToNewOwnerDocument(); } +EventListener* HTMLBodyElement::onblur() const +{ + return document()->getWindowAttributeEventListener(eventNames().blurEvent); +} + +void HTMLBodyElement::setOnblur(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().blurEvent, eventListener); +} + +EventListener* HTMLBodyElement::onerror() const +{ + return document()->getWindowAttributeEventListener(eventNames().errorEvent); +} + +void HTMLBodyElement::setOnerror(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().errorEvent, eventListener); +} + +EventListener* HTMLBodyElement::onfocus() const +{ + return document()->getWindowAttributeEventListener(eventNames().focusEvent); +} + +void HTMLBodyElement::setOnfocus(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().focusEvent, eventListener); +} + +EventListener* HTMLBodyElement::onload() const +{ + return document()->getWindowAttributeEventListener(eventNames().loadEvent); +} + +void HTMLBodyElement::setOnload(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().loadEvent, eventListener); } + +EventListener* HTMLBodyElement::onbeforeunload() const +{ + return document()->getWindowAttributeEventListener(eventNames().beforeunloadEvent); +} + +void HTMLBodyElement::setOnbeforeunload(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().beforeunloadEvent, eventListener); +} + +EventListener* HTMLBodyElement::onmessage() const +{ + return document()->getWindowAttributeEventListener(eventNames().messageEvent); +} + +void HTMLBodyElement::setOnmessage(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().messageEvent, eventListener); +} + +EventListener* HTMLBodyElement::onoffline() const +{ + return document()->getWindowAttributeEventListener(eventNames().offlineEvent); +} + +void HTMLBodyElement::setOnoffline(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().offlineEvent, eventListener); +} + +EventListener* HTMLBodyElement::ononline() const +{ + return document()->getWindowAttributeEventListener(eventNames().onlineEvent); +} + +void HTMLBodyElement::setOnonline(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().onlineEvent, eventListener); +} + +EventListener* HTMLBodyElement::onresize() const +{ + return document()->getWindowAttributeEventListener(eventNames().resizeEvent); +} + +void HTMLBodyElement::setOnresize(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().resizeEvent, eventListener); +} + +EventListener* HTMLBodyElement::onstorage() const +{ + return document()->getWindowAttributeEventListener(eventNames().storageEvent); +} + +void HTMLBodyElement::setOnstorage(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().storageEvent, eventListener); +} + +EventListener* HTMLBodyElement::onunload() const +{ + return document()->getWindowAttributeEventListener(eventNames().unloadEvent); +} + +void HTMLBodyElement::setOnunload(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().unloadEvent, eventListener); +} + +} // namespace WebCore diff --git a/WebCore/html/HTMLBodyElement.h b/WebCore/html/HTMLBodyElement.h index 8e434be..575d562 100644 --- a/WebCore/html/HTMLBodyElement.h +++ b/WebCore/html/HTMLBodyElement.h @@ -1,10 +1,8 @@ /* - * This file is part of the DOM implementation for KDE. - * * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Simon Hausmann <hausmann@kde.org> - * Copyright (C) 2004, 2006 Apple Computer, Inc. + * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -30,12 +28,47 @@ namespace WebCore { -class HTMLBodyElement : public HTMLElement -{ +class HTMLBodyElement : public HTMLElement { public: HTMLBodyElement(const QualifiedName&, Document*); - ~HTMLBodyElement(); + virtual ~HTMLBodyElement(); + + String aLink() const; + void setALink(const String&); + String bgColor() const; + void setBgColor(const String&); + String link() const; + void setLink(const String&); + String text() const; + void setText(const String&); + String vLink() const; + void setVLink(const String&); + virtual EventListener* onblur() const; + virtual void setOnblur(PassRefPtr<EventListener>); + virtual EventListener* onerror() const; + virtual void setOnerror(PassRefPtr<EventListener>); + virtual EventListener* onfocus() const; + virtual void setOnfocus(PassRefPtr<EventListener>); + virtual EventListener* onload() const; + virtual void setOnload(PassRefPtr<EventListener>); + + EventListener* onbeforeunload() const; + void setOnbeforeunload(PassRefPtr<EventListener>); + EventListener* onmessage() const; + void setOnmessage(PassRefPtr<EventListener>); + EventListener* onoffline() const; + void setOnoffline(PassRefPtr<EventListener>); + EventListener* ononline() const; + void setOnonline(PassRefPtr<EventListener>); + EventListener* onresize() const; + void setOnresize(PassRefPtr<EventListener>); + EventListener* onstorage() const; + void setOnstorage(PassRefPtr<EventListener>); + EventListener* onunload() const; + void setOnunload(PassRefPtr<EventListener>); + +private: virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } virtual int tagPriority() const { return 10; } @@ -48,19 +81,6 @@ public: virtual bool isURLAttribute(Attribute*) const; - String aLink() const; - void setALink(const String&); - String background() const; - void setBackground(const String&); - String bgColor() const; - void setBgColor(const String&); - String link() const; - void setLink(const String&); - String text() const; - void setText(const String&); - String vLink() const; - void setVLink(const String&); - virtual int scrollLeft() const; virtual void setScrollLeft(int scrollLeft); @@ -72,11 +92,9 @@ public: virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; -protected: - RefPtr<CSSMutableStyleDeclaration> m_linkDecl; - -private: virtual void didMoveToNewOwnerDocument(); + + RefPtr<CSSMutableStyleDeclaration> m_linkDecl; }; } //namespace diff --git a/WebCore/html/HTMLBodyElement.idl b/WebCore/html/HTMLBodyElement.idl index c639183..097b4ac 100644 --- a/WebCore/html/HTMLBodyElement.idl +++ b/WebCore/html/HTMLBodyElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> * * This library is free software; you can redistribute it and/or @@ -25,12 +25,33 @@ module html { InterfaceUUID=4789afc6-2d9e-4f3b-8c27-12abc9d4a014, ImplementationUUID=d2e16911-2f7e-4d58-a92c-94700d445b38 ] HTMLBodyElement : HTMLElement { - attribute [ConvertNullToNullString] DOMString aLink; - attribute [ConvertNullToNullString] DOMString background; - attribute [ConvertNullToNullString] DOMString bgColor; - attribute [ConvertNullToNullString] DOMString link; - attribute [ConvertNullToNullString] DOMString text; - attribute [ConvertNullToNullString] DOMString vLink; + attribute [ConvertNullToNullString, Reflect=alink] DOMString aLink; + attribute [ConvertNullToNullString, Reflect] DOMString background; + attribute [ConvertNullToNullString, Reflect=bgcolor] DOMString bgColor; + attribute [ConvertNullToNullString, Reflect] DOMString link; + attribute [ConvertNullToNullString, Reflect] DOMString text; + attribute [ConvertNullToNullString, Reflect=vlink] DOMString vLink; + +#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C +#if !defined(LANGUAGE_COM) || !LANGUAGE_COM + // Event handler attributes + attribute [DontEnum] EventListener onbeforeunload; + attribute [DontEnum] EventListener onmessage; + attribute [DontEnum] EventListener onoffline; + attribute [DontEnum] EventListener ononline; + attribute [DontEnum] EventListener onresize; + attribute [DontEnum] EventListener onstorage; + attribute [DontEnum] EventListener onunload; + + // Not implemented yet. + // attribute [DontEnum] EventListener onafterprint; + // attribute [DontEnum] EventListener onbeforeprint; + // attribute [DontEnum] EventListener onhashchange; + // attribute [DontEnum] EventListener onpopstate; + // attribute [DontEnum] EventListener onredo; + // attribute [DontEnum] EventListener onundo; +#endif +#endif }; } diff --git a/WebCore/html/HTMLButtonElement.h b/WebCore/html/HTMLButtonElement.h index b1d744c..f5b9b62 100644 --- a/WebCore/html/HTMLButtonElement.h +++ b/WebCore/html/HTMLButtonElement.h @@ -61,6 +61,7 @@ public: private: enum Type { SUBMIT, RESET, BUTTON }; + virtual bool isOptionalFormControl() const { return true; } Type m_type; bool m_activeSubmit; diff --git a/WebCore/html/HTMLButtonElement.idl b/WebCore/html/HTMLButtonElement.idl index 028e92b..5fd0075 100644 --- a/WebCore/html/HTMLButtonElement.idl +++ b/WebCore/html/HTMLButtonElement.idl @@ -26,6 +26,9 @@ module html { ImplementationUUID=1be13b5f-40df-4550-b70e-8c805e546cad ] HTMLButtonElement : HTMLElement { readonly attribute HTMLFormElement form; +#if !defined(LANGUAGE_COM) || !LANGUAGE_COM + readonly attribute ValidityState validity; +#endif attribute [ConvertNullToNullString] DOMString accessKey; attribute boolean disabled; attribute boolean autofocus; @@ -33,6 +36,7 @@ module html { readonly attribute DOMString type; attribute [ConvertNullToNullString] DOMString value; readonly attribute boolean willValidate; + void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error); void click(); }; diff --git a/WebCore/html/HTMLCanvasElement.cpp b/WebCore/html/HTMLCanvasElement.cpp index 9e635e7..203579b 100644 --- a/WebCore/html/HTMLCanvasElement.cpp +++ b/WebCore/html/HTMLCanvasElement.cpp @@ -195,14 +195,15 @@ void HTMLCanvasElement::reset() if (m_2DContext) m_2DContext->reset(); - if (RenderObject* ro = renderer()) + if (RenderObject* renderer = this->renderer()) { if (m_rendererIsCanvas) { if (oldSize != m_size) - static_cast<RenderHTMLCanvas*>(ro)->canvasSizeChanged(); + toRenderHTMLCanvas(renderer)->canvasSizeChanged(); if (hadImageBuffer) - ro->repaint(); + renderer->repaint(); } - + } + if (m_observer) m_observer->canvasResized(this); } @@ -259,7 +260,7 @@ void HTMLCanvasElement::createImageBuffer() const if (!size.width() || !size.height()) return; - m_imageBuffer = ImageBuffer::create(size, false); + m_imageBuffer = ImageBuffer::create(size); // The convertLogicalToDevice MaxCanvasArea check should prevent common cases // where ImageBuffer::create() returns NULL, however we could still be low on memory. if (!m_imageBuffer) diff --git a/WebCore/html/HTMLDListElement.h b/WebCore/html/HTMLDListElement.h index 8925e6b..49c944b 100644 --- a/WebCore/html/HTMLDListElement.h +++ b/WebCore/html/HTMLDListElement.h @@ -26,8 +26,7 @@ namespace WebCore { -class HTMLDListElement : public HTMLElement -{ +class HTMLDListElement : public HTMLElement { public: HTMLDListElement(const QualifiedName&, Document*); diff --git a/WebCore/html/HTMLDataGridCellElement.cpp b/WebCore/html/HTMLDataGridCellElement.cpp new file mode 100644 index 0000000..bad8929 --- /dev/null +++ b/WebCore/html/HTMLDataGridCellElement.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(DATAGRID) + +#include "HTMLDataGridCellElement.h" + +#include "HTMLNames.h" +#include "Text.h" + +namespace WebCore { + +using namespace HTMLNames; + +HTMLDataGridCellElement::HTMLDataGridCellElement(const QualifiedName& name, Document* doc) + : HTMLElement(name, doc) +{ +} + +String HTMLDataGridCellElement::label() const +{ + return getAttribute(labelAttr); +} + +void HTMLDataGridCellElement::setLabel(const String& label) +{ + setAttribute(labelAttr, label); +} + +bool HTMLDataGridCellElement::focused() const +{ + return hasAttribute(focusedAttr); +} + +void HTMLDataGridCellElement::setFocused(bool focused) +{ + setAttribute(focusedAttr, focused ? "" : 0); +} + +bool HTMLDataGridCellElement::checked() const +{ + return hasAttribute(checkedAttr); +} + +void HTMLDataGridCellElement::setChecked(bool checked) +{ + setAttribute(checkedAttr, checked ? "" : 0); +} + +bool HTMLDataGridCellElement::indeterminate() const +{ + return hasAttribute(indeterminateAttr); +} + +void HTMLDataGridCellElement::setIndeterminate(bool indeterminate) +{ + setAttribute(indeterminateAttr, indeterminate ? "" : 0); +} + +float HTMLDataGridCellElement::progress() const +{ + return getAttribute(progressAttr).toInt(); +} + +void HTMLDataGridCellElement::setProgress(float progress) +{ + setAttribute(progressAttr, String::number(progress)); +} + +} // namespace WebCore + +#endif diff --git a/WebCore/html/HTMLDataGridCellElement.h b/WebCore/html/HTMLDataGridCellElement.h new file mode 100644 index 0000000..270835c --- /dev/null +++ b/WebCore/html/HTMLDataGridCellElement.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef HTMLDataGridCellElement_h +#define HTMLDataGridCellElement_h + +#if ENABLE(DATAGRID) + +#include "HTMLElement.h" + +namespace WebCore { + +class HTMLDataGridCellElement : public HTMLElement { +public: + HTMLDataGridCellElement(const QualifiedName&, Document*); + + virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } + virtual int tagPriority() const { return 0; } + + String label() const; + void setLabel(const String&); + + bool focused() const; + void setFocused(bool); + + bool checked() const; + void setChecked(bool); + + bool indeterminate() const; + void setIndeterminate(bool); + + float progress() const; + void setProgress(float); +}; + +} // namespace WebCore + +#endif + +#endif // HTMLDataGridCellElement_h diff --git a/WebCore/html/HTMLDataGridCellElement.idl b/WebCore/html/HTMLDataGridCellElement.idl new file mode 100644 index 0000000..c7c51bc --- /dev/null +++ b/WebCore/html/HTMLDataGridCellElement.idl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +module html { + + interface [ + GenerateConstructor, + Conditional=DATAGRID + ] HTMLDataGridCellElement : HTMLElement { + attribute DOMString label; // The text to display in the column, assuming the type supports text. + + attribute boolean focused; // Whether or not this cell is currently focused. + + attribute boolean checked; // The checked state of the column, assuming the type of the column is checkbox. + attribute boolean indeterminate; // If the checked state is indeterminate. + + attribute float progress; // For progress cells, a value from 0-1.0 indicating the state of progress. + }; + +} diff --git a/WebCore/html/HTMLDataGridColElement.cpp b/WebCore/html/HTMLDataGridColElement.cpp new file mode 100644 index 0000000..8398545 --- /dev/null +++ b/WebCore/html/HTMLDataGridColElement.cpp @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(DATAGRID) + +#include "DataGridColumn.h" +#include "HTMLDataGridElement.h" +#include "HTMLDataGridColElement.h" +#include "HTMLNames.h" +#include "MappedAttribute.h" +#include "Text.h" + +namespace WebCore { + +using namespace HTMLNames; + +HTMLDataGridColElement::HTMLDataGridColElement(const QualifiedName& name, Document* doc) + : HTMLElement(name, doc) + , m_dataGrid(0) +{ +} + +HTMLDataGridElement* HTMLDataGridColElement::findDataGridAncestor() const +{ + if (parent() && parent()->hasTagName(datagridTag)) + return static_cast<HTMLDataGridElement*>(parent()); + return 0; +} + +void HTMLDataGridColElement::ensureColumn() +{ + if (m_column) + return; + m_column = DataGridColumn::create(getAttribute(idAttr), label(), type(), primary(), sortable()); +} + +void HTMLDataGridColElement::insertedIntoTree(bool deep) +{ + HTMLElement::insertedIntoTree(deep); + if (dataGrid()) // We're connected to a datagrid already. + return; + m_dataGrid = findDataGridAncestor(); + if (dataGrid() && dataGrid()->dataSource()->isDOMDataGridDataSource()) { + ensureColumn(); + m_dataGrid->columns()->add(column()); // FIXME: Deal with ordering issues (complicated, since columns can be made outside the DOM). + } +} + +void HTMLDataGridColElement::removedFromTree(bool deep) +{ + HTMLElement::removedFromTree(deep); + if (dataGrid() && dataGrid()->dataSource()->isDOMDataGridDataSource()) { + HTMLDataGridElement* grid = findDataGridAncestor(); + if (!grid && column()) { + dataGrid()->columns()->remove(column()); + m_dataGrid = 0; + } + } +} + +String HTMLDataGridColElement::label() const +{ + return getAttribute(labelAttr); +} + +void HTMLDataGridColElement::setLabel(const String& label) +{ + setAttribute(labelAttr, label); +} + +String HTMLDataGridColElement::type() const +{ + return getAttribute(typeAttr); +} + +void HTMLDataGridColElement::setType(const String& type) +{ + setAttribute(typeAttr, type); +} + +unsigned short HTMLDataGridColElement::sortable() const +{ + if (!hasAttribute(sortableAttr)) + return 2; + return getAttribute(sortableAttr).toInt(0); +} + +void HTMLDataGridColElement::setSortable(unsigned short sortable) +{ + setAttribute(sortableAttr, String::number(sortable)); +} + +unsigned short HTMLDataGridColElement::sortDirection() const +{ + String sortDirection = getAttribute(sortdirectionAttr); + if (equalIgnoringCase(sortDirection, "ascending")) + return 1; + if (equalIgnoringCase(sortDirection, "descending")) + return 2; + return 0; +} + +void HTMLDataGridColElement::setSortDirection(unsigned short sortDirection) +{ + // FIXME: Check sortable rules. + if (sortDirection == 0) + setAttribute(sortdirectionAttr, "natural"); + else if (sortDirection == 1) + setAttribute(sortdirectionAttr, "ascending"); + else if (sortDirection == 2) + setAttribute(sortdirectionAttr, "descending"); +} + +bool HTMLDataGridColElement::primary() const +{ + return hasAttribute(primaryAttr); +} + +void HTMLDataGridColElement::setPrimary(bool primary) +{ + setAttribute(primaryAttr, primary ? "" : 0); +} + +void HTMLDataGridColElement::parseMappedAttribute(MappedAttribute* attr) +{ + HTMLElement::parseMappedAttribute(attr); + + if (!column()) + return; + + if (attr->name() == labelAttr) + column()->setLabel(label()); + else if (attr->name() == typeAttr) + column()->setType(type()); + else if (attr->name() == primaryAttr) + column()->setPrimary(primary()); + else if (attr->name() == sortableAttr) + column()->setSortable(sortable()); + else if (attr->name() == sortdirectionAttr) + column()->setSortDirection(sortDirection()); + else if (attr->name() == idAttr) + column()->setId(getAttribute(idAttr)); +} + +} // namespace WebCore + +#endif diff --git a/WebCore/html/HTMLDataGridColElement.h b/WebCore/html/HTMLDataGridColElement.h new file mode 100644 index 0000000..d91ec51 --- /dev/null +++ b/WebCore/html/HTMLDataGridColElement.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef HTMLDataGridColElement_h +#define HTMLDataGridColElement_h + +#if ENABLE(DATAGRID) + +#include "DataGridColumn.h" +#include "HTMLElement.h" + +namespace WebCore { + +class HTMLDataGridElement; + +class HTMLDataGridColElement : public HTMLElement { +public: + HTMLDataGridColElement(const QualifiedName&, Document*); + + virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } + virtual int tagPriority() const { return 0; } + virtual void insertedIntoTree(bool /*deep*/); + virtual void removedFromTree(bool /*deep*/); + virtual void parseMappedAttribute(MappedAttribute*); + + String label() const; + void setLabel(const String&); + + String type() const; + void setType(const String&); + + unsigned short sortable() const; + void setSortable(unsigned short); + + unsigned short sortDirection() const; + void setSortDirection(unsigned short); + + bool primary() const; + void setPrimary(bool); + + DataGridColumn* column() const { return m_column.get(); } + void setColumn(PassRefPtr<DataGridColumn> col) { m_column = col; } + +private: + HTMLDataGridElement* dataGrid() const { return m_dataGrid; } + HTMLDataGridElement* findDataGridAncestor() const; + void ensureColumn(); + + RefPtr<DataGridColumn> m_column; + HTMLDataGridElement* m_dataGrid; // Not refcounted. We will null out our reference if we get removed from the grid. +}; + +} // namespace WebCore + +#endif + +#endif // HTMLDataGridColElement_h diff --git a/WebCore/html/HTMLDataGridColElement.idl b/WebCore/html/HTMLDataGridColElement.idl new file mode 100644 index 0000000..5861039 --- /dev/null +++ b/WebCore/html/HTMLDataGridColElement.idl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +module html { + + interface [ + GenerateConstructor, + Conditional=DATAGRID + ] HTMLDataGridColElement : HTMLElement { + attribute DOMString label; // The text to display in the column. + attribute DOMString type; // The type of data displayed in this column. + + attribute unsigned short sortable; // Whether or not the column can be sorted. Values are none, ascending/descending, and ascending/descending/na + attribute unsigned short sortDirection; // The sort direction for the column. Valid values are ascending, descending and natural (no sort applied). + + attribute boolean primary; // Whether or not this is the primary column of the tree (this will be where the disclosure triangle and connecting tree lines will display) + }; + +} diff --git a/WebCore/html/HTMLDataGridElement.cpp b/WebCore/html/HTMLDataGridElement.cpp new file mode 100644 index 0000000..bb1f4a6 --- /dev/null +++ b/WebCore/html/HTMLDataGridElement.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(DATAGRID) + +#include "HTMLDataGridElement.h" + +#include "DOMDataGridDataSource.h" +#include "HTMLNames.h" +#include "RenderDataGrid.h" +#include "Text.h" + +namespace WebCore { + +using namespace HTMLNames; + +HTMLDataGridElement::HTMLDataGridElement(const QualifiedName& tagName, Document* document) + : HTMLElement(tagName, document) + , m_columns(DataGridColumnList::create(this)) +{ + setDataSource(DOMDataGridDataSource::create()); +} + +HTMLDataGridElement::~HTMLDataGridElement() +{ + m_columns->clearDataGrid(); +} + +bool HTMLDataGridElement::checkDTD(const Node* newChild) +{ + if (newChild->isTextNode()) + return static_cast<const Text*>(newChild)->containsOnlyWhitespace(); + return newChild->hasTagName(dcolTag) || newChild->hasTagName(drowTag); +} + +RenderObject* HTMLDataGridElement::createRenderer(RenderArena* arena, RenderStyle*) +{ + return new (arena) RenderDataGrid(this); +} + +bool HTMLDataGridElement::autofocus() const +{ + return hasAttribute(autofocusAttr); +} + +void HTMLDataGridElement::setAutofocus(bool autofocus) +{ + setAttribute(autofocusAttr, autofocus ? "" : 0); +} + +bool HTMLDataGridElement::disabled() const +{ + return hasAttribute(disabledAttr); +} + +void HTMLDataGridElement::setDisabled(bool disabled) +{ + setAttribute(disabledAttr, disabled ? "" : 0); +} + +bool HTMLDataGridElement::multiple() const +{ + return hasAttribute(multipleAttr); +} + +void HTMLDataGridElement::setMultiple(bool multiple) +{ + setAttribute(multipleAttr, multiple ? "" : 0); +} + +void HTMLDataGridElement::setDataSource(PassRefPtr<DataGridDataSource> ds) +{ + if (m_dataSource == ds) + return; + + RefPtr<DataGridDataSource> dataSource = ds; + if (!dataSource) + dataSource = DOMDataGridDataSource::create(); + m_dataSource = dataSource; + + // Always clear our columns when a data source changes. + // The register callback will rebuild the columns. + m_columns->clear(); +} + +DataGridDataSource* HTMLDataGridElement::dataSource() const +{ + ASSERT(m_dataSource); + return m_dataSource.get(); +} + +} // namespace WebCore + +#endif // ENABLE(DATAGRID) diff --git a/WebCore/html/HTMLDataGridElement.h b/WebCore/html/HTMLDataGridElement.h new file mode 100644 index 0000000..94672c1 --- /dev/null +++ b/WebCore/html/HTMLDataGridElement.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef HTMLDataGridElement_h +#define HTMLDataGridElement_h + +#if ENABLE(DATAGRID) + +#include "DataGridColumnList.h" +#include "DataGridDataSource.h" +#include "HTMLElement.h" +#include "Timer.h" + +namespace WebCore { + +class HTMLDataGridElement : public HTMLElement { +public: + HTMLDataGridElement(const QualifiedName&, Document*); + virtual ~HTMLDataGridElement(); + + virtual int tagPriority() const { return 6; } // Same as <select>s + virtual bool checkDTD(const Node*); + + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + + bool autofocus() const; + void setAutofocus(bool); + + bool disabled() const; + void setDisabled(bool); + + bool multiple() const; + void setMultiple(bool); + + void setDataSource(PassRefPtr<DataGridDataSource>); + DataGridDataSource* dataSource() const; + + DataGridColumnList* columns() const { return m_columns.get(); } + +private: + RefPtr<DataGridDataSource> m_dataSource; + RefPtr<DataGridColumnList> m_columns; +}; + +} // namespace WebCore + +#endif + +#endif // HTMLDataGridElement_h diff --git a/WebCore/html/HTMLDataGridElement.idl b/WebCore/html/HTMLDataGridElement.idl new file mode 100644 index 0000000..c9e6d9d --- /dev/null +++ b/WebCore/html/HTMLDataGridElement.idl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +module html { + + interface [ + GenerateConstructor, + Conditional=DATAGRID + ] HTMLDataGridElement : HTMLElement { + attribute [Custom] DataGridDataSource dataSource; + + readonly attribute DataGridColumnList columns; + + attribute boolean autofocus; // Whether or not the datagrid should autofocus. + attribute boolean disabled; // Whether or not the datagrid can be interacted with. + attribute boolean multiple; // Whether or not the datagrid supports multiple selection. + }; + +} diff --git a/WebCore/html/HTMLDataGridRowElement.cpp b/WebCore/html/HTMLDataGridRowElement.cpp new file mode 100644 index 0000000..c958cbd --- /dev/null +++ b/WebCore/html/HTMLDataGridRowElement.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(DATAGRID) + +#include "HTMLDataGridRowElement.h" + +#include "HTMLNames.h" +#include "Text.h" + +namespace WebCore { + +using namespace HTMLNames; + +HTMLDataGridRowElement::HTMLDataGridRowElement(const QualifiedName& name, Document* doc) + : HTMLElement(name, doc) +{ +} + +bool HTMLDataGridRowElement::checkDTD(const Node* newChild) +{ + if (newChild->isTextNode()) + return static_cast<const Text*>(newChild)->containsOnlyWhitespace(); + return newChild->hasTagName(drowTag) || newChild->hasTagName(dcellTag); +} + +bool HTMLDataGridRowElement::selected() const +{ + return hasAttribute(selectedAttr); +} + +void HTMLDataGridRowElement::setSelected(bool selected) +{ + setAttribute(selectedAttr, selected ? "" : 0); +} + +bool HTMLDataGridRowElement::focused() const +{ + return hasAttribute(focusedAttr); +} + +void HTMLDataGridRowElement::setFocused(bool focused) +{ + setAttribute(focusedAttr, focused ? "" : 0); +} + +bool HTMLDataGridRowElement::expanded() const +{ + return hasAttribute(expandedAttr); +} + +void HTMLDataGridRowElement::setExpanded(bool expanded) +{ + setAttribute(expandedAttr, expanded ? "" : 0); +} + +} // namespace WebCore + +#endif diff --git a/WebCore/html/HTMLDataGridRowElement.h b/WebCore/html/HTMLDataGridRowElement.h new file mode 100644 index 0000000..eac33e6 --- /dev/null +++ b/WebCore/html/HTMLDataGridRowElement.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef HTMLDataGridRowElement_h +#define HTMLDataGridRowElement_h + +#if ENABLE(DATAGRID) + +#include "HTMLElement.h" + +namespace WebCore { + +class HTMLDataGridRowElement : public HTMLElement { +public: + HTMLDataGridRowElement(const QualifiedName&, Document*); + + virtual int tagPriority() const { return 2; } // Same as <option>s. + virtual bool checkDTD(const Node*); + + bool selected() const; + void setSelected(bool); + + bool focused() const; + void setFocused(bool); + + bool expanded() const; + void setExpanded(bool); +}; + +} // namespace WebCore + +#endif + +#endif // HTMLDataGridRowElement_h diff --git a/WebCore/html/HTMLDataGridRowElement.idl b/WebCore/html/HTMLDataGridRowElement.idl new file mode 100644 index 0000000..f6954af --- /dev/null +++ b/WebCore/html/HTMLDataGridRowElement.idl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +module html { + + interface [ + GenerateConstructor, + Conditional=DATAGRID + ] HTMLDataGridRowElement : HTMLElement { + attribute boolean selected; // Whether or not the row is currently selected. + attribute boolean focused; // Whether or not the row is the current object in the tree for keyboard navigation (or as the principal item of a multiple selection). + + attribute boolean expanded; // Whether or not the row is open (if it is, child rows will be shown). + }; + +} diff --git a/WebCore/html/HTMLDirectoryElement.h b/WebCore/html/HTMLDirectoryElement.h index 6be4c22..eead141 100644 --- a/WebCore/html/HTMLDirectoryElement.h +++ b/WebCore/html/HTMLDirectoryElement.h @@ -26,8 +26,7 @@ namespace WebCore { -class HTMLDirectoryElement : public HTMLElement -{ +class HTMLDirectoryElement : public HTMLElement { public: HTMLDirectoryElement(const QualifiedName&, Document*); diff --git a/WebCore/html/HTMLDocument.cpp b/WebCore/html/HTMLDocument.cpp index 778c5ae..d60d3fa 100644 --- a/WebCore/html/HTMLDocument.cpp +++ b/WebCore/html/HTMLDocument.cpp @@ -157,9 +157,12 @@ Element* HTMLDocument::activeElement() bool HTMLDocument::hasFocus() { - if (!page()->focusController()->isActive()) + Page* page = this->page(); + if (!page) return false; - if (Frame* focusedFrame = page()->focusController()->focusedFrame()) { + if (!page->focusController()->isActive()) + return false; + if (Frame* focusedFrame = page->focusController()->focusedFrame()) { if (focusedFrame->tree()->isDescendantOf(frame())) return true; } @@ -287,9 +290,8 @@ void HTMLDocument::releaseEvents() Tokenizer *HTMLDocument::createTokenizer() { bool reportErrors = false; - if (frame()) - if (Page* page = frame()->page()) - reportErrors = page->inspectorController()->windowVisible(); + if (Page* page = this->page()) + reportErrors = page->inspectorController()->windowVisible(); return new HTMLTokenizer(this, reportErrors); } @@ -313,34 +315,18 @@ PassRefPtr<Element> HTMLDocument::createElement(const AtomicString& name, Except return HTMLElementFactory::createHTMLElement(QualifiedName(nullAtom, lowerName, xhtmlNamespaceURI), this, 0, false); } -static void addItemToMap(HTMLDocument::NameCountMap& map, const AtomicString& name) +static void addItemToMap(HashCountedSet<AtomicStringImpl*>& map, const AtomicString& name) { if (name.isEmpty()) return; - - HTMLDocument::NameCountMap::iterator it = map.find(name.impl()); - if (it == map.end()) - map.set(name.impl(), 1); - else - ++(it->second); + map.add(name.impl()); } -static void removeItemFromMap(HTMLDocument::NameCountMap& map, const AtomicString& name) +static void removeItemFromMap(HashCountedSet<AtomicStringImpl*>& map, const AtomicString& name) { if (name.isEmpty()) return; - - HTMLDocument::NameCountMap::iterator it = map.find(name.impl()); - if (it == map.end()) - return; - - int oldVal = it->second; - ASSERT(oldVal != 0); - int newVal = oldVal - 1; - if (newVal == 0) - map.remove(it); - else - it->second = newVal; + map.remove(name.impl()); } void HTMLDocument::addNamedItem(const AtomicString& name) @@ -348,7 +334,7 @@ void HTMLDocument::addNamedItem(const AtomicString& name) addItemToMap(m_namedItemCounts, name); } -void HTMLDocument::removeNamedItem(const AtomicString &name) +void HTMLDocument::removeNamedItem(const AtomicString& name) { removeItemFromMap(m_namedItemCounts, name); } diff --git a/WebCore/html/HTMLDocument.h b/WebCore/html/HTMLDocument.h index ab5da50..eda7593 100644 --- a/WebCore/html/HTMLDocument.h +++ b/WebCore/html/HTMLDocument.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) - * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -23,8 +23,10 @@ #ifndef HTMLDocument_h #define HTMLDocument_h +#include "AtomicStringHash.h" #include "CachedResourceClient.h" #include "Document.h" +#include <wtf/HashCountedSet.h> namespace WebCore { @@ -81,8 +83,6 @@ public: void removeExtraNamedItem(const AtomicString& name); bool hasExtraNamedItem(AtomicStringImpl* name); - typedef HashMap<AtomicStringImpl*, int> NameCountMap; - protected: HTMLDocument(Frame*); @@ -92,8 +92,8 @@ private: virtual Tokenizer* createTokenizer(); virtual void determineParseMode(); - NameCountMap m_namedItemCounts; - NameCountMap m_extraNamedItemCounts; + HashCountedSet<AtomicStringImpl*> m_namedItemCounts; + HashCountedSet<AtomicStringImpl*> m_extraNamedItemCounts; }; inline bool HTMLDocument::hasNamedItem(AtomicStringImpl* name) @@ -108,6 +108,6 @@ inline bool HTMLDocument::hasExtraNamedItem(AtomicStringImpl* name) return m_extraNamedItemCounts.contains(name); } -} // namespace +} // namespace WebCore -#endif +#endif // HTMLDocument_h diff --git a/WebCore/html/HTMLElement.cpp b/WebCore/html/HTMLElement.cpp index c50e6ba..b310cad 100644 --- a/WebCore/html/HTMLElement.cpp +++ b/WebCore/html/HTMLElement.cpp @@ -79,7 +79,7 @@ HTMLTagStatus HTMLElement::endTagRequirement() const { if (hasLocalName(wbrTag)) return TagStatusForbidden; - if (hasLocalName(dtTag) || hasLocalName(ddTag)) + if (hasLocalName(dtTag) || hasLocalName(ddTag) || hasLocalName(rpTag) || hasLocalName(rtTag)) return TagStatusOptional; // Same values as <span>. This way custom tag name elements will behave like inline spans. @@ -90,9 +90,9 @@ int HTMLElement::tagPriority() const { if (hasLocalName(wbrTag)) return 0; - if (hasLocalName(addressTag) || hasLocalName(ddTag) || hasLocalName(dtTag) || hasLocalName(noscriptTag)) + if (hasLocalName(addressTag) || hasLocalName(ddTag) || hasLocalName(dtTag) || hasLocalName(noscriptTag) || hasLocalName(rpTag) || hasLocalName(rtTag)) return 3; - if (hasLocalName(centerTag) || hasLocalName(nobrTag)) + if (hasLocalName(centerTag) || hasLocalName(nobrTag) || hasLocalName(rubyTag)) return 5; if (hasLocalName(noembedTag) || hasLocalName(noframesTag)) return 10; @@ -143,6 +143,13 @@ void HTMLElement::parseMappedAttribute(MappedAttribute *attr) } else if (attr->name() == dirAttr) { addCSSProperty(attr, CSSPropertyDirection, attr->value()); addCSSProperty(attr, CSSPropertyUnicodeBidi, hasLocalName(bdoTag) ? CSSValueBidiOverride : CSSValueEmbed); + } else if (attr->name() == draggableAttr) { + const AtomicString& value = attr->value(); + if (equalIgnoringCase(value, "true")) { + addCSSProperty(attr, CSSPropertyWebkitUserDrag, CSSValueElement); + addCSSProperty(attr, CSSPropertyWebkitUserSelect, CSSValueNone); + } else if (equalIgnoringCase(value, "false")) + addCSSProperty(attr, CSSPropertyWebkitUserDrag, CSSValueNone); } // standard events else if (attr->name() == onclickAttr) { @@ -225,6 +232,8 @@ void HTMLElement::parseMappedAttribute(MappedAttribute *attr) } else if (attr->name() == ontouchcancelAttr) { setAttributeEventListener(eventNames().touchcancelEvent, createAttributeEventListener(this, attr)); #endif + } else if (attr->name() == oninputAttr) { + setAttributeEventListener(eventNames().inputEvent, createAttributeEventListener(this, attr)); } } @@ -700,6 +709,16 @@ void HTMLElement::setContentEditable(const String &enabled) setAttribute(contenteditableAttr, enabled.isEmpty() ? "true" : enabled); } +bool HTMLElement::draggable() const +{ + return equalIgnoringCase(getAttribute(draggableAttr), "true"); +} + +void HTMLElement::setDraggable(bool value) +{ + setAttribute(draggableAttr, value ? "true" : "false"); +} + void HTMLElement::click() { dispatchSimulatedClick(0, false, false); @@ -871,6 +890,7 @@ static HashSet<AtomicStringImpl*>* inlineTagList() tagList.add(inputTag.localName().impl()); tagList.add(keygenTag.localName().impl()); tagList.add(selectTag.localName().impl()); + tagList.add(datagridTag.localName().impl()); tagList.add(textareaTag.localName().impl()); tagList.add(labelTag.localName().impl()); tagList.add(buttonTag.localName().impl()); @@ -882,6 +902,9 @@ static HashSet<AtomicStringImpl*>* inlineTagList() tagList.add(audioTag.localName().impl()); tagList.add(videoTag.localName().impl()); #endif + tagList.add(rpTag.localName().impl()); + tagList.add(rtTag.localName().impl()); + tagList.add(rubyTag.localName().impl()); } return &tagList; } diff --git a/WebCore/html/HTMLElement.h b/WebCore/html/HTMLElement.h index 60152cd..21b3bb5 100644 --- a/WebCore/html/HTMLElement.h +++ b/WebCore/html/HTMLElement.h @@ -79,6 +79,9 @@ public: virtual void setContentEditable(MappedAttribute*); virtual void setContentEditable(const String&); + virtual bool draggable() const; + void setDraggable(bool); + void click(); virtual void accessKeyAction(bool sendToAnyElement); diff --git a/WebCore/html/HTMLElement.idl b/WebCore/html/HTMLElement.idl index ed21628..6b9e1d0 100644 --- a/WebCore/html/HTMLElement.idl +++ b/WebCore/html/HTMLElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> * * This library is free software; you can redistribute it and/or @@ -29,13 +29,14 @@ module html { ] HTMLElement : Element { // iht.com relies on id returning the empty string when no id is present. // Other browsers do this as well. So we don't convert null to JS null. - attribute [ConvertNullToNullString] DOMString id; - attribute [ConvertNullToNullString] DOMString title; - attribute [ConvertNullToNullString] DOMString lang; - attribute [ConvertNullToNullString] DOMString dir; - attribute [ConvertNullToNullString] DOMString className; + attribute [ConvertNullToNullString, Reflect] DOMString id; + attribute [ConvertNullToNullString, Reflect] DOMString title; + attribute [ConvertNullToNullString, Reflect] DOMString lang; + attribute [ConvertNullToNullString, Reflect] DOMString dir; + attribute [ConvertNullToNullString, Reflect=class] DOMString className; attribute long tabIndex; + attribute boolean draggable; // Extensions attribute [ConvertNullToNullString] DOMString innerHTML diff --git a/WebCore/html/HTMLElementsAllInOne.cpp b/WebCore/html/HTMLElementsAllInOne.cpp index dad548c..f9c970a 100644 --- a/WebCore/html/HTMLElementsAllInOne.cpp +++ b/WebCore/html/HTMLElementsAllInOne.cpp @@ -42,6 +42,10 @@ #include "HTMLBodyElement.cpp" #include "HTMLButtonElement.cpp" #include "HTMLCanvasElement.cpp" +#include "HTMLDataGridElement.cpp" +#include "HTMLDataGridCellElement.cpp" +#include "HTMLDataGridColElement.cpp" +#include "HTMLDataGridRowElement.cpp" #include "HTMLDListElement.cpp" #include "HTMLDirectoryElement.cpp" #include "HTMLDivElement.cpp" diff --git a/WebCore/html/HTMLEmbedElement.cpp b/WebCore/html/HTMLEmbedElement.cpp index 2500dd6..3f6db9a 100644 --- a/WebCore/html/HTMLEmbedElement.cpp +++ b/WebCore/html/HTMLEmbedElement.cpp @@ -61,7 +61,7 @@ static inline RenderWidget* findWidgetRenderer(const Node* n) while (n && !n->hasTagName(objectTag)); if (n && n->renderer() && n->renderer()->isWidget()) - return static_cast<RenderWidget*>(n->renderer()); + return toRenderWidget(n->renderer()); return 0; } @@ -98,9 +98,9 @@ void HTMLEmbedElement::parseMappedAttribute(MappedAttribute* attr) if (!isImageType() && m_imageLoader) m_imageLoader.clear(); } else if (attr->name() == codeAttr) - m_url = parseURL(value.string()); + m_url = deprecatedParseURL(value.string()); else if (attr->name() == srcAttr) { - m_url = parseURL(value.string()); + m_url = deprecatedParseURL(value.string()); if (renderer() && isImageType()) { if (!m_imageLoader) m_imageLoader.set(new HTMLImageLoader(this)); @@ -182,7 +182,7 @@ void HTMLEmbedElement::updateWidget() { document()->updateStyleIfNeeded(); if (m_needWidgetUpdate && renderer() && !isImageType()) - static_cast<RenderPartObject*>(renderer())->updateWidget(true); + toRenderPartObject(renderer())->updateWidget(true); } void HTMLEmbedElement::insertedIntoDocument() diff --git a/WebCore/html/HTMLEmbedElement.idl b/WebCore/html/HTMLEmbedElement.idl index ecf8a96..a38402c 100644 --- a/WebCore/html/HTMLEmbedElement.idl +++ b/WebCore/html/HTMLEmbedElement.idl @@ -22,8 +22,8 @@ module html { interface [ GenerateConstructor, - CustomPutFunction, - CustomGetOwnPropertySlot, + DelegatingPutFunction, + DelegatingGetOwnPropertySlot, CustomCall, HasOverridingNameGetter, InterfaceUUID=18f9bd58-6bb3-4b5c-aa30-6da13adfc91e, diff --git a/WebCore/html/HTMLFieldSetElement.cpp b/WebCore/html/HTMLFieldSetElement.cpp index eb8d4ed..eb83173 100644 --- a/WebCore/html/HTMLFieldSetElement.cpp +++ b/WebCore/html/HTMLFieldSetElement.cpp @@ -34,7 +34,7 @@ namespace WebCore { using namespace HTMLNames; HTMLFieldSetElement::HTMLFieldSetElement(const QualifiedName& tagName, Document *doc, HTMLFormElement *f) - : HTMLFormControlElement(tagName, doc, f) + : HTMLFormControlElement(tagName, doc, f) { ASSERT(hasTagName(fieldsetTag)); } diff --git a/WebCore/html/HTMLFieldSetElement.idl b/WebCore/html/HTMLFieldSetElement.idl index c48f8d6..4d11304 100644 --- a/WebCore/html/HTMLFieldSetElement.idl +++ b/WebCore/html/HTMLFieldSetElement.idl @@ -25,7 +25,11 @@ module html { ImplementationUUID=93573758-96db-415d-9bdc-ee7238604094 ] HTMLFieldSetElement : HTMLElement { readonly attribute HTMLFormElement form; +#if !defined(LANGUAGE_COM) || !LANGUAGE_COM + readonly attribute ValidityState validity; +#endif readonly attribute boolean willValidate; + void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error); }; } diff --git a/WebCore/html/HTMLFormControlElement.cpp b/WebCore/html/HTMLFormControlElement.cpp index 36d20ac..09d91df 100644 --- a/WebCore/html/HTMLFormControlElement.cpp +++ b/WebCore/html/HTMLFormControlElement.cpp @@ -25,6 +25,7 @@ #include "config.h" #include "HTMLFormControlElement.h" +#include "ChromeClient.h" #include "Document.h" #include "EventHandler.h" #include "EventNames.h" @@ -35,8 +36,10 @@ #include "HTMLParser.h" #include "HTMLTokenizer.h" #include "MappedAttribute.h" +#include "Page.h" #include "RenderBox.h" #include "RenderTheme.h" +#include "ValidityState.h" namespace WebCore { @@ -61,6 +64,14 @@ HTMLFormControlElement::~HTMLFormControlElement() m_form->removeFormElement(this); } +ValidityState* HTMLFormControlElement::validity() +{ + if (!m_validityState) + m_validityState = ValidityState::create(this); + + return m_validityState.get(); +} + void HTMLFormControlElement::parseMappedAttribute(MappedAttribute *attr) { if (attr->name() == nameAttr) { @@ -71,7 +82,7 @@ void HTMLFormControlElement::parseMappedAttribute(MappedAttribute *attr) if (oldDisabled != m_disabled) { setNeedsStyleRecalc(); if (renderer() && renderer()->style()->hasAppearance()) - theme()->stateChanged(renderer(), EnabledState); + renderer()->theme()->stateChanged(renderer(), EnabledState); } } else if (attr->name() == readonlyAttr) { bool oldReadOnly = m_readOnly; @@ -79,7 +90,7 @@ void HTMLFormControlElement::parseMappedAttribute(MappedAttribute *attr) if (oldReadOnly != m_readOnly) { setNeedsStyleRecalc(); if (renderer() && renderer()->style()->hasAppearance()) - theme()->stateChanged(renderer(), ReadOnlyState); + renderer()->theme()->stateChanged(renderer(), ReadOnlyState); } } else HTMLElement::parseMappedAttribute(attr); @@ -193,6 +204,16 @@ void HTMLFormControlElement::setAutofocus(bool b) setAttribute(autofocusAttr, b ? "autofocus" : 0); } +bool HTMLFormControlElement::required() const +{ + return hasAttribute(requiredAttr); +} + +void HTMLFormControlElement::setRequired(bool b) +{ + setAttribute(requiredAttr, b ? "required" : 0); +} + void HTMLFormControlElement::recalcStyle(StyleChange change) { HTMLElement::recalcStyle(change); @@ -241,7 +262,28 @@ bool HTMLFormControlElement::willValidate() const // The control is not an output element. return form() && name().length() && !disabled() && !isReadOnlyFormControl(); } + +void HTMLFormControlElement::setCustomValidity(const String& error) +{ + validity()->setCustomErrorMessage(error); +} +void HTMLFormControlElement::dispatchFocusEvent() +{ + if (document()->frame() && document()->frame()->page()) + document()->frame()->page()->chrome()->client()->formDidFocus(this); + + HTMLElement::dispatchFocusEvent(); +} + +void HTMLFormControlElement::dispatchBlurEvent() +{ + if (document()->frame() && document()->frame()->page()) + document()->frame()->page()->chrome()->client()->formDidBlur(this); + + HTMLElement::dispatchBlurEvent(); +} + bool HTMLFormControlElement::supportsFocus() const { return isFocusable() || (!disabled() && !document()->haveStylesheetsLoaded()); diff --git a/WebCore/html/HTMLFormControlElement.h b/WebCore/html/HTMLFormControlElement.h index 0a7bbd1..a30f46c 100644 --- a/WebCore/html/HTMLFormControlElement.h +++ b/WebCore/html/HTMLFormControlElement.h @@ -30,6 +30,7 @@ namespace WebCore { class FormDataList; class HTMLFormElement; +class ValidityState; class HTMLFormControlElement : public HTMLElement { public: @@ -40,6 +41,7 @@ public: virtual int tagPriority() const { return 1; } HTMLFormElement* form() const { return m_form; } + virtual ValidityState* validity(); virtual bool isTextFormControl() const { return false; } virtual bool isEnabledFormControl() const { return !disabled(); } @@ -72,6 +74,9 @@ public: virtual bool autofocus() const; void setAutofocus(bool); + bool required() const; + void setRequired(bool); + virtual void recalcStyle(StyleChange); virtual const AtomicString& formControlName() const; @@ -97,9 +102,16 @@ public: virtual short tabIndex() const; virtual bool willValidate() const; + void setCustomValidity(const String&); + + virtual bool valueMissing() const { return false; } + virtual bool patternMismatch() const { return false; } void formDestroyed() { m_form = 0; } + virtual void dispatchFocusEvent(); + virtual void dispatchBlurEvent(); + protected: void removeFromForm(); @@ -107,6 +119,7 @@ private: virtual HTMLFormElement* virtualForm() const; HTMLFormElement* m_form; + RefPtr<ValidityState> m_validityState; bool m_disabled; bool m_readOnly; bool m_valueMatchesRenderer; diff --git a/WebCore/html/HTMLFormElement.cpp b/WebCore/html/HTMLFormElement.cpp index 64cac37..54986b0 100644 --- a/WebCore/html/HTMLFormElement.cpp +++ b/WebCore/html/HTMLFormElement.cpp @@ -328,7 +328,7 @@ static void transferMailtoPostFormDataToURL(RefPtr<FormData>& data, KURL& url, c url.setQuery(query); } -void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool lockHistory, bool lockBackForwardList) +void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool lockHistory) { FrameView* view = document()->view(); Frame* frame = document()->frame(); @@ -389,14 +389,14 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool lockH m_url = url.string(); } - frame->loader()->submitForm("POST", m_url, data.release(), m_target, m_formDataBuilder.encodingType(), String(), lockHistory, lockBackForwardList, event, formState.release()); + frame->loader()->submitForm("POST", m_url, data.release(), m_target, m_formDataBuilder.encodingType(), String(), lockHistory, event, formState.release()); } else { Vector<char> boundary = m_formDataBuilder.generateUniqueBoundaryString(); - frame->loader()->submitForm("POST", m_url, createFormData(boundary.data()), m_target, m_formDataBuilder.encodingType(), boundary.data(), lockHistory, lockBackForwardList, event, formState.release()); + frame->loader()->submitForm("POST", m_url, createFormData(boundary.data()), m_target, m_formDataBuilder.encodingType(), boundary.data(), lockHistory, event, formState.release()); } } else { m_formDataBuilder.setIsMultiPartForm(false); - frame->loader()->submitForm("GET", m_url, createFormData(CString()), m_target, String(), String(), lockHistory, lockBackForwardList, event, formState.release()); + frame->loader()->submitForm("GET", m_url, createFormData(CString()), m_target, String(), String(), lockHistory, event, formState.release()); } if (needButtonActivation && firstSuccessfulSubmitButton) @@ -415,7 +415,7 @@ void HTMLFormElement::reset() // ### DOM2 labels this event as not cancelable, however // common browsers( sick! ) allow it be cancelled. - if ( !dispatchEvent(eventNames().resetEvent,true, true) ) { + if ( !dispatchEvent(eventNames().resetEvent, true, true) ) { m_inreset = false; return; } @@ -429,7 +429,7 @@ void HTMLFormElement::reset() void HTMLFormElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == actionAttr) - m_url = parseURL(attr->value()); + m_url = deprecatedParseURL(attr->value()); else if (attr->name() == targetAttr) m_target = attr->value(); else if (attr->name() == methodAttr) diff --git a/WebCore/html/HTMLFormElement.h b/WebCore/html/HTMLFormElement.h index d08e16c..6b7812a 100644 --- a/WebCore/html/HTMLFormElement.h +++ b/WebCore/html/HTMLFormElement.h @@ -78,7 +78,7 @@ public: void removeImgElement(HTMLImageElement*); bool prepareSubmit(Event*); - void submit(Event* = 0, bool activateSubmitButton = false, bool lockHistory = false, bool lockBackForwardList = false); + void submit(Event* = 0, bool activateSubmitButton = false, bool lockHistory = false); void reset(); // Used to indicate a malformed state to keep from applying the bottom margin of the form. diff --git a/WebCore/html/HTMLFrameElementBase.cpp b/WebCore/html/HTMLFrameElementBase.cpp index 1e09595..a4f0a5e 100644 --- a/WebCore/html/HTMLFrameElementBase.cpp +++ b/WebCore/html/HTMLFrameElementBase.cpp @@ -79,7 +79,7 @@ bool HTMLFrameElementBase::isURLAllowed(const AtomicString& URLString) const // But we don't allow more than one. bool foundSelfReference = false; for (Frame* frame = document()->frame(); frame; frame = frame->tree()->parent()) { - if (equalIgnoringRef(frame->loader()->url(), completeURL)) { + if (equalIgnoringFragmentIdentifier(frame->loader()->url(), completeURL)) { if (foundSelfReference) return false; foundSelfReference = true; @@ -111,7 +111,7 @@ void HTMLFrameElementBase::openURL() void HTMLFrameElementBase::parseMappedAttribute(MappedAttribute *attr) { if (attr->name() == srcAttr) - setLocation(parseURL(attr->value())); + setLocation(deprecatedParseURL(attr->value())); else if (attr->name() == idAttr) { // Important to call through to base for the id attribute so the hasID bit gets set. HTMLFrameOwnerElement::parseMappedAttribute(attr); @@ -193,9 +193,10 @@ void HTMLFrameElementBase::attach() HTMLFrameOwnerElement::attach(); - if (RenderPart* renderPart = static_cast<RenderPart*>(renderer())) + if (RenderPart* renderPart = toRenderPart(renderer())) { if (Frame* frame = contentFrame()) renderPart->setWidget(frame->view()); + } } KURL HTMLFrameElementBase::location() const diff --git a/WebCore/html/HTMLFrameSetElement.cpp b/WebCore/html/HTMLFrameSetElement.cpp index f8e244c..a8f544b 100644 --- a/WebCore/html/HTMLFrameSetElement.cpp +++ b/WebCore/html/HTMLFrameSetElement.cpp @@ -3,7 +3,7 @@ * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Simon Hausmann (hausmann@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2006 Apple Computer, Inc. + * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -125,13 +125,29 @@ void HTMLFrameSetElement::parseMappedAttribute(MappedAttribute *attr) addCSSColor(attr, CSSPropertyBorderColor, attr->value()); m_borderColorSet = true; } - } else if (attr->name() == onloadAttr) { + } else if (attr->name() == onloadAttr) document()->setWindowAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(document()->frame(), attr)); - } else if (attr->name() == onbeforeunloadAttr) { + else if (attr->name() == onbeforeunloadAttr) document()->setWindowAttributeEventListener(eventNames().beforeunloadEvent, createAttributeEventListener(document()->frame(), attr)); - } else if (attr->name() == onunloadAttr) { + else if (attr->name() == onunloadAttr) document()->setWindowAttributeEventListener(eventNames().unloadEvent, createAttributeEventListener(document()->frame(), attr)); - } else + else if (attr->name() == onblurAttr) + document()->setWindowAttributeEventListener(eventNames().blurEvent, createAttributeEventListener(document()->frame(), attr)); + else if (attr->name() == onfocusAttr) + document()->setWindowAttributeEventListener(eventNames().focusEvent, createAttributeEventListener(document()->frame(), attr)); + else if (attr->name() == onhashchangeAttr) + document()->setWindowAttributeEventListener(eventNames().hashchangeEvent, createAttributeEventListener(document()->frame(), attr)); + else if (attr->name() == onresizeAttr) + document()->setWindowAttributeEventListener(eventNames().resizeEvent, createAttributeEventListener(document()->frame(), attr)); + else if (attr->name() == onscrollAttr) + document()->setWindowAttributeEventListener(eventNames().scrollEvent, createAttributeEventListener(document()->frame(), attr)); + else if (attr->name() == onstorageAttr) + document()->setWindowAttributeEventListener(eventNames().storageEvent, createAttributeEventListener(document()->frame(), attr)); + else if (attr->name() == ononlineAttr) + document()->setWindowAttributeEventListener(eventNames().onlineEvent, createAttributeEventListener(document()->frame(), attr)); + else if (attr->name() == onofflineAttr) + document()->setWindowAttributeEventListener(eventNames().offlineEvent, createAttributeEventListener(document()->frame(), attr)); + else HTMLElement::parseMappedAttribute(attr); } @@ -177,7 +193,7 @@ void HTMLFrameSetElement::attach() void HTMLFrameSetElement::defaultEventHandler(Event* evt) { if (evt->isMouseEvent() && !noresize && renderer()) { - if (static_cast<RenderFrameSet*>(renderer())->userResize(static_cast<MouseEvent*>(evt))) { + if (toRenderFrameSet(renderer())->userResize(static_cast<MouseEvent*>(evt))) { evt->setDefaultHandled(); return; } @@ -217,4 +233,114 @@ void HTMLFrameSetElement::setRows(const String &value) setAttribute(rowsAttr, value); } +EventListener* HTMLFrameSetElement::onblur() const +{ + return document()->getWindowAttributeEventListener(eventNames().blurEvent); } + +void HTMLFrameSetElement::setOnblur(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().blurEvent, eventListener); +} + +EventListener* HTMLFrameSetElement::onerror() const +{ + return document()->getWindowAttributeEventListener(eventNames().errorEvent); +} + +void HTMLFrameSetElement::setOnerror(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().errorEvent, eventListener); +} + +EventListener* HTMLFrameSetElement::onfocus() const +{ + return document()->getWindowAttributeEventListener(eventNames().focusEvent); +} + +void HTMLFrameSetElement::setOnfocus(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().focusEvent, eventListener); +} + +EventListener* HTMLFrameSetElement::onload() const +{ + return document()->getWindowAttributeEventListener(eventNames().loadEvent); +} + +void HTMLFrameSetElement::setOnload(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().loadEvent, eventListener); +} + +EventListener* HTMLFrameSetElement::onbeforeunload() const +{ + return document()->getWindowAttributeEventListener(eventNames().beforeunloadEvent); +} + +void HTMLFrameSetElement::setOnbeforeunload(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().beforeunloadEvent, eventListener); +} + +EventListener* HTMLFrameSetElement::onmessage() const +{ + return document()->getWindowAttributeEventListener(eventNames().messageEvent); +} + +void HTMLFrameSetElement::setOnmessage(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().messageEvent, eventListener); +} + +EventListener* HTMLFrameSetElement::onoffline() const +{ + return document()->getWindowAttributeEventListener(eventNames().offlineEvent); +} + +void HTMLFrameSetElement::setOnoffline(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().offlineEvent, eventListener); +} + +EventListener* HTMLFrameSetElement::ononline() const +{ + return document()->getWindowAttributeEventListener(eventNames().onlineEvent); +} + +void HTMLFrameSetElement::setOnonline(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().onlineEvent, eventListener); +} + +EventListener* HTMLFrameSetElement::onresize() const +{ + return document()->getWindowAttributeEventListener(eventNames().resizeEvent); +} + +void HTMLFrameSetElement::setOnresize(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().resizeEvent, eventListener); +} + +EventListener* HTMLFrameSetElement::onstorage() const +{ + return document()->getWindowAttributeEventListener(eventNames().storageEvent); +} + +void HTMLFrameSetElement::setOnstorage(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().storageEvent, eventListener); +} + +EventListener* HTMLFrameSetElement::onunload() const +{ + return document()->getWindowAttributeEventListener(eventNames().unloadEvent); +} + +void HTMLFrameSetElement::setOnunload(PassRefPtr<EventListener> eventListener) +{ + document()->setAttributeEventListener(eventNames().unloadEvent, eventListener); +} + +} // namespace WebCore diff --git a/WebCore/html/HTMLFrameSetElement.h b/WebCore/html/HTMLFrameSetElement.h index bb9156f..4319c7a 100644 --- a/WebCore/html/HTMLFrameSetElement.h +++ b/WebCore/html/HTMLFrameSetElement.h @@ -1,10 +1,8 @@ /* - * This file is part of the DOM implementation for KDE. - * * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Simon Hausmann <hausmann@kde.org> - * Copyright (C) 2004, 2006 Apple Computer, Inc. + * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -45,7 +43,7 @@ public: virtual void attach(); virtual bool rendererIsNeeded(RenderStyle*); - virtual RenderObject *createRenderer(RenderArena*, RenderStyle*); + virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); virtual void defaultEventHandler(Event*); @@ -58,7 +56,7 @@ public: bool hasBorderColor() const { return m_borderColorSet; } - virtual void recalcStyle( StyleChange ch ); + virtual void recalcStyle(StyleChange); String cols() const; void setCols(const String&); @@ -69,6 +67,31 @@ public: const Length* rowLengths() const { return m_rows; } const Length* colLengths() const { return m_cols; } + // Event handler attributes + virtual EventListener* onblur() const; + virtual void setOnblur(PassRefPtr<EventListener>); + virtual EventListener* onerror() const; + virtual void setOnerror(PassRefPtr<EventListener>); + virtual EventListener* onfocus() const; + virtual void setOnfocus(PassRefPtr<EventListener>); + virtual EventListener* onload() const; + virtual void setOnload(PassRefPtr<EventListener>); + + EventListener* onbeforeunload() const; + void setOnbeforeunload(PassRefPtr<EventListener>); + EventListener* onmessage() const; + void setOnmessage(PassRefPtr<EventListener>); + EventListener* onoffline() const; + void setOnoffline(PassRefPtr<EventListener>); + EventListener* ononline() const; + void setOnonline(PassRefPtr<EventListener>); + EventListener* onresize() const; + void setOnresize(PassRefPtr<EventListener>); + EventListener* onstorage() const; + void setOnstorage(PassRefPtr<EventListener>); + EventListener* onunload() const; + void setOnunload(PassRefPtr<EventListener>); + private: Length* m_rows; Length* m_cols; @@ -86,6 +109,6 @@ private: bool noresize; }; -} //namespace +} // namespace WebCore -#endif +#endif // HTMLFrameSetElement_h diff --git a/WebCore/html/HTMLFrameSetElement.idl b/WebCore/html/HTMLFrameSetElement.idl index 060616e..4050f2c 100644 --- a/WebCore/html/HTMLFrameSetElement.idl +++ b/WebCore/html/HTMLFrameSetElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserve + * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserve * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> * * This library is free software; you can redistribute it and/or @@ -26,10 +26,35 @@ module html { InterfaceUUID=5038a73d-c0db-4847-acb4-4c6d31f48790, ImplementationUUID=450f7bf6-fdc0-4a0f-b7e1-baea7f7e5732 ] HTMLFrameSetElement : HTMLElement { - attribute [ConvertNullToNullString] DOMString cols; attribute [ConvertNullToNullString] DOMString rows; +#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C +#if !defined(LANGUAGE_COM) || !LANGUAGE_COM + // Event handler attributes + attribute [DontEnum] EventListener onbeforeunload; + attribute [DontEnum] EventListener onmessage; + attribute [DontEnum] EventListener onoffline; + attribute [DontEnum] EventListener ononline; + attribute [DontEnum] EventListener onresize; + attribute [DontEnum] EventListener onstorage; + attribute [DontEnum] EventListener onunload; + + // Overrides of Element attributes. + // attribute [DontEnum] EventListener onblur; + // attribute [DontEnum] EventListener onerror; + // attribute [DontEnum] EventListener onfocus; + // attribute [DontEnum] EventListener onload; + + // Not implemented yet. + // attribute [DontEnum] EventListener onafterprint; + // attribute [DontEnum] EventListener onbeforeprint; + // attribute [DontEnum] EventListener onhashchange; + // attribute [DontEnum] EventListener onpopstate; + // attribute [DontEnum] EventListener onredo; + // attribute [DontEnum] EventListener onundo; +#endif +#endif }; } diff --git a/WebCore/html/HTMLHRElement.cpp b/WebCore/html/HTMLHRElement.cpp index d6cc58e..6858f56 100644 --- a/WebCore/html/HTMLHRElement.cpp +++ b/WebCore/html/HTMLHRElement.cpp @@ -71,7 +71,7 @@ void HTMLHRElement::parseMappedAttribute(MappedAttribute *attr) } else if (attr->name() == widthAttr) { bool ok; int v = attr->value().toInt(&ok); - if(ok && !v) + if (ok && !v) addCSSLength(attr, CSSPropertyWidth, "1"); else addCSSLength(attr, CSSPropertyWidth, attr->value()); diff --git a/WebCore/html/HTMLHeadElement.h b/WebCore/html/HTMLHeadElement.h index 2f01ef2..21d8a2f 100644 --- a/WebCore/html/HTMLHeadElement.h +++ b/WebCore/html/HTMLHeadElement.h @@ -30,8 +30,7 @@ namespace WebCore { -class HTMLHeadElement : public HTMLElement -{ +class HTMLHeadElement : public HTMLElement { public: HTMLHeadElement(const QualifiedName&, Document*); ~HTMLHeadElement(); diff --git a/WebCore/html/HTMLHtmlElement.cpp b/WebCore/html/HTMLHtmlElement.cpp index d4867a4..8382e60 100644 --- a/WebCore/html/HTMLHtmlElement.cpp +++ b/WebCore/html/HTMLHtmlElement.cpp @@ -23,8 +23,10 @@ #include "config.h" #include "HTMLHtmlElement.h" -#include "ApplicationCacheGroup.h" +#include "ApplicationCacheHost.h" #include "Document.h" +#include "DocumentLoader.h" +#include "Frame.h" #include "HTMLNames.h" namespace WebCore { @@ -68,12 +70,19 @@ void HTMLHtmlElement::insertedIntoDocument() if (!document()->frame()) return; + DocumentLoader* documentLoader = document()->frame()->loader()->documentLoader(); + if (!documentLoader) + return; + // Check the manifest attribute + // FIXME: Revisit this when we get a clarification from whatwg on how to handle empty + // manifest attributes. As spec'd, and coded here, the system will initiate an update + // passing in the document url as the manifest url. That's not a good thing. AtomicString manifest = getAttribute(manifestAttr); if (manifest.isNull()) - ApplicationCacheGroup::selectCacheWithoutManifestURL(document()->frame()); + documentLoader->applicationCacheHost()->selectCacheWithoutManifest(); else - ApplicationCacheGroup::selectCache(document()->frame(), document()->completeURL(manifest)); + documentLoader->applicationCacheHost()->selectCacheWithManifest(document()->completeURL(manifest)); } #endif diff --git a/WebCore/html/HTMLHtmlElement.h b/WebCore/html/HTMLHtmlElement.h index 91a0045..86603b5 100644 --- a/WebCore/html/HTMLHtmlElement.h +++ b/WebCore/html/HTMLHtmlElement.h @@ -30,8 +30,7 @@ namespace WebCore { -class HTMLHtmlElement : public HTMLElement -{ +class HTMLHtmlElement : public HTMLElement { public: HTMLHtmlElement(const QualifiedName&, Document*); ~HTMLHtmlElement(); diff --git a/WebCore/html/HTMLIFrameElement.cpp b/WebCore/html/HTMLIFrameElement.cpp index a190bca..478925a 100644 --- a/WebCore/html/HTMLIFrameElement.cpp +++ b/WebCore/html/HTMLIFrameElement.cpp @@ -117,7 +117,7 @@ void HTMLIFrameElement::attach() { HTMLFrameElementBase::attach(); - if (RenderPartObject* renderPartObject = static_cast<RenderPartObject*>(renderer())) + if (RenderPartObject* renderPartObject = toRenderPartObject(renderer())) renderPartObject->updateWidget(false); } diff --git a/WebCore/html/HTMLImageElement.cpp b/WebCore/html/HTMLImageElement.cpp index c4bf5dc..5173964 100644 --- a/WebCore/html/HTMLImageElement.cpp +++ b/WebCore/html/HTMLImageElement.cpp @@ -110,7 +110,7 @@ void HTMLImageElement::parseMappedAttribute(MappedAttribute* attr) if (attr->value().string()[0] == '#') usemap = attr->value(); else - usemap = document()->completeURL(parseURL(attr->value())).string(); + usemap = document()->completeURL(deprecatedParseURL(attr->value())).string(); setIsLink(!attr->isNull()); } else if (attrName == ismapAttr) ismap = true; @@ -319,6 +319,12 @@ void HTMLImageElement::setBorder(const String& value) setAttribute(borderAttr, value); } +bool HTMLImageElement::draggable() const +{ + // Image elements are draggable by default. + return !equalIgnoringCase(getAttribute(draggableAttr), "false"); +} + void HTMLImageElement::setHeight(int value) { setAttribute(heightAttr, String::number(value)); diff --git a/WebCore/html/HTMLImageElement.h b/WebCore/html/HTMLImageElement.h index 25cbb55..5e82186 100644 --- a/WebCore/html/HTMLImageElement.h +++ b/WebCore/html/HTMLImageElement.h @@ -67,7 +67,7 @@ public: CachedImage* cachedImage() const { return m_imageLoader.image(); } void setCachedImage(CachedImage* i) { m_imageLoader.setImage(i); }; - void setLoadManually (bool loadManually) { m_imageLoader.setLoadManually(loadManually); } + void setLoadManually(bool loadManually) { m_imageLoader.setLoadManually(loadManually); } String name() const; void setName(const String&); @@ -81,6 +81,8 @@ public: String border() const; void setBorder(const String&); + virtual bool draggable() const; + void setHeight(int); int hspace() const; diff --git a/WebCore/html/HTMLImageElement.idl b/WebCore/html/HTMLImageElement.idl index d7da088..a90ae25 100644 --- a/WebCore/html/HTMLImageElement.idl +++ b/WebCore/html/HTMLImageElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> * * This library is free software; you can redistribute it and/or @@ -25,22 +25,22 @@ module html { InterfaceUUID=b21b8125-d00b-4bdf-b0e8-659678db3923, ImplementationUUID=2121ca21-8118-4f1b-b9fe-4788a9050281 ] HTMLImageElement : HTMLElement { - attribute [ConvertNullToNullString] DOMString name; - attribute [ConvertNullToNullString] DOMString align; - attribute [ConvertNullToNullString] DOMString alt; - attribute [ConvertNullToNullString] DOMString border; + attribute [ConvertNullToNullString, Reflect] DOMString name; + attribute [ConvertNullToNullString, Reflect] DOMString align; + attribute [ConvertNullToNullString, Reflect] DOMString alt; + attribute [ConvertNullToNullString, Reflect] DOMString border; attribute long height; attribute long hspace; attribute boolean isMap; - attribute [ConvertNullToNullString] DOMString longDesc; - attribute [ConvertNullToNullString] DOMString src; - attribute [ConvertNullToNullString] DOMString useMap; + attribute [ConvertNullToNullString, ReflectURL=longdesc] DOMString longDesc; + attribute [ConvertNullToNullString, ReflectURL] DOMString src; + attribute [ConvertNullToNullString, Reflect=usemap] DOMString useMap; attribute long vspace; attribute long width; // Extensions readonly attribute boolean complete; - attribute [ConvertNullToNullString] DOMString lowsrc; + attribute [ConvertNullToNullString, ReflectURL] DOMString lowsrc; readonly attribute long naturalHeight; readonly attribute long naturalWidth; readonly attribute long x; diff --git a/WebCore/html/HTMLImageLoader.cpp b/WebCore/html/HTMLImageLoader.cpp index ea53d7e..2b9f09c 100644 --- a/WebCore/html/HTMLImageLoader.cpp +++ b/WebCore/html/HTMLImageLoader.cpp @@ -50,7 +50,7 @@ void HTMLImageLoader::dispatchLoadEvent() String HTMLImageLoader::sourceURI(const AtomicString& attr) const { - return parseURL(attr); + return deprecatedParseURL(attr); } void HTMLImageLoader::notifyFinished(CachedResource*) diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp index 2d1b3d0..88e14fd 100644 --- a/WebCore/html/HTMLInputElement.cpp +++ b/WebCore/html/HTMLInputElement.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "HTMLInputElement.h" +#include "AXObjectCache.h" #include "CSSPropertyNames.h" #include "ChromeClient.h" #include "Document.h" @@ -47,6 +48,7 @@ #include "MappedAttribute.h" #include "MouseEvent.h" #include "Page.h" +#include "RegularExpression.h" #include "RenderButton.h" #include "RenderFileUploadControl.h" #include "RenderImage.h" @@ -117,6 +119,79 @@ bool HTMLInputElement::autoComplete() const return true; } +bool HTMLInputElement::valueMissing() const +{ + if (!isRequiredFormControl() || readOnly() || disabled()) + return false; + + switch (inputType()) { + case TEXT: + case SEARCH: + case URL: + case TELEPHONE: + case EMAIL: + case PASSWORD: + case NUMBER: + case FILE: + return value().isEmpty(); + case CHECKBOX: + return !checked(); + case RADIO: + return !document()->checkedRadioButtons().checkedButtonForGroup(name()); + case HIDDEN: + case RANGE: + case SUBMIT: + case IMAGE: + case RESET: + case BUTTON: + case ISINDEX: + break; + } + + ASSERT_NOT_REACHED(); + return false; +} + +bool HTMLInputElement::patternMismatch() const +{ + switch (inputType()) { + case ISINDEX: + case CHECKBOX: + case RADIO: + case SUBMIT: + case RESET: + case FILE: + case HIDDEN: + case IMAGE: + case BUTTON: + case RANGE: + case NUMBER: + return false; + case TEXT: + case SEARCH: + case URL: + case TELEPHONE: + case EMAIL: + case PASSWORD: + const AtomicString& pattern = getAttribute(patternAttr); + String value = this->value(); + + // Empty values can't be mismatched + if (pattern.isEmpty() || value.isEmpty()) + return false; + + RegularExpression patternRegExp(pattern, TextCaseSensitive); + int matchLength = 0; + int valueLength = value.length(); + int matchOffset = patternRegExp.match(value, 0, &matchLength); + + return matchOffset != 0 || matchLength != valueLength; + } + + ASSERT_NOT_REACHED(); + return false; +} + static inline CheckedRadioButtons& checkedRadioButtons(const HTMLInputElement *element) { if (HTMLFormElement* form = element->form()) @@ -491,31 +566,34 @@ int HTMLInputElement::selectionEnd() const return toRenderTextControl(renderer())->selectionEnd(); } +static bool isTextFieldWithRenderer(HTMLInputElement* element) +{ + if (!element->isTextField()) + return false; + + element->document()->updateLayoutIgnorePendingStylesheets(); + if (!element->renderer()) + return false; + + return true; +} + void HTMLInputElement::setSelectionStart(int start) { - if (!isTextField()) - return; - if (!renderer()) - return; - toRenderTextControl(renderer())->setSelectionStart(start); + if (isTextFieldWithRenderer(this)) + toRenderTextControl(renderer())->setSelectionStart(start); } void HTMLInputElement::setSelectionEnd(int end) { - if (!isTextField()) - return; - if (!renderer()) - return; - toRenderTextControl(renderer())->setSelectionEnd(end); + if (isTextFieldWithRenderer(this)) + toRenderTextControl(renderer())->setSelectionEnd(end); } void HTMLInputElement::select() { - if (!isTextField()) - return; - if (!renderer()) - return; - toRenderTextControl(renderer())->select(); + if (isTextFieldWithRenderer(this)) + toRenderTextControl(renderer())->select(); } void HTMLInputElement::setSelectionRange(int start, int end) @@ -645,8 +723,6 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr) setAttributeEventListener(eventNames().selectEvent, createAttributeEventListener(this, attr)); } else if (attr->name() == onchangeAttr) { setAttributeEventListener(eventNames().changeEvent, createAttributeEventListener(this, attr)); - } else if (attr->name() == oninputAttr) { - setAttributeEventListener(eventNames().inputEvent, createAttributeEventListener(this, attr)); } // Search field and slider attributes all just cause updateFromElement to be called through style // recalcing. @@ -853,13 +929,25 @@ bool HTMLInputElement::appendFormData(FormDataList& encoding, bool multipart) break; case FILE: { - // Can't submit file on GET. - if (!multipart) - return false; + unsigned numFiles = m_fileList->length(); + if (!multipart) { + // Send only the basenames. + // 4.10.16.4 and 4.10.16.6 sections in HTML5. + + // Unlike the multipart case, we have no special + // handling for the empty fileList because Netscape + // doesn't support for non-multipart submission of + // file inputs, and Firefox doesn't add "name=" query + // parameter. + + for (unsigned i = 0; i < numFiles; ++i) { + encoding.appendData(name(), m_fileList->item(i)->fileName()); + } + return true; + } // If no filename at all is entered, return successful but empty. // Null would be more logical, but Netscape posts an empty file. Argh. - unsigned numFiles = m_fileList->length(); if (!numFiles) { encoding.appendFile(name(), File::create("")); return true; @@ -894,9 +982,15 @@ void HTMLInputElement::setChecked(bool nowChecked, bool sendChangeEvent) setNeedsStyleRecalc(); checkedRadioButtons(this).addButton(this); - + if (renderer() && renderer()->style()->hasAppearance()) - theme()->stateChanged(renderer(), CheckedState); + renderer()->theme()->stateChanged(renderer(), CheckedState); + + // Ideally we'd do this from the render tree (matching + // RenderTextView), but it's not possible to do it at the moment + // because of the way the code is structured. + if (renderer() && AXObjectCache::accessibilityEnabled()) + renderer()->document()->axObjectCache()->postNotification(renderer(), "AXCheckedStateChanged", true); // Only send a change event for items in the document (avoid firing during // parsing) and don't send a change event for a radio button that's getting @@ -918,7 +1012,7 @@ void HTMLInputElement::setIndeterminate(bool _indeterminate) setNeedsStyleRecalc(); if (renderer() && renderer()->style()->hasAppearance()) - theme()->stateChanged(renderer(), CheckedState); + renderer()->theme()->stateChanged(renderer(), CheckedState); } int HTMLInputElement::size() const @@ -1241,7 +1335,7 @@ void HTMLInputElement::defaultEventHandler(Event* evt) m_activeSubmit = false; } } else if (inputType() == FILE && renderer()) - static_cast<RenderFileUploadControl*>(renderer())->click(); + toRenderFileUploadControl(renderer())->click(); } // Use key press event here since sending simulated mouse events @@ -1429,10 +1523,10 @@ void HTMLInputElement::defaultEventHandler(Event* evt) InputElement::handleBeforeTextInsertedEvent(m_data, this, document(), evt); if (isTextField() && renderer() && (evt->isMouseEvent() || evt->isDragEvent() || evt->isWheelEvent() || evt->type() == eventNames().blurEvent || evt->type() == eventNames().focusEvent)) - static_cast<RenderTextControlSingleLine*>(renderer())->forwardEvent(evt); + toRenderTextControlSingleLine(renderer())->forwardEvent(evt); if (inputType() == RANGE && renderer() && (evt->isMouseEvent() || evt->isDragEvent() || evt->isWheelEvent())) - static_cast<RenderSlider*>(renderer())->forwardEvent(evt); + toRenderSlider(renderer())->forwardEvent(evt); if (!callBaseClassEarly && !evt->defaultHandled()) HTMLFormControlElementWithState::defaultEventHandler(evt); @@ -1591,6 +1685,37 @@ void HTMLInputElement::unregisterForActivationCallbackIfNeeded() document()->unregisterForDocumentActivationCallbacks(this); } +bool HTMLInputElement::isRequiredFormControl() const +{ + if (!required()) + return false; + + switch (inputType()) { + case TEXT: + case SEARCH: + case URL: + case TELEPHONE: + case EMAIL: + case PASSWORD: + case NUMBER: + case CHECKBOX: + case RADIO: + case FILE: + return true; + case HIDDEN: + case RANGE: + case SUBMIT: + case IMAGE: + case RESET: + case BUTTON: + case ISINDEX: + return false; + } + + ASSERT_NOT_REACHED(); + return false; +} + void HTMLInputElement::cacheSelection(int start, int end) { m_data.setCachedSelectionStart(start); @@ -1601,22 +1726,22 @@ void HTMLInputElement::addSearchResult() { ASSERT(isSearchField()); if (renderer()) - static_cast<RenderTextControlSingleLine*>(renderer())->addSearchResult(); + toRenderTextControlSingleLine(renderer())->addSearchResult(); } void HTMLInputElement::onSearch() { ASSERT(isSearchField()); if (renderer()) - static_cast<RenderTextControlSingleLine*>(renderer())->stopSearchEventTimer(); + toRenderTextControlSingleLine(renderer())->stopSearchEventTimer(); dispatchEvent(eventNames().searchEvent, true, false); } VisibleSelection HTMLInputElement::selection() const { - if (!renderer() || !isTextField() || m_data.cachedSelectionStart() == -1 || m_data.cachedSelectionEnd() == -1) + if (!renderer() || !isTextField() || m_data.cachedSelectionStart() == -1 || m_data.cachedSelectionEnd() == -1) return VisibleSelection(); - return toRenderTextControl(renderer())->selection(m_data.cachedSelectionStart(), m_data.cachedSelectionEnd()); + return toRenderTextControl(renderer())->selection(m_data.cachedSelectionStart(), m_data.cachedSelectionEnd()); } void HTMLInputElement::documentDidBecomeActive() diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h index be2b4f4..4d887f3 100644 --- a/WebCore/html/HTMLInputElement.h +++ b/WebCore/html/HTMLInputElement.h @@ -90,6 +90,9 @@ public: virtual bool isTextFormControl() const { return isTextField(); } + virtual bool valueMissing() const; + virtual bool patternMismatch() const; + bool isTextButton() const { return m_type == SUBMIT || m_type == RESET || m_type == BUTTON; } virtual bool isRadioButton() const { return m_type == RADIO; } virtual bool isTextField() const { return m_type == TEXT || m_type == PASSWORD || m_type == SEARCH || m_type == ISINDEX || m_type == EMAIL || m_type == NUMBER || m_type == TELEPHONE || m_type == URL; } @@ -237,6 +240,9 @@ private: void registerForActivationCallbackIfNeeded(); void unregisterForActivationCallbackIfNeeded(); + virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); } + virtual bool isRequiredFormControl() const; + InputElementData m_data; int m_xPos; int m_yPos; diff --git a/WebCore/html/HTMLInputElement.idl b/WebCore/html/HTMLInputElement.idl index 5536733..e15c6b5 100644 --- a/WebCore/html/HTMLInputElement.idl +++ b/WebCore/html/HTMLInputElement.idl @@ -28,6 +28,9 @@ module html { attribute [ConvertNullToNullString] DOMString defaultValue; attribute boolean defaultChecked; readonly attribute HTMLFormElement form; +#if !defined(LANGUAGE_COM) || !LANGUAGE_COM + readonly attribute ValidityState validity; +#endif attribute [ConvertNullToNullString] DOMString accept; attribute [ConvertNullToNullString] DOMString accessKey; attribute [ConvertNullToNullString] DOMString align; @@ -38,8 +41,10 @@ module html { attribute long maxLength; attribute boolean multiple; attribute [ConvertNullToNullString] DOMString name; + attribute [Reflect] DOMString pattern; attribute DOMString placeholder; attribute boolean readOnly; + attribute boolean required; #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C attribute [ConvertToString] DOMString size; // DOM level 2 changed this to a long, but our existing API is a string #else @@ -51,6 +56,7 @@ module html { attribute [ConvertNullToNullString] DOMString useMap; attribute [ConvertNullToNullString] DOMString value; readonly attribute boolean willValidate; + void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error); void select(); void click(); @@ -69,7 +75,7 @@ module html { readonly attribute URL absoluteImageURL; #endif -#if !defined(LANGUAGE_COM) +#if !defined(LANGUAGE_COM) || !LANGUAGE_COM readonly attribute FileList files; #endif }; diff --git a/WebCore/html/HTMLIsIndexElement.h b/WebCore/html/HTMLIsIndexElement.h index 82042cf..a1462b8 100644 --- a/WebCore/html/HTMLIsIndexElement.h +++ b/WebCore/html/HTMLIsIndexElement.h @@ -27,8 +27,7 @@ namespace WebCore { -class HTMLIsIndexElement : public HTMLInputElement -{ +class HTMLIsIndexElement : public HTMLInputElement { public: HTMLIsIndexElement(const QualifiedName&, Document *doc, HTMLFormElement *f = 0); diff --git a/WebCore/html/HTMLLIElement.cpp b/WebCore/html/HTMLLIElement.cpp index 044b93c..a8a327a 100644 --- a/WebCore/html/HTMLLIElement.cpp +++ b/WebCore/html/HTMLLIElement.cpp @@ -56,9 +56,9 @@ void HTMLLIElement::parseMappedAttribute(MappedAttribute* attr) m_requestedValue = attr->value().toInt(); if (renderer() && renderer()->isListItem()) { if (m_requestedValue > 0) - static_cast<RenderListItem*>(renderer())->setExplicitValue(m_requestedValue); + toRenderListItem(renderer())->setExplicitValue(m_requestedValue); else - static_cast<RenderListItem*>(renderer())->clearExplicitValue(); + toRenderListItem(renderer())->clearExplicitValue(); } } else if (attr->name() == typeAttr) { if (attr->value() == "a") @@ -84,7 +84,7 @@ void HTMLLIElement::attach() HTMLElement::attach(); if (renderer() && renderer()->isListItem()) { - RenderListItem* render = static_cast<RenderListItem*>(renderer()); + RenderListItem* render = toRenderListItem(renderer()); // Find the enclosing list node. Node* listNode = 0; diff --git a/WebCore/html/HTMLLinkElement.cpp b/WebCore/html/HTMLLinkElement.cpp index a1ebbc5..aa6360b 100644 --- a/WebCore/html/HTMLLinkElement.cpp +++ b/WebCore/html/HTMLLinkElement.cpp @@ -123,7 +123,7 @@ void HTMLLinkElement::parseMappedAttribute(MappedAttribute *attr) #endif process(); } else if (attr->name() == hrefAttr) { - m_url = document()->completeURL(parseURL(attr->value())); + m_url = document()->completeURL(deprecatedParseURL(attr->value())); process(); } else if (attr->name() == typeAttr) { m_type = attr->value(); @@ -202,9 +202,11 @@ void HTMLLinkElement::process() if (m_isDNSPrefetch && m_url.isValid() && !m_url.isEmpty()) prefetchDNS(m_url.host()); + bool acceptIfTypeContainsTextCSS = document()->page() && document()->page()->settings() && document()->page()->settings()->treatsAnyTextCSSLinkAsStylesheet(); + // Stylesheet // This was buggy and would incorrectly match <link rel="alternate">, which has a different specified meaning. -dwh - if (m_disabledState != 2 && m_isStyleSheet && document()->frame() && m_url.isValid()) { + if (m_disabledState != 2 && (m_isStyleSheet || acceptIfTypeContainsTextCSS && type.contains("text/css")) && document()->frame() && m_url.isValid()) { // also, don't load style sheets for standalone documents // Add ourselves as a pending sheet, but only if we aren't an alternate // stylesheet. Alternate stylesheets don't hold up render tree construction. @@ -246,11 +248,11 @@ void HTMLLinkElement::removedFromDocument() { HTMLElement::removedFromDocument(); + document()->removeStyleSheetCandidateNode(this); + // FIXME: It's terrible to do a synchronous update of the style selector just because a <style> or <link> element got removed. - if (document()->renderer()) { - document()->removeStyleSheetCandidateNode(this); + if (document()->renderer()) document()->updateStyleSelector(); - } } void HTMLLinkElement::finishParsingChildren() diff --git a/WebCore/html/HTMLMarqueeElement.cpp b/WebCore/html/HTMLMarqueeElement.cpp index d62eaab..0cb6501 100644 --- a/WebCore/html/HTMLMarqueeElement.cpp +++ b/WebCore/html/HTMLMarqueeElement.cpp @@ -34,7 +34,7 @@ namespace WebCore { using namespace HTMLNames; - // WinIE uses 60ms as the minimum delay by default. +// WinIE uses 60ms as the minimum delay by default. const int defaultMinimumDelay = 60; HTMLMarqueeElement::HTMLMarqueeElement(const QualifiedName& tagName, Document* doc) diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp index 6ad0653..b2e6428 100644 --- a/WebCore/html/HTMLMediaElement.cpp +++ b/WebCore/html/HTMLMediaElement.cpp @@ -52,11 +52,17 @@ #include "Page.h" #include "ProgressEvent.h" #include "RenderVideo.h" +#include "ScriptEventListener.h" #include "TimeRanges.h" #include <limits> #include <wtf/CurrentTime.h> #include <wtf/MathExtras.h> +#if USE(ACCELERATED_COMPOSITING) +#include "RenderView.h" +#include "RenderLayerCompositor.h" +#endif + #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) #include "RenderPartObject.h" #include "Widget.h" @@ -77,6 +83,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* doc) , m_playedTimeRanges() , m_playbackRate(1.0f) , m_defaultPlaybackRate(1.0f) + , m_webkitPreservesPitch(true) , m_networkState(NETWORK_EMPTY) , m_readyState(HAVE_NOTHING) , m_volume(1.0f) @@ -144,12 +151,60 @@ void HTMLMediaElement::attributeChanged(Attribute* attr, bool preserveDecls) #endif } -void HTMLMediaElement::parseMappedAttribute(MappedAttribute *attr) +void HTMLMediaElement::parseMappedAttribute(MappedAttribute* attr) { - if (attr->name() == autobufferAttr) { + const QualifiedName& attrName = attr->name(); + + if (attrName == autobufferAttr) { if (m_player) m_player->setAutobuffer(!attr->isNull()); - } else + } else if (attrName == onabortAttr) + setAttributeEventListener(eventNames().abortEvent, createAttributeEventListener(this, attr)); + else if (attrName == oncanplayAttr) + setAttributeEventListener(eventNames().canplayEvent, createAttributeEventListener(this, attr)); + else if (attrName == oncanplaythroughAttr) + setAttributeEventListener(eventNames().canplaythroughEvent, createAttributeEventListener(this, attr)); + else if (attrName == ondurationchangeAttr) + setAttributeEventListener(eventNames().durationchangeEvent, createAttributeEventListener(this, attr)); + else if (attrName == onemptiedAttr) + setAttributeEventListener(eventNames().emptiedEvent, createAttributeEventListener(this, attr)); + else if (attrName == onendedAttr) + setAttributeEventListener(eventNames().endedEvent, createAttributeEventListener(this, attr)); + else if (attrName == onerrorAttr) + setAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(this, attr)); + else if (attrName == onloadAttr) + setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr)); + else if (attrName == onloadeddataAttr) + setAttributeEventListener(eventNames().loadeddataEvent, createAttributeEventListener(this, attr)); + else if (attrName == onloadedmetadataAttr) + setAttributeEventListener(eventNames().loadedmetadataEvent, createAttributeEventListener(this, attr)); + else if (attrName == onloadstartAttr) + setAttributeEventListener(eventNames().loadstartEvent, createAttributeEventListener(this, attr)); + else if (attrName == onpauseAttr) + setAttributeEventListener(eventNames().pauseEvent, createAttributeEventListener(this, attr)); + else if (attrName == onplayAttr) + setAttributeEventListener(eventNames().playEvent, createAttributeEventListener(this, attr)); + else if (attrName == onplayingAttr) + setAttributeEventListener(eventNames().playingEvent, createAttributeEventListener(this, attr)); + else if (attrName == onprogressAttr) + setAttributeEventListener(eventNames().progressEvent, createAttributeEventListener(this, attr)); + else if (attrName == onratechangeAttr) + setAttributeEventListener(eventNames().ratechangeEvent, createAttributeEventListener(this, attr)); + else if (attrName == onseekedAttr) + setAttributeEventListener(eventNames().seekedEvent, createAttributeEventListener(this, attr)); + else if (attrName == onseekingAttr) + setAttributeEventListener(eventNames().seekingEvent, createAttributeEventListener(this, attr)); + else if (attrName == onstalledAttr) + setAttributeEventListener(eventNames().stalledEvent, createAttributeEventListener(this, attr)); + else if (attrName == onsuspendAttr) + setAttributeEventListener(eventNames().suspendEvent, createAttributeEventListener(this, attr)); + else if (attrName == ontimeupdateAttr) + setAttributeEventListener(eventNames().timeupdateEvent, createAttributeEventListener(this, attr)); + else if (attrName == onvolumechangeAttr) + setAttributeEventListener(eventNames().volumechangeEvent, createAttributeEventListener(this, attr)); + else if (attrName == onwaitingAttr) + setAttributeEventListener(eventNames().waitingEvent, createAttributeEventListener(this, attr)); + else HTMLElement::parseMappedAttribute(attr); } @@ -179,7 +234,7 @@ RenderObject* HTMLMediaElement::createRenderer(RenderArena* arena, RenderStyle*) void HTMLMediaElement::insertedIntoDocument() { HTMLElement::insertedIntoDocument(); - if (!src().isEmpty()) + if (!src().isEmpty() && m_networkState == NETWORK_EMPTY) scheduleLoad(); } @@ -336,7 +391,7 @@ String HTMLMediaElement::canPlayType(const String& mimeType) const switch (support) { case MediaPlayer::IsNotSupported: - canPlay = "no"; + canPlay = ""; break; case MediaPlayer::MayBeSupported: canPlay = "maybe"; @@ -495,6 +550,7 @@ void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType) m_player.set(new MediaPlayer(this)); #endif + m_player->setPreservesPitch(m_webkitPreservesPitch); updateVolume(); m_player->load(m_currentSrc, contentType); @@ -634,7 +690,6 @@ void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state) } if (state == MediaPlayer::Idle) { - ASSERT(static_cast<ReadyState>(m_player->readyState()) < HAVE_ENOUGH_DATA); if (m_networkState > NETWORK_IDLE) { stopPeriodicTimers(); scheduleProgressEvent(eventNames().suspendEvent); @@ -696,7 +751,6 @@ void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state) if (m_seeking && m_readyState < HAVE_CURRENT_DATA) { // 4.8.10.10, step 9 scheduleEvent(eventNames().seekingEvent); - m_seeking = false; } if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { @@ -710,8 +764,8 @@ void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state) scheduleEvent(eventNames().loadedmetadataEvent); #if !ENABLE(PLUGIN_PROXY_FOR_VIDEO) - if (renderer() && !renderer()->isImage()) { - static_cast<RenderVideo*>(renderer())->videoSizeChanged(); + if (renderer() && renderer()->isVideo()) { + toRenderVideo(renderer())->videoSizeChanged(); } #endif m_delayingTheLoadEvent = false; @@ -783,6 +837,23 @@ void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) } } +void HTMLMediaElement::rewind(float timeDelta) +{ + ExceptionCode e; + setCurrentTime(max(currentTime() - timeDelta, minTimeSeekable()), e); +} + +void HTMLMediaElement::returnToRealtime() +{ + ExceptionCode e; + setCurrentTime(maxTimeSeekable(), e); +} + +bool HTMLMediaElement::supportsSave() const +{ + return m_player ? m_player->supportsSave() : false; +} + void HTMLMediaElement::seek(float time, ExceptionCode& ec) { // 4.8.10.10. Seeking @@ -835,6 +906,11 @@ HTMLMediaElement::ReadyState HTMLMediaElement::readyState() const return m_readyState; } +MediaPlayer::MovieLoadType HTMLMediaElement::movieLoadType() const +{ + return m_player ? m_player->movieLoadType() : MediaPlayer::Unknown; +} + bool HTMLMediaElement::seeking() const { return m_seeking; @@ -903,6 +979,21 @@ void HTMLMediaElement::setPlaybackRate(float rate) m_player->setRate(rate); } +bool HTMLMediaElement::webkitPreservesPitch() const +{ + return m_webkitPreservesPitch; +} + +void HTMLMediaElement::setWebkitPreservesPitch(bool preservesPitch) +{ + m_webkitPreservesPitch = preservesPitch; + + if (!m_player) + return; + + m_player->setPreservesPitch(preservesPitch); +} + bool HTMLMediaElement::ended() const { return endedPlayback(); @@ -1130,6 +1221,14 @@ bool HTMLMediaElement::canPlay() const return paused() || ended() || m_readyState < HAVE_METADATA; } +float HTMLMediaElement::percentLoaded() const +{ + if (!m_player) + return 0; + float duration = m_player->duration(); + return duration ? m_player->maxTimeBuffered() / duration : 0; +} + bool HTMLMediaElement::havePotentialSourceChild() { // Stash the current <source> node so we can restore it after checking @@ -1226,14 +1325,6 @@ void HTMLMediaElement::mediaPlayerTimeChanged(MediaPlayer*) endProcessingMediaPlayerCallback(); } -void HTMLMediaElement::mediaPlayerRepaint(MediaPlayer*) -{ - beginProcessingMediaPlayerCallback(); - if (renderer()) - renderer()->repaint(); - endProcessingMediaPlayerCallback(); -} - void HTMLMediaElement::mediaPlayerVolumeChanged(MediaPlayer*) { beginProcessingMediaPlayerCallback(); @@ -1248,8 +1339,8 @@ void HTMLMediaElement::mediaPlayerDurationChanged(MediaPlayer*) #if !ENABLE(PLUGIN_PROXY_FOR_VIDEO) if (renderer()) { renderer()->updateFromElement(); - if (!renderer()->isImage()) - static_cast<RenderVideo*>(renderer())->videoSizeChanged(); + if (renderer()->isVideo()) + toRenderVideo(renderer())->videoSizeChanged(); } #endif endProcessingMediaPlayerCallback(); @@ -1264,26 +1355,53 @@ void HTMLMediaElement::mediaPlayerRateChanged(MediaPlayer*) endProcessingMediaPlayerCallback(); } +void HTMLMediaElement::mediaPlayerSawUnsupportedTracks(MediaPlayer*) +{ + // The MediaPlayer came across content it cannot completely handle. + // This is normally acceptable except when we are in a standalone + // MediaDocument. If so, tell the document what has happened. + if (ownerDocument()->isMediaDocument()) { + MediaDocument* mediaDocument = static_cast<MediaDocument*>(ownerDocument()); + mediaDocument->mediaElementSawUnsupportedTracks(); + } +} + +// MediaPlayerPresentation methods +void HTMLMediaElement::mediaPlayerRepaint(MediaPlayer*) +{ + beginProcessingMediaPlayerCallback(); + if (renderer()) + renderer()->repaint(); + endProcessingMediaPlayerCallback(); +} + void HTMLMediaElement::mediaPlayerSizeChanged(MediaPlayer*) { beginProcessingMediaPlayerCallback(); #if !ENABLE(PLUGIN_PROXY_FOR_VIDEO) - if (renderer() && !renderer()->isImage()) - static_cast<RenderVideo*>(renderer())->videoSizeChanged(); + if (renderer() && renderer()->isVideo()) + toRenderVideo(renderer())->videoSizeChanged(); #endif endProcessingMediaPlayerCallback(); } -void HTMLMediaElement::mediaPlayerSawUnsupportedTracks(MediaPlayer*) +#if USE(ACCELERATED_COMPOSITING) +bool HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated(MediaPlayer*) { - // The MediaPlayer came across content it cannot completely handle. - // This is normally acceptable except when we are in a standalone - // MediaDocument. If so, tell the document what has happened. - if (ownerDocument()->isMediaDocument()) { - MediaDocument* mediaDocument = static_cast<MediaDocument*>(ownerDocument()); - mediaDocument->mediaElementSawUnsupportedTracks(); + if (renderer() && renderer()->isVideo()) { + ASSERT(renderer()->view()); + return renderer()->view()->compositor()->canAccelerateVideoRendering(toRenderVideo(renderer())); } + return false; +} + +GraphicsLayer* HTMLMediaElement::mediaPlayerGraphicsLayer(MediaPlayer*) +{ + if (renderer() && renderer()->isVideo()) + return toRenderVideo(renderer())->videoGraphicsLayer(); + return 0; } +#endif PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const { @@ -1310,9 +1428,9 @@ PassRefPtr<TimeRanges> HTMLMediaElement::played() const PassRefPtr<TimeRanges> HTMLMediaElement::seekable() const { // FIXME real ranges support - if (!m_player || !m_player->maxTimeSeekable()) + if (!maxTimeSeekable()) return TimeRanges::create(); - return TimeRanges::create(0, m_player->maxTimeSeekable()); + return TimeRanges::create(minTimeSeekable(), maxTimeSeekable()); } bool HTMLMediaElement::potentiallyPlaying() const @@ -1346,6 +1464,16 @@ bool HTMLMediaElement::pausedForUserInteraction() const return false; } +float HTMLMediaElement::minTimeSeekable() const +{ + return 0; +} + +float HTMLMediaElement::maxTimeSeekable() const +{ + return m_player ? m_player->maxTimeSeekable() : 0; +} + void HTMLMediaElement::updateVolume() { if (!m_player) @@ -1452,6 +1580,9 @@ void HTMLMediaElement::documentWillBecomeInactive() if (renderer()) renderer()->updateFromElement(); + + stopPeriodicTimers(); + cancelPendingEventsAndCallbacks(); } void HTMLMediaElement::documentDidBecomeActive() @@ -1484,12 +1615,12 @@ void HTMLMediaElement::defaultEventHandler(Event* event) if (!r || !r->isWidget()) return; - Widget* widget = static_cast<RenderWidget*>(r)->widget(); + Widget* widget = toRenderWidget(r)->widget(); if (widget) widget->handleEvent(event); #else if (renderer() && renderer()->isMedia()) - static_cast<RenderMedia*>(renderer())->forwardEvent(event); + toRenderMedia(renderer())->forwardEvent(event); if (event->defaultHandled()) return; HTMLElement::defaultEventHandler(event); @@ -1502,15 +1633,15 @@ bool HTMLMediaElement::processingUserGesture() const FrameLoader* loader = frame ? frame->loader() : 0; // return 'true' for safety if we don't know the answer - return loader ? loader->userGestureHint() : true; + return loader ? loader->isProcessingUserGesture() : true; } #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) + void HTMLMediaElement::deliverNotification(MediaPlayerProxyNotificationType notification) { if (notification == MediaPlayerNotificationPlayPauseButtonPressed) { - ExceptionCode ec; - togglePlayState(ec); + togglePlayState(); return; } @@ -1529,7 +1660,7 @@ String HTMLMediaElement::initialURL() KURL initialSrc = document()->completeURL(getAttribute(srcAttr)); if (!initialSrc.isValid()) - initialSrc = selectNextSourceChild(0, DoNothing).string(); + initialSrc = selectNextSourceChild(0, DoNothing); m_currentSrc = initialSrc.string(); @@ -1544,8 +1675,9 @@ void HTMLMediaElement::finishParsingChildren() document()->updateStyleIfNeeded(); if (m_needWidgetUpdate && renderer()) - static_cast<RenderPartObject*>(renderer())->updateWidget(true); + toRenderPartObject(renderer())->updateWidget(true); } + #endif } diff --git a/WebCore/html/HTMLMediaElement.h b/WebCore/html/HTMLMediaElement.h index 65c542b..27b48ea 100644 --- a/WebCore/html/HTMLMediaElement.h +++ b/WebCore/html/HTMLMediaElement.h @@ -65,7 +65,14 @@ public: virtual bool isVideo() const { return false; } virtual bool hasVideo() const { return false; } - + + void rewind(float timeDelta); + void returnToRealtime(); + + // Eventually overloaded in HTMLVideoElement + virtual bool supportsFullscreen() const { return false; }; + virtual bool supportsSave() const; + void scheduleLoad(); virtual void defaultEventHandler(Event*); @@ -73,6 +80,8 @@ public: // Pauses playback without changing any states or generating events void setPausedInternal(bool); + MediaPlayer::MovieLoadType movieLoadType() const; + bool inActiveDocument() const { return m_inActiveDocument; } // DOM API @@ -108,6 +117,8 @@ public: void setDefaultPlaybackRate(float); float playbackRate() const; void setPlaybackRate(float); + bool webkitPreservesPitch() const; + void setWebkitPreservesPitch(bool); PassRefPtr<TimeRanges> played() const; PassRefPtr<TimeRanges> seekable() const; bool ended() const; @@ -131,6 +142,8 @@ public: bool canPlay() const; + float percentLoaded() const; + #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) void setNeedWidgetUpdate(bool needWidgetUpdate) { m_needWidgetUpdate = needWidgetUpdate; } void deliverNotification(MediaPlayerProxyNotificationType notification); @@ -139,6 +152,8 @@ public: virtual void finishParsingChildren(); #endif + bool hasSingleSecurityOrigin() const { return !m_player || m_player->hasSingleSecurityOrigin(); } + protected: float getTimeOffsetAttribute(const QualifiedName&, float valueOnError) const; void setTimeOffsetAttribute(const QualifiedName&, float value); @@ -150,16 +165,20 @@ protected: void setReadyState(MediaPlayer::ReadyState); void setNetworkState(MediaPlayer::NetworkState); -private: // MediaPlayerObserver +private: // MediaPlayerClient virtual void mediaPlayerNetworkStateChanged(MediaPlayer*); virtual void mediaPlayerReadyStateChanged(MediaPlayer*); virtual void mediaPlayerTimeChanged(MediaPlayer*); - virtual void mediaPlayerRepaint(MediaPlayer*); virtual void mediaPlayerVolumeChanged(MediaPlayer*); virtual void mediaPlayerDurationChanged(MediaPlayer*); virtual void mediaPlayerRateChanged(MediaPlayer*); - virtual void mediaPlayerSizeChanged(MediaPlayer*); virtual void mediaPlayerSawUnsupportedTracks(MediaPlayer*); + virtual void mediaPlayerRepaint(MediaPlayer*); + virtual void mediaPlayerSizeChanged(MediaPlayer*); +#if USE(ACCELERATED_COMPOSITING) + virtual bool mediaPlayerRenderingCanBeAccelerated(MediaPlayer*); + virtual GraphicsLayer* mediaPlayerGraphicsLayer(MediaPlayer*); +#endif private: void loadTimerFired(Timer<HTMLMediaElement>*); @@ -209,10 +228,12 @@ private: bool stoppedDueToErrors() const; bool pausedForUserInteraction() const; + float minTimeSeekable() const; + float maxTimeSeekable() const; + // Restrictions to change default behaviors. This is a effectively a compile time choice at the moment // because there are no accessor methods. - enum BehaviorRestrictions - { + enum BehaviorRestrictions { NoRestrictions = 0, RequireUserGestureForLoadRestriction = 1 << 0, RequireUserGestureForRateChangeRestriction = 1 << 1, @@ -228,6 +249,7 @@ protected: float m_playbackRate; float m_defaultPlaybackRate; + bool m_webkitPreservesPitch; NetworkState m_networkState; ReadyState m_readyState; String m_currentSrc; diff --git a/WebCore/html/HTMLMediaElement.idl b/WebCore/html/HTMLMediaElement.idl index 008e059..7278fa6 100644 --- a/WebCore/html/HTMLMediaElement.idl +++ b/WebCore/html/HTMLMediaElement.idl @@ -76,5 +76,8 @@ interface [GenerateConstructor, Conditional=VIDEO] HTMLMediaElement : HTMLElemen attribute float volume setter raises (DOMException); attribute boolean muted; + + // WebKit extension + attribute boolean webkitPreservesPitch; }; } diff --git a/WebCore/html/HTMLMenuElement.h b/WebCore/html/HTMLMenuElement.h index 0f4488d..68b5b8f 100644 --- a/WebCore/html/HTMLMenuElement.h +++ b/WebCore/html/HTMLMenuElement.h @@ -26,8 +26,7 @@ namespace WebCore { -class HTMLMenuElement : public HTMLElement -{ +class HTMLMenuElement : public HTMLElement { public: HTMLMenuElement(const QualifiedName&, Document*); diff --git a/WebCore/html/HTMLMetaElement.h b/WebCore/html/HTMLMetaElement.h index f535293..d86df2e 100644 --- a/WebCore/html/HTMLMetaElement.h +++ b/WebCore/html/HTMLMetaElement.h @@ -28,8 +28,7 @@ namespace WebCore { -class HTMLMetaElement : public HTMLElement -{ +class HTMLMetaElement : public HTMLElement { public: HTMLMetaElement(const QualifiedName&, Document*); ~HTMLMetaElement(); diff --git a/WebCore/html/HTMLModElement.h b/WebCore/html/HTMLModElement.h index 399053c..83697f9 100644 --- a/WebCore/html/HTMLModElement.h +++ b/WebCore/html/HTMLModElement.h @@ -30,8 +30,7 @@ namespace WebCore { class String; -class HTMLModElement : public HTMLElement -{ +class HTMLModElement : public HTMLElement { public: HTMLModElement(const QualifiedName&, Document*); diff --git a/WebCore/html/HTMLOListElement.cpp b/WebCore/html/HTMLOListElement.cpp index 63fd437..344a069 100644 --- a/WebCore/html/HTMLOListElement.cpp +++ b/WebCore/html/HTMLOListElement.cpp @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * @@ -63,12 +63,16 @@ void HTMLOListElement::parseMappedAttribute(MappedAttribute* attr) else if (attr->value() == "1") addCSSProperty(attr, CSSPropertyListStyleType, CSSValueDecimal); } else if (attr->name() == startAttr) { - int s = !attr->isNull() ? attr->value().toInt() : 1; - if (s != m_start) { - m_start = s; - for (RenderObject* r = renderer(); r; r = r->nextInPreOrder(renderer())) - if (r->isListItem()) - static_cast<RenderListItem*>(r)->updateValue(); + bool canParse; + int start = attr->value().toInt(&canParse); + if (!canParse) + start = 1; + if (start == m_start) + return; + m_start = start; + for (RenderObject* child = renderer(); child; child = child->nextInPreOrder(renderer())) { + if (child->isListItem()) + toRenderListItem(child)->updateValue(); } } else HTMLElement::parseMappedAttribute(attr); diff --git a/WebCore/html/HTMLOListElement.h b/WebCore/html/HTMLOListElement.h index e459269..b7a13ee 100644 --- a/WebCore/html/HTMLOListElement.h +++ b/WebCore/html/HTMLOListElement.h @@ -26,8 +26,7 @@ namespace WebCore { -class HTMLOListElement : public HTMLElement -{ +class HTMLOListElement : public HTMLElement { public: HTMLOListElement(const QualifiedName&, Document*); diff --git a/WebCore/html/HTMLObjectElement.cpp b/WebCore/html/HTMLObjectElement.cpp index 6be41c9..76a9c5a 100644 --- a/WebCore/html/HTMLObjectElement.cpp +++ b/WebCore/html/HTMLObjectElement.cpp @@ -60,10 +60,10 @@ HTMLObjectElement::~HTMLObjectElement() RenderWidget* HTMLObjectElement::renderWidgetForJSBindings() const { - RenderWidget* renderWidget = (renderer() && renderer()->isWidget()) ? static_cast<RenderWidget*>(renderer()) : 0; + RenderWidget* renderWidget = (renderer() && renderer()->isWidget()) ? toRenderWidget(renderer()) : 0; if (renderWidget && !renderWidget->widget()) { document()->updateLayoutIgnorePendingStylesheets(); - renderWidget = (renderer() && renderer()->isWidget()) ? static_cast<RenderWidget*>(renderer()) : 0; + renderWidget = (renderer() && renderer()->isWidget()) ? toRenderWidget(renderer()) : 0; } return renderWidget; } @@ -82,7 +82,7 @@ void HTMLObjectElement::parseMappedAttribute(MappedAttribute *attr) if (!isImageType() && m_imageLoader) m_imageLoader.clear(); } else if (attr->name() == dataAttr) { - m_url = parseURL(val); + m_url = deprecatedParseURL(val); if (renderer()) m_needWidgetUpdate = true; if (renderer() && isImageType()) { @@ -166,7 +166,7 @@ void HTMLObjectElement::updateWidget() { document()->updateStyleIfNeeded(); if (m_needWidgetUpdate && renderer() && !m_useFallbackContent && !isImageType()) - static_cast<RenderPartObject*>(renderer())->updateWidget(true); + toRenderPartObject(renderer())->updateWidget(true); } void HTMLObjectElement::finishParsingChildren() diff --git a/WebCore/html/HTMLObjectElement.idl b/WebCore/html/HTMLObjectElement.idl index 5d4562c..1880836 100644 --- a/WebCore/html/HTMLObjectElement.idl +++ b/WebCore/html/HTMLObjectElement.idl @@ -22,8 +22,8 @@ module html { interface [ GenerateConstructor, - CustomPutFunction, - CustomGetOwnPropertySlot, + DelegatingPutFunction, + DelegatingGetOwnPropertySlot, CustomCall, HasOverridingNameGetter, InterfaceUUID=9d04a3b8-9016-4b64-913a-3b00d548aca7, diff --git a/WebCore/html/HTMLOptionElement.cpp b/WebCore/html/HTMLOptionElement.cpp index 66968b0..009db47 100644 --- a/WebCore/html/HTMLOptionElement.cpp +++ b/WebCore/html/HTMLOptionElement.cpp @@ -79,7 +79,7 @@ const AtomicString& HTMLOptionElement::formControlType() const String HTMLOptionElement::text() const { - return OptionElement::collectOptionText(m_data, this); + return OptionElement::collectOptionLabelOrText(m_data, this); } void HTMLOptionElement::setText(const String &text, ExceptionCode& ec) @@ -152,10 +152,10 @@ void HTMLOptionElement::setSelectedState(bool selected) void HTMLOptionElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) { - HTMLSelectElement* select = ownerSelectElement(); - if (select) - select->childrenChanged(changedByParser); - HTMLFormControlElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); + HTMLSelectElement* select = ownerSelectElement(); + if (select) + select->childrenChanged(changedByParser); + HTMLFormControlElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); } HTMLSelectElement* HTMLOptionElement::ownerSelectElement() const diff --git a/WebCore/html/HTMLParamElement.h b/WebCore/html/HTMLParamElement.h index 4da2ed3..1867ccf 100644 --- a/WebCore/html/HTMLParamElement.h +++ b/WebCore/html/HTMLParamElement.h @@ -27,8 +27,7 @@ namespace WebCore { -class HTMLParamElement : public HTMLElement -{ +class HTMLParamElement : public HTMLElement { friend class HTMLAppletElement; public: HTMLParamElement(const QualifiedName&, Document*); diff --git a/WebCore/html/HTMLParser.cpp b/WebCore/html/HTMLParser.cpp index dab58b3..722f4e2 100644 --- a/WebCore/html/HTMLParser.cpp +++ b/WebCore/html/HTMLParser.cpp @@ -793,6 +793,20 @@ bool HTMLParser::dtCreateErrorCheck(Token* t, RefPtr<Node>& result) return true; } +bool HTMLParser::rpCreateErrorCheck(Token*, RefPtr<Node>&) +{ + popBlock(rpTag); + popBlock(rtTag); + return true; +} + +bool HTMLParser::rtCreateErrorCheck(Token*, RefPtr<Node>&) +{ + popBlock(rpTag); + popBlock(rtTag); + return true; +} + bool HTMLParser::nestedCreateErrorCheck(Token* t, RefPtr<Node>&) { popBlock(t->tagName); @@ -917,6 +931,8 @@ PassRefPtr<Node> HTMLParser::getNode(Token* t) gFunctionMap.set(pTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck); gFunctionMap.set(plaintextTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck); gFunctionMap.set(preTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck); + gFunctionMap.set(rpTag.localName().impl(), &HTMLParser::rpCreateErrorCheck); + gFunctionMap.set(rtTag.localName().impl(), &HTMLParser::rtCreateErrorCheck); gFunctionMap.set(sTag.localName().impl(), &HTMLParser::nestedStyleCreateErrorCheck); gFunctionMap.set(selectTag.localName().impl(), &HTMLParser::selectCreateErrorCheck); gFunctionMap.set(smallTag.localName().impl(), &HTMLParser::nestedStyleCreateErrorCheck); @@ -1076,6 +1092,7 @@ bool HTMLParser::isAffectedByResidualStyle(const AtomicString& tagName) unaffectedTags.add(optgroupTag.localName().impl()); unaffectedTags.add(selectTag.localName().impl()); unaffectedTags.add(objectTag.localName().impl()); + unaffectedTags.add(datagridTag.localName().impl()); } return !unaffectedTags.contains(tagName.impl()); @@ -1655,7 +1672,7 @@ void HTMLParser::reportErrorToConsole(HTMLParserErrorCode errorCode, const Atomi message.replace("%tag1", tag1); message.replace("%tag2", tag2); - frame->domWindow()->console()->addMessage(HTMLMessageSource, + frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, isWarning(errorCode) ? WarningMessageLevel : ErrorMessageLevel, message, lineNumber, m_document->url().string()); } diff --git a/WebCore/html/HTMLParser.h b/WebCore/html/HTMLParser.h index 19f553e..0945826 100644 --- a/WebCore/html/HTMLParser.h +++ b/WebCore/html/HTMLParser.h @@ -49,7 +49,7 @@ struct Token; * The parser for HTML. It receives a stream of tokens from the HTMLTokenizer, and * builds up the Document structure from it. */ -class HTMLParser : Noncopyable { +class HTMLParser : public Noncopyable { public: HTMLParser(HTMLDocument*, bool reportErrors); HTMLParser(DocumentFragment*); @@ -102,6 +102,8 @@ private: bool noscriptCreateErrorCheck(Token*, RefPtr<Node>&); bool pCloserCreateErrorCheck(Token*, RefPtr<Node>&); bool pCloserStrictCreateErrorCheck(Token*, RefPtr<Node>&); + bool rpCreateErrorCheck(Token*, RefPtr<Node>&); + bool rtCreateErrorCheck(Token*, RefPtr<Node>&); bool selectCreateErrorCheck(Token*, RefPtr<Node>&); bool tableCellCreateErrorCheck(Token*, RefPtr<Node>&); bool tableSectionCreateErrorCheck(Token*, RefPtr<Node>&); diff --git a/WebCore/html/HTMLParserQuirks.h b/WebCore/html/HTMLParserQuirks.h index b5972a6..176bbfb 100644 --- a/WebCore/html/HTMLParserQuirks.h +++ b/WebCore/html/HTMLParserQuirks.h @@ -33,7 +33,7 @@ namespace WebCore { class AtomicString; class Node; -class HTMLParserQuirks : Noncopyable { +class HTMLParserQuirks : public Noncopyable { public: HTMLParserQuirks() { } virtual ~HTMLParserQuirks() { } diff --git a/WebCore/html/HTMLPlugInElement.cpp b/WebCore/html/HTMLPlugInElement.cpp index d950d9d..7aa6083 100644 --- a/WebCore/html/HTMLPlugInElement.cpp +++ b/WebCore/html/HTMLPlugInElement.cpp @@ -177,9 +177,10 @@ void HTMLPlugInElement::defaultEventHandler(Event* event) RenderObject* r = renderer(); if (!r || !r->isWidget()) return; - - if (Widget* widget = static_cast<RenderWidget*>(r)->widget()) - widget->handleEvent(event); + Widget* widget = toRenderWidget(r)->widget(); + if (!widget) + return; + widget->handleEvent(event); } #if ENABLE(NETSCAPE_PLUGIN_API) diff --git a/WebCore/html/HTMLQuoteElement.h b/WebCore/html/HTMLQuoteElement.h index 623c28f..addbfb4 100644 --- a/WebCore/html/HTMLQuoteElement.h +++ b/WebCore/html/HTMLQuoteElement.h @@ -28,8 +28,7 @@ namespace WebCore { class String; -class HTMLQuoteElement : public HTMLElement -{ +class HTMLQuoteElement : public HTMLElement { public: HTMLQuoteElement(const QualifiedName&, Document*); diff --git a/WebCore/html/HTMLSelectElement.cpp b/WebCore/html/HTMLSelectElement.cpp index 95038e6..2409f31 100644 --- a/WebCore/html/HTMLSelectElement.cpp +++ b/WebCore/html/HTMLSelectElement.cpp @@ -80,9 +80,14 @@ void HTMLSelectElement::deselectItems(HTMLOptionElement* excludeElement) SelectElement::deselectItems(m_data, this, excludeElement); } -void HTMLSelectElement::setSelectedIndex(int optionIndex, bool deselect, bool fireOnChange) +void HTMLSelectElement::setSelectedIndex(int optionIndex, bool deselect) { - SelectElement::setSelectedIndex(m_data, this, optionIndex, deselect, fireOnChange); + SelectElement::setSelectedIndex(m_data, this, optionIndex, deselect, false, false); +} + +void HTMLSelectElement::setSelectedIndexByUser(int optionIndex, bool deselect, bool fireOnChangeNow) +{ + SelectElement::setSelectedIndex(m_data, this, optionIndex, deselect, fireOnChangeNow, true); } int HTMLSelectElement::activeSelectionStartListIndex() const @@ -101,13 +106,7 @@ int HTMLSelectElement::activeSelectionEndListIndex() const unsigned HTMLSelectElement::length() const { - unsigned len = 0; - const Vector<Element*>& items = listItems(); - for (unsigned i = 0; i < items.size(); ++i) { - if (items[i]->hasLocalName(optionTag)) - ++len; - } - return len; + return SelectElement::optionCount(m_data, this); } void HTMLSelectElement::add(HTMLElement *element, HTMLElement *before, ExceptionCode& ec) diff --git a/WebCore/html/HTMLSelectElement.h b/WebCore/html/HTMLSelectElement.h index 9ecd81c..d28f116 100644 --- a/WebCore/html/HTMLSelectElement.h +++ b/WebCore/html/HTMLSelectElement.h @@ -39,7 +39,8 @@ public: HTMLSelectElement(const QualifiedName&, Document*, HTMLFormElement* = 0); virtual int selectedIndex() const; - virtual void setSelectedIndex(int index, bool deselect = true, bool fireOnChange = false); + virtual void setSelectedIndex(int index, bool deselect = true); + virtual void setSelectedIndexByUser(int index, bool deselect = true, bool fireOnChangeNow = false); unsigned length() const; @@ -129,6 +130,8 @@ private: virtual void insertedIntoTree(bool); + virtual bool isOptionalFormControl() const { return true; } + SelectElementData m_data; CollectionCache m_collectionInfo; }; diff --git a/WebCore/html/HTMLSelectElement.idl b/WebCore/html/HTMLSelectElement.idl index fb08bb1..177895e 100644 --- a/WebCore/html/HTMLSelectElement.idl +++ b/WebCore/html/HTMLSelectElement.idl @@ -41,7 +41,11 @@ module html { #endif readonly attribute HTMLFormElement form; +#if !defined(LANGUAGE_COM) || !LANGUAGE_COM + readonly attribute ValidityState validity; +#endif readonly attribute boolean willValidate; + void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error); // Modified in DOM Level 2: readonly attribute HTMLOptionsCollection options; diff --git a/WebCore/html/HTMLStyleElement.cpp b/WebCore/html/HTMLStyleElement.cpp index f6b5924..206aec4 100644 --- a/WebCore/html/HTMLStyleElement.cpp +++ b/WebCore/html/HTMLStyleElement.cpp @@ -71,8 +71,7 @@ void HTMLStyleElement::insertedIntoDocument() void HTMLStyleElement::removedFromDocument() { HTMLElement::removedFromDocument(); - if (document()->renderer()) - document()->removeStyleSheetCandidateNode(this); + document()->removeStyleSheetCandidateNode(this); StyleElement::removedFromDocument(document()); } diff --git a/WebCore/html/HTMLStyleElement.h b/WebCore/html/HTMLStyleElement.h index fe3adb0..03b4c66 100644 --- a/WebCore/html/HTMLStyleElement.h +++ b/WebCore/html/HTMLStyleElement.h @@ -28,8 +28,7 @@ namespace WebCore { -class HTMLStyleElement : public HTMLElement, public StyleElement -{ +class HTMLStyleElement : public HTMLElement, public StyleElement { public: HTMLStyleElement(const QualifiedName&, Document*, bool createdByParser); diff --git a/WebCore/html/HTMLTableCaptionElement.h b/WebCore/html/HTMLTableCaptionElement.h index 38bc434..3c2aaa1 100644 --- a/WebCore/html/HTMLTableCaptionElement.h +++ b/WebCore/html/HTMLTableCaptionElement.h @@ -30,8 +30,7 @@ namespace WebCore { -class HTMLTableCaptionElement : public HTMLTablePartElement -{ +class HTMLTableCaptionElement : public HTMLTablePartElement { public: HTMLTableCaptionElement(const QualifiedName&, Document*); diff --git a/WebCore/html/HTMLTableCellElement.cpp b/WebCore/html/HTMLTableCellElement.cpp index 05f02c7..f3b4674 100644 --- a/WebCore/html/HTMLTableCellElement.cpp +++ b/WebCore/html/HTMLTableCellElement.cpp @@ -97,12 +97,12 @@ void HTMLTableCellElement::parseMappedAttribute(MappedAttribute *attr) rSpan = !attr->isNull() ? attr->value().toInt() : 1; rSpan = max(1, min(rSpan, maxRowspan)); if (renderer() && renderer()->isTableCell()) - static_cast<RenderTableCell*>(renderer())->updateFromElement(); + toRenderTableCell(renderer())->updateFromElement(); } else if (attr->name() == colspanAttr) { cSpan = !attr->isNull() ? attr->value().toInt() : 1; cSpan = max(1, cSpan); if (renderer() && renderer()->isTableCell()) - static_cast<RenderTableCell*>(renderer())->updateFromElement(); + toRenderTableCell(renderer())->updateFromElement(); } else if (attr->name() == nowrapAttr) { #ifdef ANDROID_LAYOUT if (!(document()->frame()) || document()->frame()->settings()->layoutAlgorithm() != Settings::kLayoutSSR) diff --git a/WebCore/html/HTMLTableCellElement.h b/WebCore/html/HTMLTableCellElement.h index 7e26e94..fc74cae 100644 --- a/WebCore/html/HTMLTableCellElement.h +++ b/WebCore/html/HTMLTableCellElement.h @@ -32,8 +32,7 @@ namespace WebCore { -class HTMLTableCellElement : public HTMLTablePartElement -{ +class HTMLTableCellElement : public HTMLTablePartElement { public: HTMLTableCellElement(const QualifiedName&, Document*); ~HTMLTableCellElement(); diff --git a/WebCore/html/HTMLTableColElement.cpp b/WebCore/html/HTMLTableColElement.cpp index ae18ab1..e1008d1 100644 --- a/WebCore/html/HTMLTableColElement.cpp +++ b/WebCore/html/HTMLTableColElement.cpp @@ -79,10 +79,17 @@ void HTMLTableColElement::parseMappedAttribute(MappedAttribute *attr) if (attr->name() == spanAttr) { _span = !attr->isNull() ? attr->value().toInt() : 1; if (renderer() && renderer()->isTableCol()) - static_cast<RenderTableCol*>(renderer())->updateFromElement(); + renderer()->updateFromElement(); } else if (attr->name() == widthAttr) { - if (!attr->value().isEmpty()) + if (!attr->value().isEmpty()) { addCSSLength(attr, CSSPropertyWidth, attr->value()); + if (renderer() && renderer()->isTableCol()) { + RenderTableCol* col = toRenderTableCol(renderer()); + int newWidth = width().toInt(); + if (newWidth != col->width()) + col->setNeedsLayoutAndPrefWidthsRecalc(); + } + } } else HTMLTablePartElement::parseMappedAttribute(attr); } diff --git a/WebCore/html/HTMLTableColElement.h b/WebCore/html/HTMLTableColElement.h index 0bed401..83a26aa 100644 --- a/WebCore/html/HTMLTableColElement.h +++ b/WebCore/html/HTMLTableColElement.h @@ -34,8 +34,7 @@ namespace WebCore { class HTMLTableElement; -class HTMLTableColElement : public HTMLTablePartElement -{ +class HTMLTableColElement : public HTMLTablePartElement { public: HTMLTableColElement(const QualifiedName& tagName, Document*); diff --git a/WebCore/html/HTMLTableElement.cpp b/WebCore/html/HTMLTableElement.cpp index e37c171..af35740 100644 --- a/WebCore/html/HTMLTableElement.cpp +++ b/WebCore/html/HTMLTableElement.cpp @@ -351,7 +351,7 @@ void HTMLTableElement::parseMappedAttribute(MappedAttribute* attr) m_borderColorAttr = true; } } else if (attr->name() == backgroundAttr) { - String url = parseURL(attr->value()); + String url = deprecatedParseURL(attr->value()); if (!url.isEmpty()) addCSSImageProperty(attr, CSSPropertyBackgroundImage, document()->completeURL(url).string()); } else if (attr->name() == frameAttr) { diff --git a/WebCore/html/HTMLTablePartElement.cpp b/WebCore/html/HTMLTablePartElement.cpp index 19babf6..0f9a3e8 100644 --- a/WebCore/html/HTMLTablePartElement.cpp +++ b/WebCore/html/HTMLTablePartElement.cpp @@ -66,7 +66,7 @@ void HTMLTablePartElement::parseMappedAttribute(MappedAttribute *attr) if (attr->name() == bgcolorAttr) addCSSColor(attr, CSSPropertyBackgroundColor, attr->value()); else if (attr->name() == backgroundAttr) { - String url = parseURL(attr->value()); + String url = deprecatedParseURL(attr->value()); if (!url.isEmpty()) addCSSImageProperty(attr, CSSPropertyBackgroundImage, document()->completeURL(url).string()); } else if (attr->name() == bordercolorAttr) { diff --git a/WebCore/html/HTMLTableSectionElement.cpp b/WebCore/html/HTMLTableSectionElement.cpp index e91a96a..15fa97e 100644 --- a/WebCore/html/HTMLTableSectionElement.cpp +++ b/WebCore/html/HTMLTableSectionElement.cpp @@ -99,7 +99,7 @@ PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionC return r.release(); } -void HTMLTableSectionElement::deleteRow( int index, ExceptionCode& ec) +void HTMLTableSectionElement::deleteRow(int index, ExceptionCode& ec) { RefPtr<HTMLCollection> children = rows(); int numRows = children ? (int)children->length() : 0; diff --git a/WebCore/html/HTMLTagNames.in b/WebCore/html/HTMLTagNames.in index 14119ef..c066e3c 100644 --- a/WebCore/html/HTMLTagNames.in +++ b/WebCore/html/HTMLTagNames.in @@ -25,6 +25,10 @@ cite interfaceName=HTMLElement code interfaceName=HTMLElement col interfaceName=HTMLTableColElement colgroup interfaceName=HTMLTableColElement +datagrid interfaceName=HTMLDataGridElement,conditional=DATAGRID +dcell interfaceName=HTMLDataGridCellElement,conditional=DATAGRID +dcol interfaceName=HTMLDataGridColElement,conditional=DATAGRID +drow interfaceName=HTMLDataGridRowElement,conditional=DATAGRID dd interfaceName=HTMLElement del interfaceName=HTMLModElement dfn interfaceName=HTMLElement @@ -85,6 +89,9 @@ param plaintext interfaceName=HTMLElement pre q interfaceName=HTMLQuoteElement +rp interfaceName=HTMLElement +rt interfaceName=HTMLElement +ruby interfaceName=HTMLElement s interfaceName=HTMLElement samp interfaceName=HTMLElement script constructorNeedsCreatedByParser diff --git a/WebCore/html/HTMLTextAreaElement.cpp b/WebCore/html/HTMLTextAreaElement.cpp index 41a0126..884cf3f 100644 --- a/WebCore/html/HTMLTextAreaElement.cpp +++ b/WebCore/html/HTMLTextAreaElement.cpp @@ -27,6 +27,7 @@ #include "HTMLTextAreaElement.h" #include "ChromeClient.h" +#include "CSSValueKeywords.h" #include "Document.h" #include "Event.h" #include "EventNames.h" @@ -110,32 +111,34 @@ int HTMLTextAreaElement::selectionEnd() return toRenderTextControl(renderer())->selectionEnd(); } +static RenderTextControl* rendererAfterUpdateLayout(HTMLTextAreaElement* element) +{ + element->document()->updateLayoutIgnorePendingStylesheets(); + return toRenderTextControl(element->renderer()); +} + void HTMLTextAreaElement::setSelectionStart(int start) { - if (!renderer()) - return; - toRenderTextControl(renderer())->setSelectionStart(start); + if (RenderTextControl* renderer = rendererAfterUpdateLayout(this)) + renderer->setSelectionStart(start); } void HTMLTextAreaElement::setSelectionEnd(int end) { - if (!renderer()) - return; - toRenderTextControl(renderer())->setSelectionEnd(end); + if (RenderTextControl* renderer = rendererAfterUpdateLayout(this)) + renderer->setSelectionEnd(end); } void HTMLTextAreaElement::select() { - if (!renderer()) - return; - toRenderTextControl(renderer())->select(); + if (RenderTextControl* renderer = rendererAfterUpdateLayout(this)) + renderer->select(); } void HTMLTextAreaElement::setSelectionRange(int start, int end) { - if (!renderer()) - return; - toRenderTextControl(renderer())->setSelectionRange(start, end); + if (RenderTextControl* renderer = rendererAfterUpdateLayout(this)) + renderer->setSelectionRange(start, end); } void HTMLTextAreaElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) @@ -176,6 +179,15 @@ void HTMLTextAreaElement::parseMappedAttribute(MappedAttribute* attr) wrap = SoftWrap; if (wrap != m_wrap) { m_wrap = wrap; + + if (shouldWrapText()) { + addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValuePreWrap); + addCSSProperty(attr, CSSPropertyWordWrap, CSSValueBreakWord); + } else { + addCSSProperty(attr, CSSPropertyWhiteSpace, CSSValuePre); + addCSSProperty(attr, CSSPropertyWordWrap, CSSValueNormal); + } + if (renderer()) renderer()->setNeedsLayoutAndPrefWidthsRecalc(); } @@ -233,7 +245,8 @@ bool HTMLTextAreaElement::isMouseFocusable() const void HTMLTextAreaElement::updateFocusAppearance(bool restorePreviousSelection) { ASSERT(renderer()); - + ASSERT(!document()->childNeedsAndNotInStyleRecalc()); + if (!restorePreviousSelection || m_cachedSelectionStart < 0) { #if ENABLE(ON_FIRST_TEXTAREA_FOCUS_SELECT_ALL) // Devices with trackballs or d-pads may focus on a textarea in route @@ -258,7 +271,7 @@ void HTMLTextAreaElement::updateFocusAppearance(bool restorePreviousSelection) void HTMLTextAreaElement::defaultEventHandler(Event* event) { if (renderer() && (event->isMouseEvent() || event->isDragEvent() || event->isWheelEvent() || event->type() == eventNames().blurEvent)) - static_cast<RenderTextControlMultiLine*>(renderer())->forwardEvent(event); + toRenderTextControlMultiLine(renderer())->forwardEvent(event); HTMLFormControlElementWithState::defaultEventHandler(event); } diff --git a/WebCore/html/HTMLTextAreaElement.h b/WebCore/html/HTMLTextAreaElement.h index e22b5d5..5ef8e55 100644 --- a/WebCore/html/HTMLTextAreaElement.h +++ b/WebCore/html/HTMLTextAreaElement.h @@ -52,6 +52,8 @@ public: virtual bool isTextFormControl() const { return true; } + virtual bool valueMissing() const { return isRequiredFormControl() && !disabled() && !readOnly() && value().isEmpty(); } + int selectionStart(); int selectionEnd(); @@ -96,6 +98,9 @@ private: void updateValue() const; + virtual bool isOptionalFormControl() const { return !isRequiredFormControl(); } + virtual bool isRequiredFormControl() const { return required(); } + int m_rows; int m_cols; WrapMethod m_wrap; diff --git a/WebCore/html/HTMLTextAreaElement.idl b/WebCore/html/HTMLTextAreaElement.idl index c4f144b..5d2853e 100644 --- a/WebCore/html/HTMLTextAreaElement.idl +++ b/WebCore/html/HTMLTextAreaElement.idl @@ -27,12 +27,16 @@ module html { ] HTMLTextAreaElement : HTMLElement { attribute [ConvertNullToNullString] DOMString defaultValue; readonly attribute HTMLFormElement form; +#if !defined(LANGUAGE_COM) || !LANGUAGE_COM + readonly attribute ValidityState validity; +#endif attribute [ConvertNullToNullString] DOMString accessKey; attribute long cols; attribute boolean disabled; attribute boolean autofocus; attribute [ConvertNullToNullString] DOMString name; attribute boolean readOnly; + attribute boolean required; attribute long rows; readonly attribute DOMString type; attribute [ConvertNullToNullString] DOMString value; @@ -40,6 +44,7 @@ module html { void select(); readonly attribute boolean willValidate; + void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error); // WinIE & FireFox extension: attribute long selectionStart; diff --git a/WebCore/html/HTMLTitleElement.h b/WebCore/html/HTMLTitleElement.h index 2cbb667..5335d8d 100644 --- a/WebCore/html/HTMLTitleElement.h +++ b/WebCore/html/HTMLTitleElement.h @@ -28,8 +28,7 @@ namespace WebCore { -class HTMLTitleElement : public HTMLElement -{ +class HTMLTitleElement : public HTMLElement { public: HTMLTitleElement(const QualifiedName&, Document*); ~HTMLTitleElement(); diff --git a/WebCore/html/HTMLTokenizer.cpp b/WebCore/html/HTMLTokenizer.cpp index 413050d..2850aec 100644 --- a/WebCore/html/HTMLTokenizer.cpp +++ b/WebCore/html/HTMLTokenizer.cpp @@ -47,6 +47,7 @@ #include "ScriptController.h" #include "ScriptSourceCode.h" #include "ScriptValue.h" +#include "XSSAuditor.h" #include <wtf/ASCIICType.h> #include <wtf/CurrentTime.h> @@ -319,11 +320,11 @@ HTMLTokenizer::State HTMLTokenizer::processListing(SegmentedString list, State s return state; } -HTMLTokenizer::State HTMLTokenizer::parseSpecial(SegmentedString& src, State state) +HTMLTokenizer::State HTMLTokenizer::parseNonHTMLText(SegmentedString& src, State state) { ASSERT(state.inTextArea() || state.inTitle() || state.inIFrame() || !state.hasEntityState()); ASSERT(!state.hasTagState()); - ASSERT(state.inXmp() + state.inTextArea() + state.inTitle() + state.inStyle() + state.inScript() + state.inIFrame() == 1 ); + ASSERT(state.inXmp() + state.inTextArea() + state.inTitle() + state.inStyle() + state.inScript() + state.inIFrame() == 1); if (state.inScript() && !m_currentScriptTagStartLineNumber) m_currentScriptTagStartLineNumber = m_lineNumber; @@ -741,9 +742,9 @@ HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString& src, UChar*& de EntityUnicodeValue = 0; } - while(!src.isEmpty()) { + while (!src.isEmpty()) { UChar cc = *src; - switch(state.entityState()) { + switch (state.entityState()) { case NoEntity: ASSERT(state.entityState() != NoEntity); return state; @@ -792,7 +793,7 @@ HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString& src, UChar*& de case Decimal: { int ll = min(src.length(), 9-cBufferPos); - while(ll--) { + while (ll--) { cc = *src; if (!(cc >= '0' && cc <= '9')) { @@ -811,7 +812,7 @@ HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString& src, UChar*& de case EntityName: { int ll = min(src.length(), 9-cBufferPos); - while(ll--) { + while (ll--) { cc = *src; if (!((cc >= 'a' && cc <= 'z') || (cc >= '0' && cc <= '9') || (cc >= 'A' && cc <= 'Z'))) { @@ -825,7 +826,7 @@ HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString& src, UChar*& de if (cBufferPos == 9) state.setEntityState(SearchSemicolon); if (state.entityState() == SearchSemicolon) { - if(cBufferPos > 1) { + if (cBufferPos > 1) { // Since the maximum length of entity name is 9, // so a single char array which is allocated on // the stack, its length is 10, should be OK. @@ -848,11 +849,11 @@ HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString& src, UChar*& de else e = 0; - if(e) + if (e) EntityUnicodeValue = e->code; // be IE compatible - if(parsingTag && EntityUnicodeValue > 255 && *src != ';') + if (parsingTag && EntityUnicodeValue > 255 && *src != ';') EntityUnicodeValue = 0; } } @@ -1133,7 +1134,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) while (!src.isEmpty()) { checkBuffer(); - switch(state.tagState()) { + switch (state.tagState()) { case NoTag: { m_cBufferPos = cBufferPos; @@ -1248,7 +1249,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) break; } case SearchAttribute: - while(!src.isEmpty()) { + while (!src.isEmpty()) { UChar curchar = *src; // In this mode just ignore any quotes we encounter and treat them like spaces. if (!isASCIISpace(curchar) && curchar != '\'' && curchar != '"') { @@ -1267,6 +1268,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) break; case AttributeName: { + m_rawAttributeBeforeValue.clear(); int ll = min(src.length(), CBUFLEN - cBufferPos); while (ll--) { UChar curchar = *src; @@ -1289,6 +1291,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) else m_cBuffer[cBufferPos++] = curchar; + m_rawAttributeBeforeValue.append(curchar); src.advance(m_lineNumber); } if (cBufferPos == CBUFLEN) { @@ -1320,6 +1323,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) state.setTagState(SearchValue); if (inViewSourceMode()) m_currentToken.addViewSourceChar(curchar); + m_rawAttributeBeforeValue.append(curchar); src.advancePastNonNewline(); } else { m_currentToken.addAttribute(m_attrName, emptyAtom, inViewSourceMode()); @@ -1329,11 +1333,12 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) } break; } - if (inViewSourceMode()) - m_currentToken.addViewSourceChar(curchar); - + lastIsSlash = curchar == '/'; + if (inViewSourceMode()) + m_currentToken.addViewSourceChar(curchar); + m_rawAttributeBeforeValue.append(curchar); src.advance(m_lineNumber); } break; @@ -1346,6 +1351,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) state.setTagState(QuotedValue); if (inViewSourceMode()) m_currentToken.addViewSourceChar(curchar); + m_rawAttributeBeforeValue.append(curchar); src.advancePastNonNewline(); } else state.setTagState(Value); @@ -1354,6 +1360,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) } if (inViewSourceMode()) m_currentToken.addViewSourceChar(curchar); + m_rawAttributeBeforeValue.append(curchar); src.advance(m_lineNumber); } break; @@ -1402,6 +1409,13 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) m_currentToken.addViewSourceChar('x'); } else if (inViewSourceMode()) m_currentToken.addViewSourceChar('v'); + + if (m_currentToken.beginTag && m_currentToken.tagName == scriptTag && !inViewSourceMode() && !m_parser->skipMode() && m_attrName == srcAttr) { + String context(m_rawAttributeBeforeValue.data(), m_rawAttributeBeforeValue.size()); + if (m_XSSAuditor && !m_XSSAuditor->canLoadExternalScriptFromSrc(context, attributeValue)) + attributeValue = blankURL().string(); + } + m_currentToken.addAttribute(m_attrName, attributeValue, inViewSourceMode()); m_dest = m_buffer; state.setTagState(SearchAttribute); @@ -1418,7 +1432,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) } break; case Value: - while(!src.isEmpty()) { + while (!src.isEmpty()) { checkBuffer(); UChar curchar = *src; if (curchar <= '>' && !src.escaped()) { @@ -1432,6 +1446,13 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) // '/' does not delimit in IE! if (isASCIISpace(curchar) || curchar == '>') { AtomicString attributeValue(m_buffer + 1, m_dest - m_buffer - 1); + + if (m_currentToken.beginTag && m_currentToken.tagName == scriptTag && !inViewSourceMode() && !m_parser->skipMode() && m_attrName == srcAttr) { + String context(m_rawAttributeBeforeValue.data(), m_rawAttributeBeforeValue.size()); + if (m_XSSAuditor && !m_XSSAuditor->canLoadExternalScriptFromSrc(context, attributeValue)) + attributeValue = blankURL().string(); + } + m_currentToken.addAttribute(m_attrName, attributeValue, inViewSourceMode()); if (inViewSourceMode()) m_currentToken.addViewSourceChar('v'); @@ -1485,7 +1506,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) if (m_currentToken.attrs && !m_fragment) { if (m_doc->frame() && m_doc->frame()->script()->isEnabled()) { if ((a = m_currentToken.attrs->getAttributeItem(srcAttr))) - m_scriptTagSrcAttrValue = m_doc->completeURL(parseURL(a->value())).string(); + m_scriptTagSrcAttrValue = m_doc->completeURL(deprecatedParseURL(a->value())).string(); } } } @@ -1493,6 +1514,9 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) RefPtr<Node> n = processToken(); m_cBufferPos = cBufferPos; if (n || inViewSourceMode()) { + State savedState = state; + SegmentedString savedSrc = src; + long savedLineno = m_lineNumber; if ((tagName == preTag || tagName == listingTag) && !inViewSourceMode()) { if (beginTag) state.setDiscardLF(true); // Discard the first LF after we open a pre. @@ -1505,7 +1529,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) m_searchStopper = scriptEnd; m_searchStopperLength = 8; state.setInScript(true); - state = parseSpecial(src, state); + state = parseNonHTMLText(src, state); } else if (isSelfClosingScript) { // Handle <script src="foo"/> state.setInScript(true); state = scriptHandler(state); @@ -1515,53 +1539,50 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) m_searchStopper = styleEnd; m_searchStopperLength = 7; state.setInStyle(true); - state = parseSpecial(src, state); + state = parseNonHTMLText(src, state); } } else if (tagName == textareaTag) { if (beginTag) { m_searchStopper = textareaEnd; m_searchStopperLength = 10; state.setInTextArea(true); - state = parseSpecial(src, state); + state = parseNonHTMLText(src, state); } } else if (tagName == titleTag) { if (beginTag) { m_searchStopper = titleEnd; m_searchStopperLength = 7; - State savedState = state; - SegmentedString savedSrc = src; - long savedLineno = m_lineNumber; state.setInTitle(true); - state = parseSpecial(src, state); - if (state.inTitle() && src.isEmpty()) { - // We just ate the rest of the document as the title #text node! - // Reset the state then retokenize without special title handling. - // Let the parser clean up the missing </title> tag. - // FIXME: This is incorrect, because src.isEmpty() doesn't mean we're - // at the end of the document unless m_noMoreData is also true. We need - // to detect this case elsewhere, and save the state somewhere other - // than a local variable. - state = savedState; - src = savedSrc; - m_lineNumber = savedLineno; - m_scriptCodeSize = 0; - } + state = parseNonHTMLText(src, state); } } else if (tagName == xmpTag) { if (beginTag) { m_searchStopper = xmpEnd; m_searchStopperLength = 5; state.setInXmp(true); - state = parseSpecial(src, state); + state = parseNonHTMLText(src, state); } } else if (tagName == iframeTag) { if (beginTag) { m_searchStopper = iframeEnd; m_searchStopperLength = 8; state.setInIFrame(true); - state = parseSpecial(src, state); + state = parseNonHTMLText(src, state); } } + if (src.isEmpty() && (state.inTitle() || inViewSourceMode()) && !state.inComment() && !(state.inScript() && m_currentScriptTagStartLineNumber)) { + // We just ate the rest of the document as the #text node under the special tag! + // Reset the state then retokenize without special handling. + // Let the parser clean up the missing close tag. + // FIXME: This is incorrect, because src.isEmpty() doesn't mean we're + // at the end of the document unless m_noMoreData is also true. We need + // to detect this case elsewhere, and save the state somewhere other + // than a local variable. + state = savedState; + src = savedSrc; + m_lineNumber = savedLineno; + m_scriptCodeSize = 0; + } } if (tagName == plaintextTag) state.setInPlainText(beginTag); @@ -1681,8 +1702,8 @@ void HTMLTokenizer::write(const SegmentedString& str, bool appendData) state = parseEntity(m_src, m_dest, state, m_cBufferPos, false, state.hasTagState()); else if (state.inPlainText()) state = parseText(m_src, state); - else if (state.inAnySpecial()) - state = parseSpecial(m_src, state); + else if (state.inAnyNonHTMLText()) + state = parseNonHTMLText(m_src, state); else if (state.inComment()) state = parseComment(m_src, state); else if (state.inDoctype()) @@ -1696,7 +1717,7 @@ void HTMLTokenizer::write(const SegmentedString& str, bool appendData) else if (state.startTag()) { state.setStartTag(false); - switch(cc) { + switch (cc) { case '/': break; case '!': { @@ -1724,7 +1745,7 @@ void HTMLTokenizer::write(const SegmentedString& str, bool appendData) } // else fall through default: { - if( ((cc >= 'a') && (cc <= 'z')) || ((cc >= 'A') && (cc <= 'Z'))) { + if ( ((cc >= 'a') && (cc <= 'z')) || ((cc >= 'A') && (cc <= 'Z'))) { // Start of a Start-Tag } else { // Invalid tag diff --git a/WebCore/html/HTMLTokenizer.h b/WebCore/html/HTMLTokenizer.h index 2896974..d731b2d 100644 --- a/WebCore/html/HTMLTokenizer.h +++ b/WebCore/html/HTMLTokenizer.h @@ -173,7 +173,7 @@ private: State parseDoctype(SegmentedString&, State); State parseServer(SegmentedString&, State); State parseText(SegmentedString&, State); - State parseSpecial(SegmentedString&, State); + State parseNonHTMLText(SegmentedString&, State); State parseTag(SegmentedString&, State); State parseEntity(SegmentedString&, UChar*& dest, State, unsigned& cBufferPos, bool start, bool parsingTag); State parseProcessingInstruction(SegmentedString&, State); @@ -213,6 +213,10 @@ private: Token m_currentToken; + // This buffer holds the raw characters we've seen between the beginning of + // the attribute name and the first character of the attribute value. + Vector<UChar, 32> m_rawAttributeBeforeValue; + // Tokenizer flags ////////////////// // are we in quotes within a html tag @@ -288,7 +292,7 @@ private: bool forceSynchronous() const { return testBit(ForceSynchronous); } void setForceSynchronous(bool v) { setBit(ForceSynchronous, v); } - bool inAnySpecial() const { return m_bits & (InScript | InStyle | InXmp | InTextArea | InTitle | InIFrame); } + bool inAnyNonHTMLText() const { return m_bits & (InScript | InStyle | InXmp | InTextArea | InTitle | InIFrame); } bool hasTagState() const { return m_bits & TagMask; } bool hasEntityState() const { return m_bits & EntityMask; } diff --git a/WebCore/html/HTMLUListElement.h b/WebCore/html/HTMLUListElement.h index 3a565a4..1eda5f3 100644 --- a/WebCore/html/HTMLUListElement.h +++ b/WebCore/html/HTMLUListElement.h @@ -26,8 +26,7 @@ namespace WebCore { -class HTMLUListElement : public HTMLElement -{ +class HTMLUListElement : public HTMLElement { public: HTMLUListElement(const QualifiedName&, Document*); diff --git a/WebCore/html/HTMLVideoElement.cpp b/WebCore/html/HTMLVideoElement.cpp index d465b73..ecd74e7 100644 --- a/WebCore/html/HTMLVideoElement.cpp +++ b/WebCore/html/HTMLVideoElement.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -186,5 +186,29 @@ void HTMLVideoElement::updatePosterImage() #endif } +void HTMLVideoElement::paint(GraphicsContext* context, const IntRect& destRect) +{ + // FIXME: We should also be able to paint the poster image. + + MediaPlayer* player = HTMLMediaElement::player(); + if (!player) + return; + + player->setVisible(true); // Make player visible or it won't draw. + player->paint(context, destRect); +} + +void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& destRect) +{ + // FIXME: We should also be able to paint the poster image. + + MediaPlayer* player = HTMLMediaElement::player(); + if (!player) + return; + + player->setVisible(true); // Make player visible or it won't draw. + player->paintCurrentFrameInContext(context, destRect); +} + } #endif diff --git a/WebCore/html/HTMLVideoElement.h b/WebCore/html/HTMLVideoElement.h index d35f3f8..dc9714a 100644 --- a/WebCore/html/HTMLVideoElement.h +++ b/WebCore/html/HTMLVideoElement.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,8 +35,7 @@ namespace WebCore { class HTMLImageLoader; -class HTMLVideoElement : public HTMLMediaElement -{ +class HTMLVideoElement : public HTMLMediaElement { public: HTMLVideoElement(const QualifiedName&, Document*); @@ -50,6 +49,7 @@ public: virtual void parseMappedAttribute(MappedAttribute* attr); virtual bool isVideo() const { return true; } virtual bool hasVideo() const { return player() && player()->hasVideo(); } + virtual bool supportsFullscreen() const { return player() && player()->supportsFullscreen(); } virtual bool isURLAttribute(Attribute*) const; virtual const QualifiedName& imageSourceAttributeName() const; @@ -66,6 +66,10 @@ public: void updatePosterImage(); + void paint(GraphicsContext*, const IntRect&); + // Used by canvas to gain raw pixel access + void paintCurrentFrameInContext(GraphicsContext*, const IntRect&); + private: OwnPtr<HTMLImageLoader> m_imageLoader; bool m_shouldShowPosterImage; diff --git a/WebCore/html/HTMLViewSourceDocument.cpp b/WebCore/html/HTMLViewSourceDocument.cpp index d4d6df7..13404cc 100644 --- a/WebCore/html/HTMLViewSourceDocument.cpp +++ b/WebCore/html/HTMLViewSourceDocument.cpp @@ -56,9 +56,16 @@ HTMLViewSourceDocument::HTMLViewSourceDocument(Frame* frame, const String& mimeT Tokenizer* HTMLViewSourceDocument::createTokenizer() { - if (implementation()->isTextMIMEType(m_type)) - return createTextTokenizer(this); - return new HTMLTokenizer(this); + // Use HTMLTokenizer if applicable, otherwise use TextTokenizer. + if (m_type == "text/html" || m_type == "application/xhtml+xml" || m_type == "image/svg+xml" || implementation()->isXMLMIMEType(m_type) +#if ENABLE(XHTMLMP) + || m_type == "application/vnd.wap.xhtml+xml" +#endif + ) { + return new HTMLTokenizer(this); + } + + return createTextTokenizer(this); } void HTMLViewSourceDocument::createContainingTable() diff --git a/WebCore/html/HTMLViewSourceDocument.h b/WebCore/html/HTMLViewSourceDocument.h index 4e725c7..57a8f21 100644 --- a/WebCore/html/HTMLViewSourceDocument.h +++ b/WebCore/html/HTMLViewSourceDocument.h @@ -38,9 +38,10 @@ public: { return new HTMLViewSourceDocument(frame, mimeType); } - + + // Returns HTMLTokenizer or TextTokenizer based on m_type. virtual Tokenizer* createTokenizer(); - + void addViewSourceToken(Token*); // Used by the HTML tokenizer. void addViewSourceText(const String&); // Used by the plaintext tokenizer. void addViewSourceDoctypeToken(DoctypeToken*); diff --git a/WebCore/html/ImageData.idl b/WebCore/html/ImageData.idl index 7f37b52..8025de1 100644 --- a/WebCore/html/ImageData.idl +++ b/WebCore/html/ImageData.idl @@ -29,8 +29,8 @@ module html { interface [ + CustomToJS, GenerateConstructor, - GenerateToJS ] ImageData { readonly attribute long width; readonly attribute long height; diff --git a/WebCore/html/PreloadScanner.cpp b/WebCore/html/PreloadScanner.cpp index 6ea4451..8762b7e 100644 --- a/WebCore/html/PreloadScanner.cpp +++ b/WebCore/html/PreloadScanner.cpp @@ -696,12 +696,12 @@ void PreloadScanner::processAttribute() String value(m_attributeValue.data(), m_attributeValue.size()); if (tag == scriptTag || tag == imgTag) { if (attribute == srcAttr && m_urlToLoad.isEmpty()) - m_urlToLoad = parseURL(value); + m_urlToLoad = deprecatedParseURL(value); else if (attribute == charsetAttr) m_charset = value; } else if (tag == linkTag) { if (attribute == hrefAttr && m_urlToLoad.isEmpty()) - m_urlToLoad = parseURL(value); + m_urlToLoad = deprecatedParseURL(value); else if (attribute == relAttr) { bool styleSheet = false; bool alternate = false; @@ -854,7 +854,7 @@ void PreloadScanner::emitCSSRule() String rule(m_cssRule.data(), m_cssRule.size()); if (equalIgnoringCase(rule, "import") && !m_cssRuleValue.isEmpty()) { String value(m_cssRuleValue.data(), m_cssRuleValue.size()); - String url = parseURL(value); + String url = deprecatedParseURL(value); if (!url.isEmpty()) m_document->docLoader()->preload(CachedResource::CSSStyleSheet, url, String(), scanningBody()); } diff --git a/WebCore/html/PreloadScanner.h b/WebCore/html/PreloadScanner.h index f1d2cf8..6022ee7 100644 --- a/WebCore/html/PreloadScanner.h +++ b/WebCore/html/PreloadScanner.h @@ -37,7 +37,7 @@ namespace WebCore { class CachedResourceClient; class Document; - class PreloadScanner : Noncopyable { + class PreloadScanner : public Noncopyable { public: PreloadScanner(Document*); ~PreloadScanner(); diff --git a/WebCore/html/TimeRanges.h b/WebCore/html/TimeRanges.h index 37820dc..6be8c4e 100644 --- a/WebCore/html/TimeRanges.h +++ b/WebCore/html/TimeRanges.h @@ -64,7 +64,8 @@ private: // We consider all the Ranges to be semi-bounded as follow: [start, end[ struct Range { Range() { } - Range(float start, float end) { + Range(float start, float end) + { m_start = start; m_end = end; } diff --git a/WebCore/html/TimeRanges.idl b/WebCore/html/TimeRanges.idl index c6776a9..d8686be 100644 --- a/WebCore/html/TimeRanges.idl +++ b/WebCore/html/TimeRanges.idl @@ -25,7 +25,7 @@ module html { -interface TimeRanges { +interface [Conditional=VIDEO] TimeRanges { readonly attribute unsigned long length; float start(in unsigned long index) raises (DOMException); diff --git a/WebCore/html/ValidityState.cpp b/WebCore/html/ValidityState.cpp new file mode 100644 index 0000000..86227d4 --- /dev/null +++ b/WebCore/html/ValidityState.cpp @@ -0,0 +1,42 @@ +/* + * This file is part of the WebKit project. + * + * Copyright (C) 2009 Michelangelo De Simone <micdesim@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "ValidityState.h" + +namespace WebCore { + +ValidityState::ValidityState(HTMLFormControlElement* parent) + : m_control(parent) +{ + ASSERT(parent); +} + +bool ValidityState::valid() +{ + bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow() || + tooLong() || patternMismatch() || valueMissing() || customError(); + + return !someError; +} + +} // namespace diff --git a/WebCore/html/ValidityState.h b/WebCore/html/ValidityState.h new file mode 100644 index 0000000..794822a --- /dev/null +++ b/WebCore/html/ValidityState.h @@ -0,0 +1,61 @@ +/* + * This file is part of the WebKit project. + * + * Copyright (C) 2009 Michelangelo De Simone <micdesim@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef ValidityState_h +#define ValidityState_h + +#include "HTMLFormControlElement.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + + class ValidityState : public RefCounted<ValidityState> { + public: + static PassRefPtr<ValidityState> create(HTMLFormControlElement* owner) + { + return adoptRef(new ValidityState(owner)); + } + + HTMLFormControlElement* control() const { return m_control; } + + void setCustomErrorMessage(const String& message) { m_customErrorMessage = message; } + + bool valueMissing() { return control()->valueMissing(); } + bool typeMismatch() { return false; } + bool patternMismatch() { return control()->patternMismatch(); } + bool tooLong() { return false; } + bool rangeUnderflow() { return false; } + bool rangeOverflow() { return false; } + bool stepMismatch() { return false; } + bool customError() { return !m_customErrorMessage.isEmpty(); } + bool valid(); + + private: + ValidityState(HTMLFormControlElement*); + HTMLFormControlElement* m_control; + String m_customErrorMessage; + }; + +} // namespace WebCore + +#endif // ValidityState_h diff --git a/WebCore/html/ValidityState.idl b/WebCore/html/ValidityState.idl new file mode 100644 index 0000000..b926852 --- /dev/null +++ b/WebCore/html/ValidityState.idl @@ -0,0 +1,36 @@ +/* + * This file is part of the WebKit project. + * + * Copyright (C) 2009 Michelangelo De Simone <micdesim@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +module html { + + interface ValidityState { + readonly attribute boolean valueMissing; + readonly attribute boolean typeMismatch; + readonly attribute boolean patternMismatch; + readonly attribute boolean tooLong; + readonly attribute boolean rangeUnderflow; + readonly attribute boolean rangeOverflow; + readonly attribute boolean stepMismatch; + readonly attribute boolean customError; + readonly attribute boolean valid; + }; +} diff --git a/WebCore/html/CanvasGradient.cpp b/WebCore/html/canvas/CanvasGradient.cpp index fd48194..fd48194 100644 --- a/WebCore/html/CanvasGradient.cpp +++ b/WebCore/html/canvas/CanvasGradient.cpp diff --git a/WebCore/html/CanvasGradient.h b/WebCore/html/canvas/CanvasGradient.h index 0a77652..0a77652 100644 --- a/WebCore/html/CanvasGradient.h +++ b/WebCore/html/canvas/CanvasGradient.h diff --git a/WebCore/html/CanvasGradient.idl b/WebCore/html/canvas/CanvasGradient.idl index a925a26..a925a26 100644 --- a/WebCore/html/CanvasGradient.idl +++ b/WebCore/html/canvas/CanvasGradient.idl diff --git a/WebCore/html/CanvasPattern.cpp b/WebCore/html/canvas/CanvasPattern.cpp index 62a4620..62a4620 100644 --- a/WebCore/html/CanvasPattern.cpp +++ b/WebCore/html/canvas/CanvasPattern.cpp diff --git a/WebCore/html/CanvasPattern.h b/WebCore/html/canvas/CanvasPattern.h index 6c012d1..6c012d1 100644 --- a/WebCore/html/CanvasPattern.h +++ b/WebCore/html/canvas/CanvasPattern.h diff --git a/WebCore/html/CanvasPattern.idl b/WebCore/html/canvas/CanvasPattern.idl index 1cac8f8..1cac8f8 100644 --- a/WebCore/html/CanvasPattern.idl +++ b/WebCore/html/canvas/CanvasPattern.idl diff --git a/WebCore/html/CanvasPixelArray.cpp b/WebCore/html/canvas/CanvasPixelArray.cpp index a377c83..a377c83 100644 --- a/WebCore/html/CanvasPixelArray.cpp +++ b/WebCore/html/canvas/CanvasPixelArray.cpp diff --git a/WebCore/html/CanvasPixelArray.h b/WebCore/html/canvas/CanvasPixelArray.h index b91a642..b91a642 100644 --- a/WebCore/html/CanvasPixelArray.h +++ b/WebCore/html/canvas/CanvasPixelArray.h diff --git a/WebCore/html/CanvasPixelArray.idl b/WebCore/html/canvas/CanvasPixelArray.idl index c815788..c815788 100644 --- a/WebCore/html/CanvasPixelArray.idl +++ b/WebCore/html/canvas/CanvasPixelArray.idl diff --git a/WebCore/html/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp index f2541ed..20718e9 100644 --- a/WebCore/html/CanvasRenderingContext2D.cpp +++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) * Copyright (C) 2007 Alp Toker <alp@atoker.com> * Copyright (C) 2008 Eric Seidel <eric@webkit.org> @@ -56,11 +56,12 @@ #include "Settings.h" #include "StrokeStyleApplier.h" #include "TextMetrics.h" +#include "HTMLVideoElement.h" #include <stdio.h> - #include <wtf/ByteArray.h> #include <wtf/MathExtras.h> #include <wtf/OwnPtr.h> +#include <wtf/UnusedParam.h> using namespace std; @@ -545,7 +546,10 @@ void CanvasRenderingContext2D::lineTo(float x, float y) return; if (!state().m_invertibleCTM) return; - m_path.addLineTo(FloatPoint(x, y)); + if (!m_path.hasCurrentPoint()) + m_path.moveTo(FloatPoint(x, y)); + else + m_path.addLineTo(FloatPoint(x, y)); } void CanvasRenderingContext2D::quadraticCurveTo(float cpx, float cpy, float x, float y) @@ -554,7 +558,10 @@ void CanvasRenderingContext2D::quadraticCurveTo(float cpx, float cpy, float x, f return; if (!state().m_invertibleCTM) return; - m_path.addQuadCurveTo(FloatPoint(cpx, cpy), FloatPoint(x, y)); + if (!m_path.hasCurrentPoint()) + m_path.moveTo(FloatPoint(x, y)); + else + m_path.addQuadCurveTo(FloatPoint(cpx, cpy), FloatPoint(x, y)); } void CanvasRenderingContext2D::bezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y) @@ -563,7 +570,10 @@ void CanvasRenderingContext2D::bezierCurveTo(float cp1x, float cp1y, float cp2x, return; if (!state().m_invertibleCTM) return; - m_path.addBezierCurveTo(FloatPoint(cp1x, cp1y), FloatPoint(cp2x, cp2y), FloatPoint(x, y)); + if (!m_path.hasCurrentPoint()) + m_path.moveTo(FloatPoint(x, y)); + else + m_path.addBezierCurveTo(FloatPoint(cp1x, cp1y), FloatPoint(cp2x, cp2y), FloatPoint(x, y)); } void CanvasRenderingContext2D::arcTo(float x0, float y0, float x1, float y1, float r, ExceptionCode& ec) @@ -912,6 +922,15 @@ static IntSize size(HTMLImageElement* image) return IntSize(); } +#if ENABLE(VIDEO) +static IntSize size(HTMLVideoElement* video) +{ + if (MediaPlayer* player = video->player()) + return player->naturalSize(); + return IntSize(); +} +#endif + static inline FloatRect normalizeRect(const FloatRect& rect) { return FloatRect(min(rect.x(), rect.right()), @@ -920,6 +939,20 @@ static inline FloatRect normalizeRect(const FloatRect& rect) max(rect.height(), -rect.height())); } +void CanvasRenderingContext2D::checkOrigin(const KURL& url) +{ + RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url); + if (!m_canvas->document()->securityOrigin()->canAccess(origin.get())) + m_canvas->setOriginTainted(); +} + +void CanvasRenderingContext2D::checkOrigin(const String& url) +{ + RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(url); + if (!m_canvas->document()->securityOrigin()->canAccess(origin.get())) + m_canvas->setOriginTainted(); +} + void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float y) { ASSERT(image); @@ -936,13 +969,6 @@ void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, drawImage(image, FloatRect(0, 0, s.width(), s.height()), FloatRect(x, y, width, height), ec); } -void CanvasRenderingContext2D::checkOrigin(const KURL& url) -{ - RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url); - if (!m_canvas->document()->securityOrigin()->canAccess(origin.get())) - m_canvas->setOriginTainted(); -} - void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode& ec) { @@ -978,13 +1004,7 @@ void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, const FloatRec FloatRect sourceRect = c->roundToDevicePixels(srcRect); FloatRect destRect = c->roundToDevicePixels(dstRect); willDraw(destRect); -#if PLATFORM(SGL) - // this seems like a bug fix as well. - // can't see how the std code can use destRect/sourceRect, since they are scaled by matrix - c->drawImage(cachedImage->image(), dstRect, srcRect, state().m_globalComposite); -#else c->drawImage(cachedImage->image(), destRect, sourceRect, state().m_globalComposite); -#endif } void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, float x, float y) @@ -1039,6 +1059,64 @@ void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, const FloatR // FIXME: Arguably willDraw should become didDraw and occur after drawing calls and not before them to avoid problems like this. } +#if ENABLE(VIDEO) +void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, float x, float y) +{ + ASSERT(video); + IntSize s = size(video); + ExceptionCode ec; + drawImage(video, x, y, s.width(), s.height(), ec); +} + +void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, + float x, float y, float width, float height, ExceptionCode& ec) +{ + ASSERT(video); + IntSize s = size(video); + drawImage(video, FloatRect(0, 0, s.width(), s.height()), FloatRect(x, y, width, height), ec); +} + +void CanvasRenderingContext2D::drawImage(HTMLVideoElement* video, const FloatRect& srcRect, const FloatRect& dstRect, + ExceptionCode& ec) +{ + ASSERT(video); + + ec = 0; + FloatRect videoRect = FloatRect(FloatPoint(), size(video)); + if (!videoRect.contains(normalizeRect(srcRect)) || srcRect.width() == 0 || srcRect.height() == 0) { + ec = INDEX_SIZE_ERR; + return; + } + + if (!dstRect.width() || !dstRect.height()) + return; + + GraphicsContext* c = drawingContext(); + if (!c) + return; + if (!state().m_invertibleCTM) + return; + + if (m_canvas->originClean()) + checkOrigin(video->currentSrc()); + + if (m_canvas->originClean() && !video->hasSingleSecurityOrigin()) + m_canvas->setOriginTainted(); + + FloatRect sourceRect = c->roundToDevicePixels(srcRect); + FloatRect destRect = c->roundToDevicePixels(dstRect); + willDraw(destRect); + + c->save(); + c->clip(destRect); + c->translate(destRect.x(), destRect.y()); + c->scale(FloatSize(destRect.width()/sourceRect.width(), destRect.height()/sourceRect.height())); + c->translate(-sourceRect.x(), -sourceRect.y()); + video->paintCurrentFrameInContext(c, IntRect(IntPoint(), size(video))); + c->restore(); +} +#endif + // FIXME: Why isn't this just another overload of drawImage? Why have a different name? void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement* image, float sx, float sy, float sw, float sh, @@ -1089,6 +1167,8 @@ void CanvasRenderingContext2D::prepareGradientForDashboard(CanvasGradient* gradi if (Settings* settings = m_canvas->document()->settings()) if (settings->usesDashboardBackwardCompatibilityMode()) gradient->setDashboardCompatibilityMode(); +#else + UNUSED_PARAM(gradient); #endif } @@ -1446,7 +1526,7 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo // FIXME: The rect is not big enough for miters on stroked text. IntRect maskRect = enclosingIntRect(textRect); - OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(maskRect.size(), false); + OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(maskRect.size()); GraphicsContext* maskImageContext = maskImage->context(); diff --git a/WebCore/html/CanvasRenderingContext2D.h b/WebCore/html/canvas/CanvasRenderingContext2D.h index d74659e..9648ffc 100644 --- a/WebCore/html/CanvasRenderingContext2D.h +++ b/WebCore/html/canvas/CanvasRenderingContext2D.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -47,13 +47,14 @@ namespace WebCore { class GraphicsContext; class HTMLCanvasElement; class HTMLImageElement; + class HTMLVideoElement; class ImageData; class KURL; class TextMetrics; typedef int ExceptionCode; - class CanvasRenderingContext2D : Noncopyable { + class CanvasRenderingContext2D : public Noncopyable { public: CanvasRenderingContext2D(HTMLCanvasElement*); @@ -159,6 +160,11 @@ namespace WebCore { void drawImage(HTMLCanvasElement*, float x, float y); void drawImage(HTMLCanvasElement*, float x, float y, float width, float height, ExceptionCode&); void drawImage(HTMLCanvasElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&); +#if ENABLE(VIDEO) + void drawImage(HTMLVideoElement*, float x, float y); + void drawImage(HTMLVideoElement*, float x, float y, float width, float height, ExceptionCode&); + void drawImage(HTMLVideoElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&); +#endif void drawImageFromRect(HTMLImageElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, const String& compositeOperation); @@ -254,6 +260,7 @@ namespace WebCore { void prepareGradientForDashboard(CanvasGradient* gradient) const; void checkOrigin(const KURL&); + void checkOrigin(const String&); HTMLCanvasElement* m_canvas; Vector<State, 1> m_stateStack; diff --git a/WebCore/html/CanvasRenderingContext2D.idl b/WebCore/html/canvas/CanvasRenderingContext2D.idl index a86b47d..a86b47d 100644 --- a/WebCore/html/CanvasRenderingContext2D.idl +++ b/WebCore/html/canvas/CanvasRenderingContext2D.idl diff --git a/WebCore/html/CanvasStyle.cpp b/WebCore/html/canvas/CanvasStyle.cpp index 37308ad..946cac7 100644 --- a/WebCore/html/CanvasStyle.cpp +++ b/WebCore/html/canvas/CanvasStyle.cpp @@ -153,8 +153,6 @@ void CanvasStyle::applyStrokeColor(GraphicsContext* context) clr.setCmykF(m_cyan, m_magenta, m_yellow, m_black, m_alpha); currentPen.setColor(clr); context->platformContext()->setPen(currentPen); -#elif PLATFORM(SGL) - context->setCMYKAStrokeColor(m_cyan, m_magenta, m_yellow, m_black, m_alpha); #else context->setStrokeColor(Color(m_cyan, m_magenta, m_yellow, m_black, m_alpha)); #endif @@ -176,7 +174,7 @@ void CanvasStyle::applyFillColor(GraphicsContext* context) switch (m_type) { case ColorString: { Color c = Color(m_color); - if (c.isValid()){ + if (c.isValid()) { context->setFillColor(c.rgb()); break; } @@ -187,7 +185,7 @@ void CanvasStyle::applyFillColor(GraphicsContext* context) } case ColorStringWithAlpha: { Color c = Color(m_color); - if (c.isValid()){ + if (c.isValid()) { context->setFillColor(colorWithOverrideAlpha(c.rgb(), m_alpha)); break; } @@ -216,8 +214,6 @@ void CanvasStyle::applyFillColor(GraphicsContext* context) clr.setCmykF(m_cyan, m_magenta, m_yellow, m_black, m_alpha); currentBrush.setColor(clr); context->platformContext()->setBrush(currentBrush); -#elif PLATFORM(SGL) - context->setCMYKAFillColor(m_cyan, m_magenta, m_yellow, m_black, m_alpha); #else context->setFillColor(Color(m_cyan, m_magenta, m_yellow, m_black, m_alpha)); #endif diff --git a/WebCore/html/CanvasStyle.h b/WebCore/html/canvas/CanvasStyle.h index fe01bd1..fe01bd1 100644 --- a/WebCore/html/CanvasStyle.h +++ b/WebCore/html/canvas/CanvasStyle.h |