summaryrefslogtreecommitdiffstats
path: root/WebCore/html
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-08-27 11:02:25 +0100
committerSteve Block <steveblock@google.com>2010-09-02 17:17:20 +0100
commite8b154fd68f9b33be40a3590e58347f353835f5c (patch)
tree0733ce26384183245aaa5656af26c653636fe6c1 /WebCore/html
parentda56157816334089526a7a115a85fd85a6e9a1dc (diff)
downloadexternal_webkit-e8b154fd68f9b33be40a3590e58347f353835f5c.zip
external_webkit-e8b154fd68f9b33be40a3590e58347f353835f5c.tar.gz
external_webkit-e8b154fd68f9b33be40a3590e58347f353835f5c.tar.bz2
Merge WebKit at r66079 : Initial merge by git
Change-Id: Ie2e1440fb9d487d24e52c247342c076fecaecac7
Diffstat (limited to 'WebCore/html')
-rw-r--r--WebCore/html/FileReader.cpp6
-rw-r--r--WebCore/html/FileReader.h2
-rw-r--r--WebCore/html/FileStream.cpp151
-rw-r--r--WebCore/html/FileStream.h101
-rw-r--r--WebCore/html/FileStreamProxy.cpp35
-rw-r--r--WebCore/html/FileStreamProxy.h27
-rw-r--r--WebCore/html/FileThreadTask.h8
-rw-r--r--WebCore/html/FileWriter.cpp (renamed from WebCore/html/FileStreamClient.h)67
-rw-r--r--WebCore/html/FileWriter.h112
-rw-r--r--WebCore/html/FileWriter.idl62
-rw-r--r--WebCore/html/HTMLAnchorElement.h2
-rw-r--r--WebCore/html/HTMLAppletElement.h2
-rw-r--r--WebCore/html/HTMLAreaElement.cpp2
-rw-r--r--WebCore/html/HTMLAreaElement.h2
-rw-r--r--WebCore/html/HTMLAudioElement.h1
-rw-r--r--WebCore/html/HTMLBRElement.h3
-rw-r--r--WebCore/html/HTMLBaseElement.h3
-rw-r--r--WebCore/html/HTMLBaseFontElement.h3
-rw-r--r--WebCore/html/HTMLBlockquoteElement.h3
-rw-r--r--WebCore/html/HTMLBodyElement.h3
-rw-r--r--WebCore/html/HTMLCanvasElement.cpp34
-rw-r--r--WebCore/html/HTMLCanvasElement.h5
-rw-r--r--WebCore/html/HTMLConstructionSite.cpp21
-rw-r--r--WebCore/html/HTMLConstructionSite.h6
-rw-r--r--WebCore/html/HTMLDListElement.h3
-rw-r--r--WebCore/html/HTMLDataGridCellElement.h4
-rw-r--r--WebCore/html/HTMLDataGridColElement.h2
-rw-r--r--WebCore/html/HTMLDataGridElement.cpp7
-rw-r--r--WebCore/html/HTMLDataGridElement.h3
-rw-r--r--WebCore/html/HTMLDataGridRowElement.cpp7
-rw-r--r--WebCore/html/HTMLDataGridRowElement.h3
-rw-r--r--WebCore/html/HTMLDataListElement.cpp5
-rw-r--r--WebCore/html/HTMLDataListElement.h2
-rw-r--r--WebCore/html/HTMLDirectoryElement.h3
-rw-r--r--WebCore/html/HTMLDivElement.h3
-rw-r--r--WebCore/html/HTMLDocument.cpp11
-rw-r--r--WebCore/html/HTMLDocument.h4
-rw-r--r--WebCore/html/HTMLDocumentParser.cpp109
-rw-r--r--WebCore/html/HTMLDocumentParser.h20
-rw-r--r--WebCore/html/HTMLElement.cpp354
-rw-r--r--WebCore/html/HTMLElement.h15
-rw-r--r--WebCore/html/HTMLElementStack.cpp4
-rw-r--r--WebCore/html/HTMLEmbedElement.cpp4
-rw-r--r--WebCore/html/HTMLEmbedElement.h3
-rw-r--r--WebCore/html/HTMLFieldSetElement.cpp5
-rw-r--r--WebCore/html/HTMLFieldSetElement.h3
-rw-r--r--WebCore/html/HTMLFontElement.h3
-rw-r--r--WebCore/html/HTMLFormCollection.cpp2
-rw-r--r--WebCore/html/HTMLFormControlElement.cpp7
-rw-r--r--WebCore/html/HTMLFormControlElement.h3
-rw-r--r--WebCore/html/HTMLFormElement.cpp2
-rw-r--r--WebCore/html/HTMLFormElement.h3
-rw-r--r--WebCore/html/HTMLFrameElement.h3
-rw-r--r--WebCore/html/HTMLFrameSetElement.cpp9
-rw-r--r--WebCore/html/HTMLFrameSetElement.h4
-rw-r--r--WebCore/html/HTMLHRElement.h3
-rw-r--r--WebCore/html/HTMLHeadElement.cpp17
-rw-r--r--WebCore/html/HTMLHeadElement.h6
-rw-r--r--WebCore/html/HTMLHeadingElement.cpp14
-rw-r--r--WebCore/html/HTMLHeadingElement.h4
-rw-r--r--WebCore/html/HTMLHtmlElement.cpp6
-rw-r--r--WebCore/html/HTMLHtmlElement.h4
-rw-r--r--WebCore/html/HTMLIFrameElement.h3
-rw-r--r--WebCore/html/HTMLImageElement.h3
-rw-r--r--WebCore/html/HTMLInputElement.cpp18
-rw-r--r--WebCore/html/HTMLInputElement.h3
-rw-r--r--WebCore/html/HTMLIsIndexElement.h2
-rw-r--r--WebCore/html/HTMLKeygenElement.cpp5
-rw-r--r--WebCore/html/HTMLKeygenElement.h1
-rw-r--r--WebCore/html/HTMLLIElement.h3
-rw-r--r--WebCore/html/HTMLLabelElement.h2
-rw-r--r--WebCore/html/HTMLLinkElement.h3
-rw-r--r--WebCore/html/HTMLMapElement.cpp6
-rw-r--r--WebCore/html/HTMLMapElement.h4
-rw-r--r--WebCore/html/HTMLMarqueeElement.h3
-rw-r--r--WebCore/html/HTMLMediaElement.cpp6
-rw-r--r--WebCore/html/HTMLMediaElement.h1
-rw-r--r--WebCore/html/HTMLMenuElement.h3
-rw-r--r--WebCore/html/HTMLMetaElement.h3
-rw-r--r--WebCore/html/HTMLMeterElement.cpp2
-rw-r--r--WebCore/html/HTMLModElement.h3
-rw-r--r--WebCore/html/HTMLNoScriptElement.cpp5
-rw-r--r--WebCore/html/HTMLNoScriptElement.h1
-rw-r--r--WebCore/html/HTMLOListElement.h3
-rw-r--r--WebCore/html/HTMLObjectElement.cpp33
-rw-r--r--WebCore/html/HTMLObjectElement.h2
-rw-r--r--WebCore/html/HTMLOptGroupElement.cpp6
-rw-r--r--WebCore/html/HTMLOptGroupElement.h1
-rw-r--r--WebCore/html/HTMLOptionElement.cpp5
-rw-r--r--WebCore/html/HTMLOptionElement.h3
-rw-r--r--WebCore/html/HTMLParagraphElement.cpp5
-rw-r--r--WebCore/html/HTMLParagraphElement.h4
-rw-r--r--WebCore/html/HTMLParamElement.h8
-rw-r--r--WebCore/html/HTMLParserScheduler.h8
-rw-r--r--WebCore/html/HTMLPlugInElement.cpp5
-rw-r--r--WebCore/html/HTMLPlugInElement.h3
-rw-r--r--WebCore/html/HTMLPreElement.h3
-rw-r--r--WebCore/html/HTMLPreloadScanner.cpp10
-rw-r--r--WebCore/html/HTMLPreloadScanner.h6
-rw-r--r--WebCore/html/HTMLProgressElement.cpp2
-rw-r--r--WebCore/html/HTMLQuoteElement.h3
-rw-r--r--WebCore/html/HTMLScriptElement.h4
-rw-r--r--WebCore/html/HTMLScriptRunner.cpp9
-rw-r--r--WebCore/html/HTMLScriptRunner.h9
-rw-r--r--WebCore/html/HTMLSelectElement.cpp7
-rw-r--r--WebCore/html/HTMLSelectElement.h3
-rw-r--r--WebCore/html/HTMLSourceElement.h3
-rw-r--r--WebCore/html/HTMLStyleElement.h4
-rw-r--r--WebCore/html/HTMLTableCaptionElement.h3
-rw-r--r--WebCore/html/HTMLTableCellElement.h3
-rw-r--r--WebCore/html/HTMLTableColElement.cpp20
-rw-r--r--WebCore/html/HTMLTableColElement.h3
-rw-r--r--WebCore/html/HTMLTableElement.cpp25
-rw-r--r--WebCore/html/HTMLTableElement.h6
-rw-r--r--WebCore/html/HTMLTableRowElement.cpp22
-rw-r--r--WebCore/html/HTMLTableRowElement.h6
-rw-r--r--WebCore/html/HTMLTableSectionElement.cpp22
-rw-r--r--WebCore/html/HTMLTableSectionElement.h5
-rw-r--r--WebCore/html/HTMLTextAreaElement.h2
-rw-r--r--WebCore/html/HTMLTitleElement.h2
-rw-r--r--WebCore/html/HTMLToken.h2
-rw-r--r--WebCore/html/HTMLTokenizer.h5
-rw-r--r--WebCore/html/HTMLTreeBuilder.cpp260
-rw-r--r--WebCore/html/HTMLTreeBuilder.h53
-rw-r--r--WebCore/html/HTMLUListElement.h3
-rw-r--r--WebCore/html/HTMLVideoElement.cpp4
-rw-r--r--WebCore/html/HTMLVideoElement.h1
-rw-r--r--WebCore/html/HTMLViewSourceDocument.cpp4
-rw-r--r--WebCore/html/HTMLViewSourceDocument.h2
-rw-r--r--WebCore/html/HTMLViewSourceParser.cpp14
-rw-r--r--WebCore/html/HTMLViewSourceParser.h13
-rw-r--r--WebCore/html/LegacyHTMLTreeBuilder.cpp1786
-rw-r--r--WebCore/html/LegacyHTMLTreeBuilder.h306
-rw-r--r--WebCore/html/StepRange.cpp2
-rw-r--r--WebCore/html/ThreadableBlobRegistry.cpp6
-rw-r--r--WebCore/html/ValidityState.cpp2
-rw-r--r--WebCore/html/ValidityState.h2
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext.cpp13
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext.h1
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext2D.cpp28
-rw-r--r--WebCore/html/canvas/Float32Array.cpp2
-rw-r--r--WebCore/html/canvas/Float32Array.h2
-rw-r--r--WebCore/html/canvas/TypedArrayBase.h2
-rw-r--r--WebCore/html/canvas/WebGLBuffer.cpp1
-rw-r--r--WebCore/html/canvas/WebGLBuffer.h1
-rw-r--r--WebCore/html/canvas/WebGLFramebuffer.cpp2
-rw-r--r--WebCore/html/canvas/WebGLRenderingContext.cpp347
-rw-r--r--WebCore/html/canvas/WebGLRenderingContext.h23
-rw-r--r--WebCore/html/canvas/WebGLRenderingContext.idl345
-rw-r--r--WebCore/html/canvas/WebGLTexture.cpp5
-rw-r--r--WebCore/html/canvas/WebGLTexture.h2
151 files changed, 1106 insertions, 3806 deletions
diff --git a/WebCore/html/FileReader.cpp b/WebCore/html/FileReader.cpp
index e99fdc4..d600d40 100644
--- a/WebCore/html/FileReader.cpp
+++ b/WebCore/html/FileReader.cpp
@@ -189,10 +189,10 @@ void FileReader::didGetSize(long long size)
m_streamProxy->openForRead(m_fileBlob->path(), start, m_totalBytes);
}
-void FileReader::didOpen(ExceptionCode ec)
+void FileReader::didOpen(bool success)
{
- if (ec) {
- didFail(ec);
+ if (!success) {
+ didFail(NOT_READABLE_ERR);
return;
}
diff --git a/WebCore/html/FileReader.h b/WebCore/html/FileReader.h
index 2237af5..ee15968 100644
--- a/WebCore/html/FileReader.h
+++ b/WebCore/html/FileReader.h
@@ -89,7 +89,7 @@ public:
// FileStreamClient
virtual void didStart();
virtual void didGetSize(long long);
- virtual void didOpen(ExceptionCode);
+ virtual void didOpen(bool);
virtual void didRead(int);
using RefCounted<FileReader>::ref;
diff --git a/WebCore/html/FileStream.cpp b/WebCore/html/FileStream.cpp
deleted file mode 100644
index a89c67a..0000000
--- a/WebCore/html/FileStream.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(BLOB) || ENABLE(FILE_WRITER)
-
-#include "FileStream.h"
-
-#include "Blob.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
-FileStream::FileStream()
- : m_handle(invalidPlatformFileHandle)
- , m_bytesProcessed(0)
- , m_totalBytesToRead(0)
-{
-}
-
-FileStream::~FileStream()
-{
- ASSERT(!isHandleValid(m_handle));
-}
-
-// FIXME: To be removed when we switch to using BlobData.
-void FileStream::start()
-{
-}
-
-void FileStream::stop()
-{
- close();
-}
-
-long long FileStream::getSize(const String& path, double expectedModificationTime)
-{
- // Check the modification time for the possible file change.
- time_t modificationTime;
- if (!getFileModificationTime(path, modificationTime))
- return -1;
- if (expectedModificationTime) {
- if (static_cast<time_t>(expectedModificationTime) != modificationTime)
- return -1;
- }
-
- // Now get the file size.
- long long length;
- if (!getFileSize(path, length))
- return -1;
-
- return length;
-}
-
-ExceptionCode FileStream::openForRead(const String& path, long long offset, long long length)
-{
- if (isHandleValid(m_handle))
- return 0;
-
- // Open the file.
- m_handle = openFile(path, OpenForRead);
- if (!isHandleValid(m_handle))
- return NOT_READABLE_ERR;
-
- // Jump to the beginning position if the file has been sliced.
- if (offset > 0) {
- if (seekFile(m_handle, offset, SeekFromBeginning) < 0)
- return NOT_READABLE_ERR;
- }
-
- m_totalBytesToRead = length;
- m_bytesProcessed = 0;
-
- return 0;
-}
-
-ExceptionCode FileStream::openForWrite(const String&)
-{
- // FIXME: to be implemented.
- return NOT_SUPPORTED_ERR;
-}
-
-void FileStream::close()
-{
- if (isHandleValid(m_handle)) {
- closeFile(m_handle);
- m_handle = invalidPlatformFileHandle;
- }
-}
-
-int FileStream::read(char* buffer, int bufferSize)
-{
- if (!isHandleValid(m_handle))
- return -1;
-
- long long remaining = m_totalBytesToRead - m_bytesProcessed;
- int bytesToRead = (remaining < bufferSize) ? static_cast<int>(remaining) : bufferSize;
- int bytesRead = 0;
- if (bytesToRead > 0)
- bytesRead = readFromFile(m_handle, buffer, bytesToRead);
- if (bytesRead < 0)
- return -1;
- if (bytesRead > 0)
- m_bytesProcessed += bytesRead;
-
- return bytesRead;
-}
-
-int FileStream::write(Blob*, long long, int)
-{
- // FIXME: to be implemented.
- return -1;
-}
-
-ExceptionCode FileStream::truncate(long long)
-{
- // FIXME: to be implemented.
- return NOT_SUPPORTED_ERR;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(BLOB) || ENABLE(FILE_WRITER)
diff --git a/WebCore/html/FileStream.h b/WebCore/html/FileStream.h
deleted file mode 100644
index e299fe4..0000000
--- a/WebCore/html/FileStream.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FileStream_h
-#define FileStream_h
-
-#if ENABLE(BLOB) || ENABLE(FILE_WRITER)
-
-#include "ExceptionCode.h"
-#include "FileSystem.h"
-#include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class Blob;
-
-// All methods are synchronous.
-class FileStream : public RefCounted<FileStream> {
-public:
- static PassRefPtr<FileStream> create()
- {
- return adoptRef(new FileStream());
- }
- virtual ~FileStream();
-
- // FIXME: To be removed when we switch to using BlobData.
- void start();
-
- // Aborts the operation.
- void stop();
-
- // Gets the size of a file. Also validates if the file has been changed or not if the expected modification time is provided, i.e. non-zero.
- // Returns total number of bytes if successful. -1 otherwise.
- long long getSize(const String& path, double expectedModificationTime);
-
- // Opens a file for reading. The reading starts at the specified offset and lasts till the specified length.
- // Returns 0 on success. Exception code otherwise.
- ExceptionCode openForRead(const String& path, long long offset, long long length);
-
- // Opens a file for writing.
- // Returns 0 on success. Exception code otherwise.
- ExceptionCode openForWrite(const String& path);
-
- // Closes the file.
- void close();
-
- // Reads a file into the provided data buffer.
- // Returns number of bytes being read on success. -1 otherwise.
- // If 0 is returned, it means that the reading is completed.
- int read(char* buffer, int length);
-
- // Writes a blob to the file.
- // Returns number of bytes being written on success. -1 otherwise.
- int write(Blob*, long long position, int length);
-
- // Truncates the file to the specified position.
- // Returns 0 on success. Exception code otherwise.
- ExceptionCode truncate(long long position);
-
-private:
- FileStream();
-
- PlatformFileHandle m_handle;
- long long m_bytesProcessed;
- long long m_totalBytesToRead;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(BLOB) || ENABLE(FILE_WRITER)
-
-#endif // FileStream_h
diff --git a/WebCore/html/FileStreamProxy.cpp b/WebCore/html/FileStreamProxy.cpp
index f50b7e8..30813d3 100644
--- a/WebCore/html/FileStreamProxy.cpp
+++ b/WebCore/html/FileStreamProxy.cpp
@@ -37,7 +37,6 @@
#include "Blob.h"
#include "CrossThreadTask.h"
#include "FileStream.h"
-#include "FileStreamClient.h"
#include "FileThread.h"
#include "FileThreadTask.h"
#include "PlatformString.h"
@@ -46,8 +45,8 @@
namespace WebCore {
inline FileStreamProxy::FileStreamProxy(ScriptExecutionContext* context, FileStreamClient* client)
- : m_context(context)
- , m_client(client)
+ : AsyncFileStream(client)
+ , m_context(context)
, m_stream(FileStream::create())
{
}
@@ -91,7 +90,7 @@ void FileStreamProxy::startOnFileThread()
void FileStreamProxy::stop()
{
// Clear the client so that we won't be calling callbacks on the client.
- m_client = 0;
+ setClient(0);
fileThread()->unscheduleTasks(m_stream.get());
fileThread()->postTask(createFileThreadTask(this, &FileStreamProxy::stopOnFileThread));
@@ -126,10 +125,10 @@ void FileStreamProxy::getSizeOnFileThread(const String& path, double expectedMod
m_context->postTask(createCallbackTask(&didGetSize, this, size));
}
-static void didOpen(ScriptExecutionContext*, FileStreamProxy* proxy, ExceptionCode ec)
+static void didOpen(ScriptExecutionContext*, FileStreamProxy* proxy, bool success)
{
if (proxy->client())
- proxy->client()->didOpen(ec);
+ proxy->client()->didOpen(success);
}
void FileStreamProxy::openForRead(const String& path, long long offset, long long length)
@@ -139,8 +138,8 @@ void FileStreamProxy::openForRead(const String& path, long long offset, long lon
void FileStreamProxy::openForReadOnFileThread(const String& path, long long offset, long long length)
{
- ExceptionCode ec = m_stream->openForRead(path, offset, length);
- m_context->postTask(createCallbackTask(&didOpen, this, ec));
+ bool success = m_stream->openForRead(path, offset, length);
+ m_context->postTask(createCallbackTask(&didOpen, this, success));
}
void FileStreamProxy::openForWrite(const String& path)
@@ -150,8 +149,8 @@ void FileStreamProxy::openForWrite(const String& path)
void FileStreamProxy::openForWriteOnFileThread(const String& path)
{
- ExceptionCode ec = m_stream->openForWrite(path);
- m_context->postTask(createCallbackTask(&didOpen, this, ec));
+ bool success = m_stream->openForWrite(path);
+ m_context->postTask(createCallbackTask(&didOpen, this, success));
}
void FileStreamProxy::close()
@@ -187,21 +186,21 @@ static void didWrite(ScriptExecutionContext*, FileStreamProxy* proxy, int bytesW
proxy->client()->didWrite(bytesWritten);
}
-void FileStreamProxy::write(Blob* blob, long long position, int length)
+void FileStreamProxy::write(const KURL& blobURL, long long position, int length)
{
- fileThread()->postTask(createFileThreadTask(this, &FileStreamProxy::writeOnFileThread, blob, position, length));
+ fileThread()->postTask(createFileThreadTask(this, &FileStreamProxy::writeOnFileThread, blobURL, position, length));
}
-void FileStreamProxy::writeOnFileThread(Blob* blob, long long position, int length)
+void FileStreamProxy::writeOnFileThread(const KURL& blobURL, long long position, int length)
{
- int bytesWritten = m_stream->write(blob, position, length);
+ int bytesWritten = m_stream->write(blobURL, position, length);
m_context->postTask(createCallbackTask(&didWrite, this, bytesWritten));
}
-static void didTruncate(ScriptExecutionContext*, FileStreamProxy* proxy, ExceptionCode ec)
+static void didTruncate(ScriptExecutionContext*, FileStreamProxy* proxy, bool success)
{
if (proxy->client())
- proxy->client()->didTruncate(ec);
+ proxy->client()->didTruncate(success);
}
void FileStreamProxy::truncate(long long position)
@@ -211,8 +210,8 @@ void FileStreamProxy::truncate(long long position)
void FileStreamProxy::truncateOnFileThread(long long position)
{
- ExceptionCode ec = m_stream->truncate(position);
- m_context->postTask(createCallbackTask(&didTruncate, this, ec));
+ bool success = m_stream->truncate(position);
+ m_context->postTask(createCallbackTask(&didTruncate, this, success));
}
} // namespace WebCore
diff --git a/WebCore/html/FileStreamProxy.h b/WebCore/html/FileStreamProxy.h
index 1d03a58..35a3af8 100644
--- a/WebCore/html/FileStreamProxy.h
+++ b/WebCore/html/FileStreamProxy.h
@@ -34,6 +34,7 @@
#if ENABLE(BLOB) || ENABLE(FILE_WRITER)
+#include "AsyncFileStream.h"
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -41,31 +42,28 @@
namespace WebCore {
-class Blob;
class FileStream;
-class FileStreamClient;
class FileThread;
+class KURL;
class ScriptExecutionContext;
// A proxy module that asynchronously calls corresponding FileStream methods on the file thread. Note: you must call stop() first and then release the reference to destruct the FileStreamProxy instance.
-class FileStreamProxy : public RefCounted<FileStreamProxy> {
+class FileStreamProxy : public AsyncFileStream {
public:
static PassRefPtr<FileStreamProxy> create(ScriptExecutionContext*, FileStreamClient*);
virtual ~FileStreamProxy();
- void getSize(const String& path, double expectedModificationTime);
- void openForRead(const String& path, long long offset, long long length);
- void openForWrite(const String& path);
- void close();
- void read(char* buffer, int length);
- void write(Blob*, long long position, int length);
- void truncate(long long position);
+ virtual void getSize(const String& path, double expectedModificationTime);
+ virtual void openForRead(const String& path, long long offset, long long length);
+ virtual void openForWrite(const String& path);
+ virtual void close();
+ virtual void read(char* buffer, int length);
+ virtual void write(const KURL& blobURL, long long position, int length);
+ virtual void truncate(long long position);
// Stops the proxy and scedules it to be destructed. All the pending tasks will be aborted and the file stream will be closed.
// Note: the caller should deref the instance immediately after calling stop().
- void stop();
-
- FileStreamClient* client() const { return m_client; }
+ virtual void stop();
private:
FileStreamProxy(ScriptExecutionContext*, FileStreamClient*);
@@ -80,11 +78,10 @@ private:
void openForWriteOnFileThread(const String& path);
void closeOnFileThread();
void readOnFileThread(char* buffer, int length);
- void writeOnFileThread(Blob*, long long position, int length);
+ void writeOnFileThread(const KURL& blobURL, long long position, int length);
void truncateOnFileThread(long long position);
RefPtr<ScriptExecutionContext> m_context;
- FileStreamClient* m_client;
RefPtr<FileStream> m_stream;
};
diff --git a/WebCore/html/FileThreadTask.h b/WebCore/html/FileThreadTask.h
index 3443457..8a8ffcb 100644
--- a/WebCore/html/FileThreadTask.h
+++ b/WebCore/html/FileThreadTask.h
@@ -47,7 +47,7 @@ public:
static PassOwnPtr<FileThreadTaskImpl> create(T* instance, Method method)
{
- return new FileThreadTaskImpl(instance, method);
+ return adoptPtr(new FileThreadTaskImpl(instance, method));
}
private:
@@ -75,7 +75,7 @@ public:
static PassOwnPtr<FileThreadTaskImpl> create(T* instance, Method method, Param1 parameter1)
{
- return new FileThreadTaskImpl(instance, method, parameter1);
+ return adoptPtr(new FileThreadTaskImpl(instance, method, parameter1));
}
private:
@@ -106,7 +106,7 @@ public:
static PassOwnPtr<FileThreadTaskImpl> create(T* instance, Method method, Param1 parameter1, Param2 parameter2)
{
- return new FileThreadTaskImpl(instance, method, parameter1, parameter2);
+ return adoptPtr(new FileThreadTaskImpl(instance, method, parameter1, parameter2));
}
private:
@@ -140,7 +140,7 @@ public:
static PassOwnPtr<FileThreadTaskImpl> create(T* instance, Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3)
{
- return new FileThreadTaskImpl(instance, method, parameter1, parameter2, parameter3);
+ return adoptPtr(new FileThreadTaskImpl(instance, method, parameter1, parameter2, parameter3));
}
private:
diff --git a/WebCore/html/FileStreamClient.h b/WebCore/html/FileWriter.cpp
index 440d2fb..7d112e2 100644
--- a/WebCore/html/FileStreamClient.h
+++ b/WebCore/html/FileWriter.cpp
@@ -28,38 +28,59 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef FileStreamClient_h
-#define FileStreamClient_h
+#include "config.h"
-#if ENABLE(BLOB) || ENABLE(FILE_WRITER)
+#if ENABLE(FILE_WRITER)
-#include "ExceptionCode.h"
+#include "FileWriter.h"
namespace WebCore {
-class FileStreamClient {
-public:
- // For reading.
- virtual void didRead(int) { }
+FileWriter::FileWriter(ScriptExecutionContext* context)
+ : ActiveDOMObject(context, this)
+{
+}
- // For writing.
- virtual void didWrite(int) { }
- virtual void didTruncate(ExceptionCode) { }
+FileWriter::~FileWriter()
+{
+}
- // FIXME: To be removed when we switch to using BlobData.
- virtual void didStart() { }
+bool FileWriter::hasPendingActivity() const
+{
+ return false;
+}
- // For both reading and writing.
- virtual void didOpen(ExceptionCode) { }
- virtual void didStop() { }
- virtual void didGetSize(long long) { }
+bool FileWriter::canSuspend() const
+{
+ // FIXME: It is not currently possible to suspend a FileWriter, so pages with FileWriter can not go into page cache.
+ return false;
+}
-protected:
- virtual ~FileStreamClient() { }
-};
+void FileWriter::stop()
+{
+}
-} // namespace WebCore
+void FileWriter::write(Blob*)
+{
+}
+
+void FileWriter::seek(long long)
+{
+}
+
+void FileWriter::truncate(long long)
+{
+}
-#endif // ENABLE(BLOB) || ENABLE(FILE_WRITER)
+void FileWriter::abort()
+{
+}
-#endif // FileStreamClient_h
+FileWriter::ReadyState FileWriter::readyState() const
+{
+ return EMPTY;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_WRITER)
diff --git a/WebCore/html/FileWriter.h b/WebCore/html/FileWriter.h
new file mode 100644
index 0000000..fd5babf
--- /dev/null
+++ b/WebCore/html/FileWriter.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FileWriter_h
+#define FileWriter_h
+
+#if ENABLE(FILE_WRITER)
+
+#include "ActiveDOMObject.h"
+#include "EventTarget.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Blob;
+class FileError;
+class ScriptExecutionContext;
+
+// FIXME: This is an empty, do-nothing placeholder for implementation yet to come.
+class FileWriter : public RefCounted<FileWriter>, public ActiveDOMObject, public EventTarget {
+public:
+ static PassRefPtr<FileWriter> create(ScriptExecutionContext* context)
+ {
+ return adoptRef(new FileWriter(context));
+ }
+
+ enum ReadyState {
+ EMPTY = 0,
+ WRITING = 1,
+ DONE = 2
+ };
+
+ void write(Blob*);
+ void seek(long long position);
+ void truncate(long long length);
+ void abort();
+
+ ReadyState readyState() const;
+ FileError* error() const { return m_error; };
+ long long position() const { return 0; };
+ long long length() const { return 0; };
+
+ // ActiveDOMObject
+ virtual bool canSuspend() const;
+ virtual void stop();
+ virtual bool hasPendingActivity() const;
+
+ // EventTarget
+ virtual FileWriter* toFileWriter() { return this; }
+ virtual ScriptExecutionContext* scriptExecutionContext() const { return ActiveDOMObject::scriptExecutionContext(); }
+
+ using RefCounted<FileWriter>::ref;
+ using RefCounted<FileWriter>::deref;
+
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(writestart);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(progress);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(write);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(writeend);
+
+private:
+ FileWriter(ScriptExecutionContext*);
+
+ virtual ~FileWriter();
+
+ friend class RefCounted<FileWriter>;
+
+ // EventTarget
+ virtual void refEventTarget() { ref(); }
+ virtual void derefEventTarget() { deref(); }
+ virtual EventTargetData* eventTargetData() { return &m_eventTargetData; }
+ virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData; }
+
+ RefPtr<FileError*> m_error;
+ EventTargetData m_eventTargetData;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_WRITER)
+
+#endif // FileWriter_h
diff --git a/WebCore/html/FileWriter.idl b/WebCore/html/FileWriter.idl
new file mode 100644
index 0000000..bb95ee1
--- /dev/null
+++ b/WebCore/html/FileWriter.idl
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ Conditional=FILE_WRITER,
+ CallWith=ScriptExecutionContext,
+ EventTarget,
+ NoStaticTables
+ ] FileWriter {
+ // ready states
+ const unsigned short INIT = 0;
+ const unsigned short WRITING = 1;
+ const unsigned short DONE = 2;
+ readonly attribute unsigned short readyState;
+
+ // async write/modify methods
+ void write(in Blob data) raises (FileException);
+ void seek(in long long position) raises (FileException);
+ void truncate(in long long size) raises (FileException);
+
+ void abort() raises (FileException);
+
+ readonly attribute FileError error;
+ readonly attribute long long position;
+ readonly attribute long long length;
+
+ attribute EventListener onwritestart;
+ attribute EventListener onprogress;
+ attribute EventListener onwrite;
+ attribute EventListener onabort;
+ attribute EventListener onerror;
+ attribute EventListener onwriteend;
+ };
+}
diff --git a/WebCore/html/HTMLAnchorElement.h b/WebCore/html/HTMLAnchorElement.h
index 4f7b4fd..a5ef167 100644
--- a/WebCore/html/HTMLAnchorElement.h
+++ b/WebCore/html/HTMLAnchorElement.h
@@ -97,8 +97,6 @@ protected:
virtual void parseMappedAttribute(Attribute*);
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;
diff --git a/WebCore/html/HTMLAppletElement.h b/WebCore/html/HTMLAppletElement.h
index e0e4ec9..1499279 100644
--- a/WebCore/html/HTMLAppletElement.h
+++ b/WebCore/html/HTMLAppletElement.h
@@ -34,8 +34,6 @@ public:
private:
HTMLAppletElement(const QualifiedName&, Document*);
- virtual int tagPriority() const { return 1; }
-
virtual void parseMappedAttribute(Attribute*);
virtual bool rendererIsNeeded(RenderStyle*);
diff --git a/WebCore/html/HTMLAreaElement.cpp b/WebCore/html/HTMLAreaElement.cpp
index 2d714ba..3547cd9 100644
--- a/WebCore/html/HTMLAreaElement.cpp
+++ b/WebCore/html/HTMLAreaElement.cpp
@@ -72,7 +72,7 @@ void HTMLAreaElement::parseMappedAttribute(Attribute* attr)
bool HTMLAreaElement::mapMouseEvent(int x, int y, const IntSize& size, HitTestResult& result)
{
if (m_lastSize != size) {
- m_region.set(new Path(getRegion(size)));
+ m_region = adoptPtr(new Path(getRegion(size)));
m_lastSize = size;
}
diff --git a/WebCore/html/HTMLAreaElement.h b/WebCore/html/HTMLAreaElement.h
index ce711b2..10784c3 100644
--- a/WebCore/html/HTMLAreaElement.h
+++ b/WebCore/html/HTMLAreaElement.h
@@ -50,8 +50,6 @@ public:
private:
HTMLAreaElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
virtual void parseMappedAttribute(Attribute*);
virtual bool supportsFocus() const;
virtual String target() const;
diff --git a/WebCore/html/HTMLAudioElement.h b/WebCore/html/HTMLAudioElement.h
index e453486..a12cd4b 100644
--- a/WebCore/html/HTMLAudioElement.h
+++ b/WebCore/html/HTMLAudioElement.h
@@ -43,7 +43,6 @@ private:
HTMLAudioElement(const QualifiedName&, Document*);
virtual bool isVideo() const { return false; }
- virtual int tagPriority() const { return 5; }
};
} //namespace
diff --git a/WebCore/html/HTMLBRElement.h b/WebCore/html/HTMLBRElement.h
index 3bb5af1..05df8f6 100644
--- a/WebCore/html/HTMLBRElement.h
+++ b/WebCore/html/HTMLBRElement.h
@@ -36,9 +36,6 @@ public:
private:
HTMLBRElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLBaseElement.h b/WebCore/html/HTMLBaseElement.h
index 6c2d2d8..aa1454f 100644
--- a/WebCore/html/HTMLBaseElement.h
+++ b/WebCore/html/HTMLBaseElement.h
@@ -34,9 +34,6 @@ public:
private:
HTMLBaseElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
-
virtual String target() const { return m_target; }
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLBaseFontElement.h b/WebCore/html/HTMLBaseFontElement.h
index 5651a61..7573045 100644
--- a/WebCore/html/HTMLBaseFontElement.h
+++ b/WebCore/html/HTMLBaseFontElement.h
@@ -33,9 +33,6 @@ public:
private:
HTMLBaseFontElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
};
} // namespace
diff --git a/WebCore/html/HTMLBlockquoteElement.h b/WebCore/html/HTMLBlockquoteElement.h
index 3f46d63..194fe54 100644
--- a/WebCore/html/HTMLBlockquoteElement.h
+++ b/WebCore/html/HTMLBlockquoteElement.h
@@ -34,9 +34,6 @@ public:
private:
HTMLBlockquoteElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 5; }
};
} // namespace WebCore
diff --git a/WebCore/html/HTMLBodyElement.h b/WebCore/html/HTMLBodyElement.h
index 7b32549..d6ef185 100644
--- a/WebCore/html/HTMLBodyElement.h
+++ b/WebCore/html/HTMLBodyElement.h
@@ -69,9 +69,6 @@ public:
private:
HTMLBodyElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 10; }
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLCanvasElement.cpp b/WebCore/html/HTMLCanvasElement.cpp
index 84ab227..7463551 100644
--- a/WebCore/html/HTMLCanvasElement.cpp
+++ b/WebCore/html/HTMLCanvasElement.cpp
@@ -97,28 +97,6 @@ HTMLCanvasElement::~HTMLCanvasElement()
m_observer->canvasDestroyed(this);
}
-#if ENABLE(DASHBOARD_SUPPORT)
-
-HTMLTagStatus HTMLCanvasElement::endTagRequirement() const
-{
- Settings* settings = document()->settings();
- if (settings && settings->usesDashboardBackwardCompatibilityMode())
- return TagStatusForbidden;
-
- return HTMLElement::endTagRequirement();
-}
-
-int HTMLCanvasElement::tagPriority() const
-{
- Settings* settings = document()->settings();
- if (settings && settings->usesDashboardBackwardCompatibilityMode())
- return 0;
-
- return HTMLElement::tagPriority();
-}
-
-#endif
-
void HTMLCanvasElement::parseMappedAttribute(Attribute* attr)
{
const QualifiedName& attrName = attr->name();
@@ -168,7 +146,7 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas
if (Settings* settings = document()->settings())
usesDashbardCompatibilityMode = settings->usesDashboardBackwardCompatibilityMode();
#endif
- m_context = new CanvasRenderingContext2D(this, document()->inCompatMode(), usesDashbardCompatibilityMode);
+ m_context = adoptPtr(new CanvasRenderingContext2D(this, document()->inCompatMode(), usesDashbardCompatibilityMode));
#if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING)
if (m_context) {
// Need to make sure a RenderLayer and compositing layer get created for the Canvas
@@ -272,15 +250,11 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r)
if (context->paintingDisabled())
return;
-#if ENABLE(3D_CANVAS)
- WebGLRenderingContext* context3D = 0;
- if (m_context && m_context->is3d()) {
- context3D = static_cast<WebGLRenderingContext*>(m_context.get());
- if (!context3D->paintsIntoCanvasBuffer())
+ if (m_context) {
+ if (!m_context->paintsIntoCanvasBuffer())
return;
- context3D->paintRenderingResultsToCanvas();
+ m_context->paintRenderingResultsToCanvas();
}
-#endif
if (hasCreatedImageBuffer()) {
ImageBuffer* imageBuffer = buffer();
diff --git a/WebCore/html/HTMLCanvasElement.h b/WebCore/html/HTMLCanvasElement.h
index 3270667..c9b258d 100644
--- a/WebCore/html/HTMLCanvasElement.h
+++ b/WebCore/html/HTMLCanvasElement.h
@@ -134,11 +134,6 @@ public:
private:
HTMLCanvasElement(const QualifiedName&, Document*);
-#if ENABLE(DASHBOARD_SUPPORT)
- virtual HTMLTagStatus endTagRequirement() const;
- virtual int tagPriority() const;
-#endif
-
virtual void parseMappedAttribute(Attribute*);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
diff --git a/WebCore/html/HTMLConstructionSite.cpp b/WebCore/html/HTMLConstructionSite.cpp
index a25c7d9..8735cd2 100644
--- a/WebCore/html/HTMLConstructionSite.cpp
+++ b/WebCore/html/HTMLConstructionSite.cpp
@@ -39,7 +39,6 @@
#include "HTMLScriptElement.h"
#include "HTMLToken.h"
#include "HTMLTokenizer.h"
-#include "LegacyHTMLTreeBuilder.h"
#include "LocalizedStrings.h"
#if ENABLE(MATHML)
#include "MathMLNames.h"
@@ -83,7 +82,7 @@ bool causesFosterParenting(const QualifiedName& tagName)
} // namespace
template<typename ChildType>
-PassRefPtr<ChildType> HTMLConstructionSite::attach(Node* parent, PassRefPtr<ChildType> prpChild)
+PassRefPtr<ChildType> HTMLConstructionSite::attach(ContainerNode* parent, PassRefPtr<ChildType> prpChild)
{
RefPtr<ChildType> child = prpChild;
@@ -92,7 +91,7 @@ PassRefPtr<ChildType> HTMLConstructionSite::attach(Node* parent, PassRefPtr<Chil
// doesn't. It feels like we're missing a concept somehow.
if (shouldFosterParent()) {
fosterParent(child.get());
- ASSERT(child->attached() || !child->parent()->attached());
+ ASSERT(child->attached() || !child->parent() || !child->parent()->attached());
return child.release();
}
@@ -118,10 +117,7 @@ void HTMLConstructionSite::attachAtSite(const AttachmentSite& site, PassRefPtr<N
RefPtr<Node> child = prpChild;
if (site.nextChild) {
- // FIXME: We need an insertElement which does not send mutation events.
- ExceptionCode ec = 0;
- site.parent->insertBefore(child, site.nextChild, ec);
- ASSERT(!ec);
+ site.parent->parserInsertBefore(child, site.nextChild);
if (site.parent->attached() && !child->attached())
child->attach();
return;
@@ -146,6 +142,11 @@ HTMLConstructionSite::~HTMLConstructionSite()
{
}
+void HTMLConstructionSite::detach()
+{
+ m_document = 0;
+}
+
void HTMLConstructionSite::setForm(HTMLFormElement* form)
{
// This method should only be needed for HTMLTreeBuilder in the fragment case.
@@ -160,6 +161,7 @@ PassRefPtr<HTMLFormElement> HTMLConstructionSite::takeForm()
void HTMLConstructionSite::dispatchDocumentElementAvailableIfNeeded()
{
+ ASSERT(m_document);
if (m_document->frame() && !m_isParsingFragment)
m_document->frame()->loader()->dispatchDocumentElementAvailable();
}
@@ -287,7 +289,8 @@ void HTMLConstructionSite::insertFormattingElement(AtomicHTMLToken& token)
void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken& token)
{
RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, m_document, true);
- element->setAttributeMap(token.takeAtributes(), m_fragmentScriptingPermission);
+ if (m_fragmentScriptingPermission == FragmentScriptingAllowed)
+ element->setAttributeMap(token.takeAtributes(), m_fragmentScriptingPermission);
m_openElements.push(attachToCurrent(element.release()));
}
@@ -429,7 +432,7 @@ void HTMLConstructionSite::findFosterSite(AttachmentSite& site)
HTMLElementStack::ElementRecord* lastTableElementRecord = m_openElements.topmost(tableTag.localName());
if (lastTableElementRecord) {
Element* lastTableElement = lastTableElementRecord->element();
- if (Node* parent = lastTableElement->parent()) {
+ if (ContainerNode* parent = lastTableElement->parent()) {
site.parent = parent;
site.nextChild = lastTableElement;
return;
diff --git a/WebCore/html/HTMLConstructionSite.h b/WebCore/html/HTMLConstructionSite.h
index 16ba56b..2e746b4 100644
--- a/WebCore/html/HTMLConstructionSite.h
+++ b/WebCore/html/HTMLConstructionSite.h
@@ -45,6 +45,8 @@ public:
HTMLConstructionSite(Document*, FragmentScriptingPermission, bool isParsingFragment);
~HTMLConstructionSite();
+ void detach();
+
void insertDoctype(AtomicHTMLToken&);
void insertComment(AtomicHTMLToken&);
void insertCommentOnDocument(AtomicHTMLToken&);
@@ -109,12 +111,12 @@ public:
private:
struct AttachmentSite {
- Node* parent;
+ ContainerNode* parent;
Node* nextChild;
};
template<typename ChildType>
- PassRefPtr<ChildType> attach(Node* parent, PassRefPtr<ChildType> child);
+ PassRefPtr<ChildType> attach(ContainerNode* parent, PassRefPtr<ChildType> child);
PassRefPtr<Element> attachToCurrent(PassRefPtr<Element>);
void attachAtSite(const AttachmentSite&, PassRefPtr<Node> child);
diff --git a/WebCore/html/HTMLDListElement.h b/WebCore/html/HTMLDListElement.h
index 260aa42..25697a1 100644
--- a/WebCore/html/HTMLDListElement.h
+++ b/WebCore/html/HTMLDListElement.h
@@ -33,9 +33,6 @@ public:
private:
HTMLDListElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 5; }
};
} //namespace
diff --git a/WebCore/html/HTMLDataGridCellElement.h b/WebCore/html/HTMLDataGridCellElement.h
index 567ec23..60af155 100644
--- a/WebCore/html/HTMLDataGridCellElement.h
+++ b/WebCore/html/HTMLDataGridCellElement.h
@@ -53,10 +53,6 @@ public:
private:
HTMLDataGridCellElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
-
};
} // namespace WebCore
diff --git a/WebCore/html/HTMLDataGridColElement.h b/WebCore/html/HTMLDataGridColElement.h
index 701bc42..5198190 100644
--- a/WebCore/html/HTMLDataGridColElement.h
+++ b/WebCore/html/HTMLDataGridColElement.h
@@ -60,8 +60,6 @@ public:
private:
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(Attribute*);
diff --git a/WebCore/html/HTMLDataGridElement.cpp b/WebCore/html/HTMLDataGridElement.cpp
index 82edf8f..d9ffa27 100644
--- a/WebCore/html/HTMLDataGridElement.cpp
+++ b/WebCore/html/HTMLDataGridElement.cpp
@@ -55,13 +55,6 @@ 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);
diff --git a/WebCore/html/HTMLDataGridElement.h b/WebCore/html/HTMLDataGridElement.h
index e29bf98..c594623 100644
--- a/WebCore/html/HTMLDataGridElement.h
+++ b/WebCore/html/HTMLDataGridElement.h
@@ -56,9 +56,6 @@ public:
private:
HTMLDataGridElement(const QualifiedName&, Document*);
- virtual int tagPriority() const { return 6; } // Same as <select>s
- virtual bool checkDTD(const Node*);
-
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
RefPtr<DataGridDataSource> m_dataSource;
diff --git a/WebCore/html/HTMLDataGridRowElement.cpp b/WebCore/html/HTMLDataGridRowElement.cpp
index 8e08c7c..74c88ba 100644
--- a/WebCore/html/HTMLDataGridRowElement.cpp
+++ b/WebCore/html/HTMLDataGridRowElement.cpp
@@ -45,13 +45,6 @@ PassRefPtr<HTMLDataGridRowElement> HTMLDataGridRowElement::create(const Qualifie
return adoptRef(new HTMLDataGridRowElement(name, document));
}
-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);
diff --git a/WebCore/html/HTMLDataGridRowElement.h b/WebCore/html/HTMLDataGridRowElement.h
index 81be914..3ee5bc6 100644
--- a/WebCore/html/HTMLDataGridRowElement.h
+++ b/WebCore/html/HTMLDataGridRowElement.h
@@ -47,9 +47,6 @@ public:
private:
HTMLDataGridRowElement(const QualifiedName&, Document*);
-
- virtual int tagPriority() const { return 2; } // Same as <option>s.
- virtual bool checkDTD(const Node*);
};
} // namespace WebCore
diff --git a/WebCore/html/HTMLDataListElement.cpp b/WebCore/html/HTMLDataListElement.cpp
index 3404348..b73606d 100644
--- a/WebCore/html/HTMLDataListElement.cpp
+++ b/WebCore/html/HTMLDataListElement.cpp
@@ -47,11 +47,6 @@ PassRefPtr<HTMLDataListElement> HTMLDataListElement::create(const QualifiedName&
return adoptRef(new HTMLDataListElement(tagName, document));
}
-bool HTMLDataListElement::checkDTD(const Node* newChild)
-{
- return newChild->hasTagName(HTMLNames::optionTag) || HTMLElement::inInlineTagList(newChild);
-}
-
PassRefPtr<HTMLCollection> HTMLDataListElement::options()
{
return HTMLCollection::create(this, DataListOptions);
diff --git a/WebCore/html/HTMLDataListElement.h b/WebCore/html/HTMLDataListElement.h
index 3587234..97e608f 100644
--- a/WebCore/html/HTMLDataListElement.h
+++ b/WebCore/html/HTMLDataListElement.h
@@ -47,8 +47,6 @@ public:
private:
HTMLDataListElement(const QualifiedName&, Document*);
-
- virtual bool checkDTD(const Node*);
};
} // namespace WebCore
diff --git a/WebCore/html/HTMLDirectoryElement.h b/WebCore/html/HTMLDirectoryElement.h
index 0e440d4..afd3876 100644
--- a/WebCore/html/HTMLDirectoryElement.h
+++ b/WebCore/html/HTMLDirectoryElement.h
@@ -33,9 +33,6 @@ public:
private:
HTMLDirectoryElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 5; }
};
} //namespace
diff --git a/WebCore/html/HTMLDivElement.h b/WebCore/html/HTMLDivElement.h
index 30eddf3..2e2b417 100644
--- a/WebCore/html/HTMLDivElement.h
+++ b/WebCore/html/HTMLDivElement.h
@@ -36,9 +36,6 @@ protected:
HTMLDivElement(const QualifiedName&, Document*);
private:
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 5; }
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
};
diff --git a/WebCore/html/HTMLDocument.cpp b/WebCore/html/HTMLDocument.cpp
index 4e26c02..5e11ad2 100644
--- a/WebCore/html/HTMLDocument.cpp
+++ b/WebCore/html/HTMLDocument.cpp
@@ -282,25 +282,20 @@ void HTMLDocument::releaseEvents()
{
}
-DocumentParser* HTMLDocument::createParser()
+PassRefPtr<DocumentParser> HTMLDocument::createParser()
{
bool reportErrors = false;
#if ENABLE(INSPECTOR)
if (Page* page = this->page())
- reportErrors = page->inspectorController()->windowVisible();
+ reportErrors = page->inspectorController()->hasFrontend();
#endif
- return new HTMLDocumentParser(this, reportErrors);
+ return HTMLDocumentParser::create(this, reportErrors);
}
// --------------------------------------------------------------------------
// not part of the DOM
// --------------------------------------------------------------------------
-bool HTMLDocument::childAllowed(Node *newChild)
-{
- return newChild->hasTagName(htmlTag) || newChild->isCommentNode() || (newChild->nodeType() == DOCUMENT_TYPE_NODE && !doctype());
-}
-
PassRefPtr<Element> HTMLDocument::createElement(const AtomicString& name, ExceptionCode& ec)
{
if (!isValidName(name)) {
diff --git a/WebCore/html/HTMLDocument.h b/WebCore/html/HTMLDocument.h
index 3b5fdfa..583cdcc 100644
--- a/WebCore/html/HTMLDocument.h
+++ b/WebCore/html/HTMLDocument.h
@@ -91,12 +91,10 @@ protected:
#endif
private:
- virtual bool childAllowed(Node*);
-
virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
virtual bool isFrameSet() const;
- virtual DocumentParser* createParser();
+ virtual PassRefPtr<DocumentParser> createParser();
virtual void determineParseMode();
void addItemToMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
diff --git a/WebCore/html/HTMLDocumentParser.cpp b/WebCore/html/HTMLDocumentParser.cpp
index bd2c590..a271603 100644
--- a/WebCore/html/HTMLDocumentParser.cpp
+++ b/WebCore/html/HTMLDocumentParser.cpp
@@ -99,10 +99,10 @@ HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElement, bo
HTMLDocumentParser::HTMLDocumentParser(HTMLDocument* document, bool reportErrors)
: ScriptableDocumentParser(document)
- , m_tokenizer(new HTMLTokenizer)
- , m_scriptRunner(new HTMLScriptRunner(document, this))
- , m_treeBuilder(new HTMLTreeBuilder(m_tokenizer.get(), document, reportErrors))
- , m_parserScheduler(new HTMLParserScheduler(this))
+ , m_tokenizer(HTMLTokenizer::create())
+ , m_scriptRunner(HTMLScriptRunner::create(document, this))
+ , m_treeBuilder(HTMLTreeBuilder::create(m_tokenizer.get(), document, reportErrors))
+ , m_parserScheduler(HTMLParserScheduler::create(this))
, m_endWasDelayed(false)
, m_writeNestingLevel(0)
{
@@ -112,8 +112,8 @@ HTMLDocumentParser::HTMLDocumentParser(HTMLDocument* document, bool reportErrors
// minimize code duplication between these constructors.
HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission)
: ScriptableDocumentParser(fragment->document())
- , m_tokenizer(new HTMLTokenizer)
- , m_treeBuilder(new HTMLTreeBuilder(m_tokenizer.get(), fragment, contextElement, scriptingPermission))
+ , m_tokenizer(HTMLTokenizer::create())
+ , m_treeBuilder(HTMLTreeBuilder::create(m_tokenizer.get(), fragment, contextElement, scriptingPermission))
, m_endWasDelayed(false)
, m_writeNestingLevel(0)
{
@@ -123,10 +123,21 @@ HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont
HTMLDocumentParser::~HTMLDocumentParser()
{
- // FIXME: We'd like to ASSERT that normal operation of this class clears
- // out any delayed actions, but we can't because we're unceremoniously
- // deleted. If there were a required call to some sort of cancel function,
- // then we could ASSERT some invariants here.
+ ASSERT(!m_parserScheduler);
+ ASSERT(!m_writeNestingLevel);
+ ASSERT(!m_preloadScanner);
+}
+
+void HTMLDocumentParser::detach()
+{
+ DocumentParser::detach();
+ if (m_scriptRunner)
+ m_scriptRunner->detach();
+ m_treeBuilder->detach();
+ // FIXME: It seems wrong that we would have a preload scanner here.
+ // Yet during fast/dom/HTMLScriptElement/script-load-events.html we do.
+ m_preloadScanner.clear();
+ m_parserScheduler.clear(); // Deleting the scheduler will clear any timers.
}
void HTMLDocumentParser::stopParsing()
@@ -162,6 +173,10 @@ bool HTMLDocumentParser::isScheduledForResume() const
// Used by HTMLParserScheduler
void HTMLDocumentParser::resumeParsingAfterYield()
{
+ // pumpTokenizer can cause this parser to be detached from the Document,
+ // but we need to ensure it isn't deleted yet.
+ RefPtr<HTMLDocumentParser> protect(this);
+
// We should never be here unless we can pump immediately. Call pumpTokenizer()
// directly so that ASSERTS will fire if we're wrong.
pumpTokenizer(AllowYield);
@@ -182,9 +197,12 @@ bool HTMLDocumentParser::runScriptsForPausedTreeBuilder()
void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode)
{
+ ASSERT(!isDetached());
ASSERT(!m_parserStopped);
ASSERT(!m_treeBuilder->isPaused());
ASSERT(!isScheduledForResume());
+ // ASSERT that this object is both attached to the Document and protected.
+ ASSERT(refCount() >= 2);
// We tell the InspectorTimelineAgent about every pump, even if we
// end up pumping nothing. It can filter out empty pumps itself.
@@ -192,13 +210,17 @@ void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode)
HTMLParserScheduler::PumpSession session;
// FIXME: This loop body has is now too long and needs cleanup.
- while (mode == ForceSynchronous || (!m_parserStopped && m_parserScheduler->shouldContinueParsing(session))) {
+ while (mode == ForceSynchronous || m_parserScheduler->shouldContinueParsing(session)) {
if (!m_tokenizer->nextToken(m_input.current(), m_token))
break;
m_treeBuilder->constructTreeFromToken(m_token);
m_token.clear();
+ // JavaScript may have stopped or detached the parser.
+ if (isDetached() || m_parserStopped)
+ return;
+
// The parser will pause itself when waiting on a script to load or run.
if (!m_treeBuilder->isPaused())
continue;
@@ -206,14 +228,23 @@ void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode)
// If we're paused waiting for a script, we try to execute scripts before continuing.
bool shouldContinueParsing = runScriptsForPausedTreeBuilder();
m_treeBuilder->setPaused(!shouldContinueParsing);
+
+ // JavaScript may have stopped or detached the parser.
+ if (isDetached() || m_parserStopped)
+ return;
+
if (!shouldContinueParsing)
break;
}
+ // Ensure we haven't been totally deref'ed after pumping. Any caller of this
+ // function should be holding a RefPtr to this to ensure we weren't deleted.
+ ASSERT(refCount() >= 1);
+
if (isWaitingForScripts()) {
ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState);
if (!m_preloadScanner) {
- m_preloadScanner.set(new HTMLPreloadScanner(m_document));
+ m_preloadScanner.set(new HTMLPreloadScanner(document()));
m_preloadScanner->appendToEnd(m_input.current());
}
m_preloadScanner->scan();
@@ -228,7 +259,7 @@ void HTMLDocumentParser::willPumpLexer()
// FIXME: m_input.current().length() is only accurate if we
// end up parsing the whole buffer in this pump. We should pass how
// much we parsed as part of didWriteHTML instead of willWriteHTML.
- if (InspectorTimelineAgent* timelineAgent = m_document->inspectorTimelineAgent())
+ if (InspectorTimelineAgent* timelineAgent = document()->inspectorTimelineAgent())
timelineAgent->willWriteHTML(m_input.current().length(), m_tokenizer->lineNumber());
#endif
}
@@ -236,7 +267,7 @@ void HTMLDocumentParser::willPumpLexer()
void HTMLDocumentParser::didPumpLexer()
{
#if ENABLE(INSPECTOR)
- if (InspectorTimelineAgent* timelineAgent = m_document->inspectorTimelineAgent())
+ if (InspectorTimelineAgent* timelineAgent = document()->inspectorTimelineAgent())
timelineAgent->didWriteHTML(m_tokenizer->lineNumber());
#endif
}
@@ -251,9 +282,15 @@ void HTMLDocumentParser::insert(const SegmentedString& source)
if (m_parserStopped)
return;
+<<<<<<< HEAD
#ifdef ANDROID_INSTRUMENT
android::TimeCounter::start(android::TimeCounter::ParsingTimeCounter);
#endif
+=======
+ // pumpTokenizer can cause this parser to be detached from the Document,
+ // but we need to ensure it isn't deleted yet.
+ RefPtr<HTMLDocumentParser> protect(this);
+>>>>>>> webkit.org at r66079
{
NestingLevelIncrementer nestingLevelIncrementer(m_writeNestingLevel);
@@ -272,6 +309,10 @@ void HTMLDocumentParser::append(const SegmentedString& source)
if (m_parserStopped)
return;
+ // pumpTokenizer can cause this parser to be detached from the Document,
+ // but we need to ensure it isn't deleted yet.
+ RefPtr<HTMLDocumentParser> protect(this);
+
{
NestingLevelIncrementer nestingLevelIncrementer(m_writeNestingLevel);
@@ -300,7 +341,13 @@ void HTMLDocumentParser::append(const SegmentedString& source)
void HTMLDocumentParser::end()
{
+ ASSERT(!isDetached());
ASSERT(!isScheduledForResume());
+
+ // pumpTokenizer can cause this parser to be detached from the Document,
+ // but we need to ensure it isn't deleted yet.
+ RefPtr<HTMLDocumentParser> protect(this);
+
// NOTE: This pump should only ever emit buffered character tokens,
// so ForceSynchronous vs. AllowYield should be meaningless.
pumpTokenizerIfPossible(ForceSynchronous);
@@ -323,6 +370,10 @@ void HTMLDocumentParser::attemptToEnd()
void HTMLDocumentParser::endIfDelayed()
{
+ // If we've already been detached, don't bother ending.
+ if (isDetached())
+ return;
+
if (!m_endWasDelayed || shouldDelayEnd())
return;
@@ -332,6 +383,11 @@ void HTMLDocumentParser::endIfDelayed()
void HTMLDocumentParser::finish()
{
+ // FIXME: We should ASSERT(!m_parserStopped) here, since it does not
+ // makes sense to call any methods on DocumentParser once it's been stopped.
+ // However, FrameLoader::stop calls Document::finishParsing unconditionally
+ // which in turn calls m_parser->finish().
+
// We're not going to get any more data off the network, so we tell the
// input stream we've reached the end of file. finish() can be called more
// than once, if the first time does not call end().
@@ -369,11 +425,6 @@ int HTMLDocumentParser::columnNumber() const
return m_tokenizer->columnNumber();
}
-LegacyHTMLTreeBuilder* HTMLDocumentParser::htmlTreeBuilder() const
-{
- return m_treeBuilder->legacyTreeBuilder();
-}
-
bool HTMLDocumentParser::isWaitingForScripts() const
{
return m_treeBuilder->isPaused();
@@ -412,6 +463,10 @@ bool HTMLDocumentParser::shouldLoadExternalScriptFromSrc(const AtomicString& src
void HTMLDocumentParser::notifyFinished(CachedResource* cachedResource)
{
+ // pumpTokenizer can cause this parser to be detached from the Document,
+ // but we need to ensure it isn't deleted yet.
+ RefPtr<HTMLDocumentParser> protect(this);
+
ASSERT(m_scriptRunner);
ASSERT(!inScriptExecution());
ASSERT(m_treeBuilder->isPaused());
@@ -434,6 +489,11 @@ void HTMLDocumentParser::executeScriptsWaitingForStylesheets()
// is a re-entrant call from encountering a </ style> tag.
if (!m_scriptRunner->hasScriptsWaitingForStylesheets())
return;
+
+ // pumpTokenizer can cause this parser to be detached from the Document,
+ // but we need to ensure it isn't deleted yet.
+ RefPtr<HTMLDocumentParser> protect(this);
+
ASSERT(!m_scriptRunner->isExecutingScript());
ASSERT(m_treeBuilder->isPaused());
// Note: We only ever wait on one script at a time, so we always know this
@@ -447,15 +507,16 @@ void HTMLDocumentParser::executeScriptsWaitingForStylesheets()
ScriptController* HTMLDocumentParser::script() const
{
- return m_document->frame() ? m_document->frame()->script() : 0;
+ return document()->frame() ? document()->frame()->script() : 0;
}
void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission)
{
- HTMLDocumentParser parser(fragment, contextElement, scriptingPermission);
- parser.insert(source); // Use insert() so that the parser will not yield.
- parser.finish();
- ASSERT(!parser.processingData()); // Make sure we're done. <rdar://problem/3963151>
+ RefPtr<HTMLDocumentParser> parser = HTMLDocumentParser::create(fragment, contextElement, scriptingPermission);
+ parser->insert(source); // Use insert() so that the parser will not yield.
+ parser->finish();
+ ASSERT(!parser->processingData()); // Make sure we're done. <rdar://problem/3963151>
+ parser->detach(); // Allows ~DocumentParser to assert it was detached before destruction.
}
}
diff --git a/WebCore/html/HTMLDocumentParser.h b/WebCore/html/HTMLDocumentParser.h
index d35cfaf..da21a2b 100644
--- a/WebCore/html/HTMLDocumentParser.h
+++ b/WebCore/html/HTMLDocumentParser.h
@@ -46,15 +46,20 @@ class HTMLTokenizer;
class HTMLScriptRunner;
class HTMLTreeBuilder;
class HTMLPreloadScanner;
-class LegacyHTMLTreeBuilder;
class ScriptController;
class ScriptSourceCode;
class HTMLDocumentParser : public ScriptableDocumentParser, HTMLScriptRunnerHost, CachedResourceClient {
public:
- // FIXME: These constructors should be made private and replaced by create() methods.
- HTMLDocumentParser(HTMLDocument*, bool reportErrors);
- HTMLDocumentParser(DocumentFragment*, Element* contextElement, FragmentScriptingPermission);
+ static PassRefPtr<HTMLDocumentParser> create(HTMLDocument* document, bool reportErrors)
+ {
+ return adoptRef(new HTMLDocumentParser(document, reportErrors));
+ }
+ static PassRefPtr<HTMLDocumentParser> create(DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission permission)
+ {
+ return adoptRef(new HTMLDocumentParser(fragment, contextElement, permission));
+ }
+
virtual ~HTMLDocumentParser();
// Exposed for HTMLParserScheduler
@@ -66,8 +71,12 @@ protected:
virtual void insert(const SegmentedString&);
virtual void finish();
+ HTMLDocumentParser(HTMLDocument*, bool reportErrors);
+ HTMLDocumentParser(DocumentFragment*, Element* contextElement, FragmentScriptingPermission);
+
private:
// DocumentParser
+ virtual void detach();
virtual bool hasInsertionPoint();
virtual void append(const SegmentedString&);
virtual bool finishWasCalled();
@@ -78,9 +87,6 @@ private:
virtual void executeScriptsWaitingForStylesheets();
virtual int lineNumber() const;
virtual int columnNumber() const;
- // FIXME: HTMLFormControlElement accesses the LegacyHTMLTreeBuilder via this method.
- // Remove this when the LegacyHTMLTreeBuilder is no longer used.
- virtual LegacyHTMLTreeBuilder* htmlTreeBuilder() const;
// HTMLScriptRunnerHost
virtual void watchForLoad(CachedResource*);
diff --git a/WebCore/html/HTMLElement.cpp b/WebCore/html/HTMLElement.cpp
index ff25e62..f40489b 100644
--- a/WebCore/html/HTMLElement.cpp
+++ b/WebCore/html/HTMLElement.cpp
@@ -61,68 +61,55 @@ PassRefPtr<HTMLElement> HTMLElement::create(const QualifiedName& tagName, Docume
String HTMLElement::nodeName() const
{
- // FIXME: Would be nice to have an atomicstring lookup based off uppercase chars that does not have to copy
- // the string on a hit in the hash.
+ // FIXME: Would be nice to have an atomicstring lookup based off uppercase
+ // chars that does not have to copy the string on a hit in the hash.
// FIXME: We should have a way to detect XHTML elements and replace the hasPrefix() check with it.
if (document()->isHTMLDocument() && !tagQName().hasPrefix())
return tagQName().localNameUpper();
return Element::nodeName();
}
-
-HTMLTagStatus HTMLElement::endTagRequirement() const
-{
- if (hasLocalName(wbrTag))
- return TagStatusForbidden;
- 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.
- return TagStatusRequired;
-}
-struct Empty1IntHashTraits : HashTraits<int> {
- static const bool emptyValueIsZero = false;
- static int emptyValue() { return 1; }
-};
-typedef HashMap<AtomicStringImpl*, int, DefaultHash<AtomicStringImpl*>::Hash, HashTraits<AtomicStringImpl*>, Empty1IntHashTraits> TagPriorityMap;
-
-static const TagPriorityMap* createTagPriorityMap()
-{
- TagPriorityMap* map = new TagPriorityMap;
-
- map->add(wbrTag.localName().impl(), 0);
-
- map->add(addressTag.localName().impl(), 3);
- map->add(ddTag.localName().impl(), 3);
- map->add(dtTag.localName().impl(), 3);
- map->add(noscriptTag.localName().impl(), 3);
- map->add(rpTag.localName().impl(), 3);
- map->add(rtTag.localName().impl(), 3);
-
- // 5 is same as <div>'s priority.
- map->add(articleTag.localName().impl(), 5);
- map->add(asideTag.localName().impl(), 5);
- map->add(centerTag.localName().impl(), 5);
- map->add(footerTag.localName().impl(), 5);
- map->add(headerTag.localName().impl(), 5);
- map->add(hgroupTag.localName().impl(), 5);
- map->add(nobrTag.localName().impl(), 5);
- map->add(rubyTag.localName().impl(), 5);
- map->add(navTag.localName().impl(), 5);
- map->add(sectionTag.localName().impl(), 5);
-
- map->add(noembedTag.localName().impl(), 10);
- map->add(noframesTag.localName().impl(), 10);
-
- // TagPriorityMap returns 1 for unregistered tags. It's same as <span>.
- // This way custom tag name elements will behave like inline spans.
- return map;
-}
-
-int HTMLElement::tagPriority() const
-{
- static const TagPriorityMap* tagPriorityMap = createTagPriorityMap();
- return tagPriorityMap->get(localName().impl());
+bool HTMLElement::ieForbidsInsertHTML() const
+{
+ // FIXME: Supposedly IE disallows settting innerHTML, outerHTML
+ // and createContextualFragment on these tags. We have no tests to
+ // verify this however, so this list could be totally wrong.
+ // This list was moved from the previous endTagRequirement() implementation.
+ // This is also called from editing and assumed to be the list of tags
+ // for which no end tag should be serialized. It's unclear if the list for
+ // IE compat and the list for serialization sanity are the same.
+ if (hasLocalName(areaTag)
+ || hasLocalName(baseTag)
+ || hasLocalName(basefontTag)
+ || hasLocalName(brTag)
+ || hasLocalName(colTag)
+#if ENABLE(DATAGRID)
+ || hasLocalName(dcellTag)
+ || hasLocalName(dcolTag)
+#endif
+ || hasLocalName(embedTag)
+ || hasLocalName(frameTag)
+ || hasLocalName(hrTag)
+ || hasLocalName(imageTag)
+ || hasLocalName(imgTag)
+ || hasLocalName(inputTag)
+ || hasLocalName(isindexTag)
+ || hasLocalName(linkTag)
+ || hasLocalName(metaTag)
+ || hasLocalName(paramTag)
+ || hasLocalName(sourceTag)
+ || hasLocalName(wbrTag))
+ return true;
+ // FIXME: I'm not sure why dashboard mode would want to change the
+ // serialization of <canvas>, that seems like a bad idea.
+#if ENABLE(DASHBOARD_SUPPORT)
+ if (hasLocalName(canvasTag)) {
+ Settings* settings = document()->settings();
+ if (settings && settings->usesDashboardBackwardCompatibilityMode())
+ return true;
+ }
+#endif
+ return false;
}
bool HTMLElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
@@ -275,16 +262,16 @@ String HTMLElement::outerHTML() const
return createMarkup(this);
}
-static bool useLegacyTreeBuilder(Document* document)
+static bool useLegacyTreeBuilder(Document*)
{
- return !document || !document->settings() || !document->settings()->html5TreeBuilderEnabled();
+ return false;
}
// FIXME: This logic should move into Range::createContextualFragment
PassRefPtr<DocumentFragment> HTMLElement::deprecatedCreateContextualFragment(const String& markup, FragmentScriptingPermission scriptingPermission)
{
// The following is in accordance with the definition as used by IE.
- if (endTagRequirement() == TagStatusForbidden)
+ if (ieForbidsInsertHTML())
return 0;
if (hasLocalName(colTag) || hasLocalName(colgroupTag) || hasLocalName(framesetTag)
@@ -404,8 +391,7 @@ void HTMLElement::setOuterHTML(const String& html, ExceptionCode& ec)
void HTMLElement::setInnerText(const String& text, ExceptionCode& ec)
{
- // Follow the IE specs about when this is allowed.
- if (endTagRequirement() == TagStatusForbidden) {
+ if (ieForbidsInsertHTML()) {
ec = NO_MODIFICATION_ALLOWED_ERR;
return;
}
@@ -474,8 +460,7 @@ void HTMLElement::setInnerText(const String& text, ExceptionCode& ec)
void HTMLElement::setOuterText(const String &text, ExceptionCode& ec)
{
- // Follow the IE specs about when this is allowed.
- if (endTagRequirement() == TagStatusForbidden) {
+ if (ieForbidsInsertHTML()) {
ec = NO_MODIFICATION_ALLOWED_ERR;
return;
}
@@ -666,9 +651,9 @@ bool HTMLElement::isContentEditable() const
if (document()->frame() && document()->frame()->isContentEditable())
return true;
- // FIXME: this is a terrible thing to do here:
- // https://bugs.webkit.org/show_bug.cgi?id=21834
- document()->updateStyleIfNeeded();
+ // Ideally we'd call ASSERT!needsStyleRecalc()) here, but
+ // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion
+ // would fire in the middle of Document::setFocusedNode().
if (!renderer()) {
if (parentNode())
@@ -685,8 +670,6 @@ bool HTMLElement::isContentRichlyEditable() const
if (document()->frame() && document()->frame()->isContentEditable())
return true;
- document()->updateStyleIfNeeded();
-
if (!renderer()) {
if (parentNode())
return parentNode()->isContentEditable();
@@ -699,8 +682,6 @@ bool HTMLElement::isContentRichlyEditable() const
String HTMLElement::contentEditable() const
{
- document()->updateStyleIfNeeded();
-
if (!renderer())
return "false";
@@ -802,239 +783,6 @@ PassRefPtr<HTMLCollection> HTMLElement::children()
return HTMLCollection::create(this, NodeChildren);
}
-// DOM Section 1.1.1
-bool HTMLElement::childAllowed(Node *newChild)
-{
- if (!Element::childAllowed(newChild))
- return false;
-
- // For XML documents, we are non-validating and do not check against a DTD, even for HTML elements.
- if (!document()->isHTMLDocument())
- return true;
-
- // Future-proof for XML content inside HTML documents (we may allow this some day).
- if (newChild->isElementNode() && !newChild->isHTMLElement())
- return true;
-
- // Elements with forbidden tag status can never have children
- if (endTagRequirement() == TagStatusForbidden)
- return false;
-
- // Comment nodes are always allowed.
- if (newChild->isCommentNode())
- return true;
-
- // Now call checkDTD.
- return checkDTD(newChild);
-}
-
-// DTD Stuff
-// This unfortunate function is only needed when checking against the DTD. Other languages (like SVG) won't need this.
-bool HTMLElement::isRecognizedTagName(const QualifiedName& tagName)
-{
- DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ());
- if (tagList.isEmpty()) {
- size_t tagCount = 0;
- WebCore::QualifiedName** tags = HTMLNames::getHTMLTags(&tagCount);
- for (size_t i = 0; i < tagCount; i++) {
- if (*tags[i] == bgsoundTag
- || *tags[i] == commandTag
- || *tags[i] == detailsTag
- || *tags[i] == figcaptionTag
- || *tags[i] == figureTag
- || *tags[i] == summaryTag
- || *tags[i] == trackTag) {
- // Even though we have atoms for these tags, we don't want to
- // treat them as "recognized tags" for the purpose of parsing
- // because that changes how we parse documents.
- continue;
- }
- tagList.add(tags[i]->localName().impl());
- }
- }
- return tagList.contains(tagName.localName().impl());
-}
-
-// The terms inline and block are used here loosely. Don't make the mistake of assuming all inlines or all blocks
-// need to be in these two lists.
-static HashSet<AtomicStringImpl*>* inlineTagList()
-{
- DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ());
- if (tagList.isEmpty()) {
- tagList.add(ttTag.localName().impl());
- tagList.add(iTag.localName().impl());
- tagList.add(bTag.localName().impl());
- tagList.add(uTag.localName().impl());
- tagList.add(sTag.localName().impl());
- tagList.add(strikeTag.localName().impl());
- tagList.add(bigTag.localName().impl());
- tagList.add(smallTag.localName().impl());
- tagList.add(emTag.localName().impl());
- tagList.add(strongTag.localName().impl());
- tagList.add(dfnTag.localName().impl());
- tagList.add(codeTag.localName().impl());
- tagList.add(sampTag.localName().impl());
- tagList.add(kbdTag.localName().impl());
- tagList.add(varTag.localName().impl());
- tagList.add(citeTag.localName().impl());
- tagList.add(abbrTag.localName().impl());
- tagList.add(acronymTag.localName().impl());
- tagList.add(aTag.localName().impl());
- tagList.add(canvasTag.localName().impl());
- tagList.add(imgTag.localName().impl());
- tagList.add(appletTag.localName().impl());
- tagList.add(objectTag.localName().impl());
- tagList.add(embedTag.localName().impl());
- tagList.add(fontTag.localName().impl());
- tagList.add(basefontTag.localName().impl());
- tagList.add(brTag.localName().impl());
- tagList.add(scriptTag.localName().impl());
- tagList.add(styleTag.localName().impl());
- tagList.add(linkTag.localName().impl());
- tagList.add(mapTag.localName().impl());
- tagList.add(qTag.localName().impl());
- tagList.add(subTag.localName().impl());
- tagList.add(supTag.localName().impl());
- tagList.add(spanTag.localName().impl());
- tagList.add(bdoTag.localName().impl());
- tagList.add(iframeTag.localName().impl());
- 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());
- tagList.add(datalistTag.localName().impl());
- tagList.add(insTag.localName().impl());
- tagList.add(delTag.localName().impl());
- tagList.add(nobrTag.localName().impl());
- tagList.add(wbrTag.localName().impl());
-#if ENABLE(VIDEO)
- 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());
- tagList.add(progressTag.localName().impl());
- tagList.add(meterTag.localName().impl());
- tagList.add(markTag.localName().impl());
- }
- return &tagList;
-}
-
-static HashSet<AtomicStringImpl*>* blockTagList()
-{
- DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ());
- if (tagList.isEmpty()) {
- tagList.add(addressTag.localName().impl());
- tagList.add(articleTag.localName().impl());
- tagList.add(asideTag.localName().impl());
- tagList.add(blockquoteTag.localName().impl());
- tagList.add(centerTag.localName().impl());
- tagList.add(ddTag.localName().impl());
- tagList.add(dirTag.localName().impl());
- tagList.add(divTag.localName().impl());
- tagList.add(dlTag.localName().impl());
- tagList.add(dtTag.localName().impl());
- tagList.add(fieldsetTag.localName().impl());
- tagList.add(footerTag.localName().impl());
- tagList.add(formTag.localName().impl());
- tagList.add(h1Tag.localName().impl());
- tagList.add(h2Tag.localName().impl());
- tagList.add(h3Tag.localName().impl());
- tagList.add(h4Tag.localName().impl());
- tagList.add(h5Tag.localName().impl());
- tagList.add(h6Tag.localName().impl());
- tagList.add(headerTag.localName().impl());
- tagList.add(hgroupTag.localName().impl());
- tagList.add(hrTag.localName().impl());
- tagList.add(isindexTag.localName().impl());
- tagList.add(layerTag.localName().impl());
- tagList.add(liTag.localName().impl());
- tagList.add(listingTag.localName().impl());
- tagList.add(marqueeTag.localName().impl());
- tagList.add(menuTag.localName().impl());
- tagList.add(navTag.localName().impl());
- tagList.add(noembedTag.localName().impl());
- tagList.add(noframesTag.localName().impl());
- tagList.add(nolayerTag.localName().impl());
- tagList.add(noscriptTag.localName().impl());
- tagList.add(olTag.localName().impl());
- tagList.add(pTag.localName().impl());
- tagList.add(plaintextTag.localName().impl());
- tagList.add(preTag.localName().impl());
- tagList.add(sectionTag.localName().impl());
- tagList.add(tableTag.localName().impl());
- tagList.add(ulTag.localName().impl());
- tagList.add(xmpTag.localName().impl());
- }
- return &tagList;
-}
-
-bool HTMLElement::inEitherTagList(const Node* newChild)
-{
- if (newChild->isTextNode())
- return true;
-
- if (newChild->isHTMLElement()) {
- const HTMLElement* child = static_cast<const HTMLElement*>(newChild);
- if (inlineTagList()->contains(child->tagQName().localName().impl())) {
-#if PLATFORM(MAC)
- if (child->tagQName().localName() == styleTag) {
- // Leopard Mail doesn't expect <style> to be in the body of the document, so don't allow it in that case.
- // See <rdar://problem/6621310>
- Settings* settings = newChild->document() ? newChild->document()->settings() : 0;
- if (settings && settings->needsLeopardMailQuirks())
- return false;
- }
-#endif
- return true;
- }
- if (blockTagList()->contains(child->tagQName().localName().impl()))
- return true;
- return !isRecognizedTagName(child->tagQName()); // Accept custom html tags
- }
-
- return false;
-}
-
-bool HTMLElement::inInlineTagList(const Node* newChild)
-{
- if (newChild->isTextNode())
- return true;
-
- if (newChild->isHTMLElement()) {
- const HTMLElement* child = static_cast<const HTMLElement*>(newChild);
- if (inlineTagList()->contains(child->tagQName().localName().impl()))
- return true;
- return !isRecognizedTagName(child->tagQName()); // Accept custom html tags
- }
-
- return false;
-}
-
-bool HTMLElement::inBlockTagList(const Node* newChild)
-{
- if (newChild->isTextNode())
- return true;
-
- if (newChild->isHTMLElement()) {
- const HTMLElement* child = static_cast<const HTMLElement*>(newChild);
- return (blockTagList()->contains(child->tagQName().localName().impl()));
- }
-
- return false;
-}
-
-bool HTMLElement::checkDTD(const Node* newChild)
-{
- if (hasLocalName(addressTag) && newChild->hasTagName(pTag))
- return true;
- return inEitherTagList(newChild);
-}
-
bool HTMLElement::rendererIsNeeded(RenderStyle *style)
{
#if !ENABLE(XHTMLMP)
diff --git a/WebCore/html/HTMLElement.h b/WebCore/html/HTMLElement.h
index 8f54d3e..52e9ecf 100644
--- a/WebCore/html/HTMLElement.h
+++ b/WebCore/html/HTMLElement.h
@@ -30,8 +30,6 @@ namespace WebCore {
class DocumentFragment;
class HTMLCollection;
class HTMLFormElement;
-
-enum HTMLTagStatus { TagStatusOptional, TagStatusRequired, TagStatusForbidden };
class HTMLElement : public StyledElement {
public:
@@ -72,8 +70,7 @@ public:
virtual void accessKeyAction(bool sendToAnyElement);
- virtual HTMLTagStatus endTagRequirement() const;
- virtual int tagPriority() const;
+ bool ieForbidsInsertHTML() const;
virtual bool rendererIsNeeded(RenderStyle*);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
@@ -90,16 +87,6 @@ protected:
virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
virtual void parseMappedAttribute(Attribute*);
- virtual bool childAllowed(Node* newChild); // Error-checking during parsing that checks the DTD
-
- // Helper function to check the DTD for a given child node.
- virtual bool checkDTD(const Node*);
-
- static bool inEitherTagList(const Node*);
- static bool inInlineTagList(const Node*);
- static bool inBlockTagList(const Node*);
- static bool isRecognizedTagName(const QualifiedName&);
-
HTMLFormElement* findFormAncestor() const;
private:
diff --git a/WebCore/html/HTMLElementStack.cpp b/WebCore/html/HTMLElementStack.cpp
index 194753b..b6f4111 100644
--- a/WebCore/html/HTMLElementStack.cpp
+++ b/WebCore/html/HTMLElementStack.cpp
@@ -299,7 +299,7 @@ void HTMLElementStack::insertAbove(PassRefPtr<Element> element, ElementRecord* r
if (recordAbove->next() != recordBelow)
continue;
- recordAbove->setNext(new ElementRecord(element, recordAbove->releaseNext()));
+ recordAbove->setNext(adoptPtr(new ElementRecord(element, recordAbove->releaseNext())));
recordAbove->next()->element()->beginParsingChildren();
return;
}
@@ -492,7 +492,7 @@ Element* HTMLElementStack::bodyElement() const
void HTMLElementStack::pushCommon(PassRefPtr<Element> element)
{
ASSERT(m_htmlElement);
- m_top.set(new ElementRecord(element, m_top.release()));
+ m_top = adoptPtr(new ElementRecord(element, m_top.release()));
top()->beginParsingChildren();
}
diff --git a/WebCore/html/HTMLEmbedElement.cpp b/WebCore/html/HTMLEmbedElement.cpp
index afa56d4..0a15321 100644
--- a/WebCore/html/HTMLEmbedElement.cpp
+++ b/WebCore/html/HTMLEmbedElement.cpp
@@ -100,7 +100,7 @@ void HTMLEmbedElement::parseMappedAttribute(Attribute* attr)
m_url = deprecatedParseURL(value.string());
if (renderer() && isImageType()) {
if (!m_imageLoader)
- m_imageLoader.set(new HTMLImageLoader(this));
+ m_imageLoader = adoptPtr(new HTMLImageLoader(this));
m_imageLoader->updateFromElementIgnoringPreviousError();
}
} else if (attr->name() == hiddenAttr) {
@@ -167,7 +167,7 @@ void HTMLEmbedElement::attach()
if (isImage && renderer()) {
if (!m_imageLoader)
- m_imageLoader.set(new HTMLImageLoader(this));
+ m_imageLoader = adoptPtr(new HTMLImageLoader(this));
m_imageLoader->updateFromElement();
if (renderer())
diff --git a/WebCore/html/HTMLEmbedElement.h b/WebCore/html/HTMLEmbedElement.h
index 53da011..5f4df67 100644
--- a/WebCore/html/HTMLEmbedElement.h
+++ b/WebCore/html/HTMLEmbedElement.h
@@ -36,9 +36,6 @@ public:
private:
HTMLEmbedElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
-
virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLFieldSetElement.cpp b/WebCore/html/HTMLFieldSetElement.cpp
index ae0f8e7..4b90412 100644
--- a/WebCore/html/HTMLFieldSetElement.cpp
+++ b/WebCore/html/HTMLFieldSetElement.cpp
@@ -44,11 +44,6 @@ PassRefPtr<HTMLFieldSetElement> HTMLFieldSetElement::create(const QualifiedName&
return adoptRef(new HTMLFieldSetElement(tagName, document, form));
}
-bool HTMLFieldSetElement::checkDTD(const Node* newChild)
-{
- return newChild->hasTagName(legendTag) || HTMLElement::checkDTD(newChild);
-}
-
bool HTMLFieldSetElement::supportsFocus() const
{
return HTMLElement::supportsFocus();
diff --git a/WebCore/html/HTMLFieldSetElement.h b/WebCore/html/HTMLFieldSetElement.h
index 58c3ec4..db99a89 100644
--- a/WebCore/html/HTMLFieldSetElement.h
+++ b/WebCore/html/HTMLFieldSetElement.h
@@ -35,9 +35,6 @@ public:
private:
HTMLFieldSetElement(const QualifiedName&, Document*, HTMLFormElement*);
- virtual int tagPriority() const { return 3; }
- virtual bool checkDTD(const Node* newChild);
-
virtual bool supportsFocus() const;
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual const AtomicString& formControlType() const;
diff --git a/WebCore/html/HTMLFontElement.h b/WebCore/html/HTMLFontElement.h
index f96a50b..f97ab08 100644
--- a/WebCore/html/HTMLFontElement.h
+++ b/WebCore/html/HTMLFontElement.h
@@ -36,9 +36,6 @@ public:
private:
HTMLFontElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 1; }
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLFormCollection.cpp b/WebCore/html/HTMLFormCollection.cpp
index 7a2e63a..4147f29 100644
--- a/WebCore/html/HTMLFormCollection.cpp
+++ b/WebCore/html/HTMLFormCollection.cpp
@@ -39,7 +39,7 @@ using namespace HTMLNames;
inline CollectionCache* HTMLFormCollection::formCollectionInfo(HTMLFormElement* form)
{
if (!form->m_collectionCache)
- form->m_collectionCache.set(new CollectionCache);
+ form->m_collectionCache = adoptPtr(new CollectionCache);
return form->m_collectionCache.get();
}
diff --git a/WebCore/html/HTMLFormControlElement.cpp b/WebCore/html/HTMLFormControlElement.cpp
index ae1ac62..2080d91 100644
--- a/WebCore/html/HTMLFormControlElement.cpp
+++ b/WebCore/html/HTMLFormControlElement.cpp
@@ -39,7 +39,6 @@
#include "HTMLFormElement.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
-#include "LegacyHTMLTreeBuilder.h"
#include "LabelsNodeList.h"
#include "Page.h"
#include "RenderBox.h"
@@ -173,11 +172,7 @@ void HTMLFormControlElement::removedFromTree(bool deep)
{
// If the form and element are both in the same tree, preserve the connection to the form.
// Otherwise, null out our form and remove ourselves from the form's list of elements.
- LegacyHTMLTreeBuilder* treeBuilder = 0;
- if (DocumentParser* parser = document()->parser())
- treeBuilder = parser->htmlTreeBuilder();
-
- if (m_form && !(treeBuilder && treeBuilder->isHandlingResidualStyleAcrossBlocks()) && findRoot(this) != findRoot(m_form)) {
+ if (m_form && findRoot(this) != findRoot(m_form)) {
m_form->removeFormElement(this);
m_form = 0;
}
diff --git a/WebCore/html/HTMLFormControlElement.h b/WebCore/html/HTMLFormControlElement.h
index 02ea4e7..2352182 100644
--- a/WebCore/html/HTMLFormControlElement.h
+++ b/WebCore/html/HTMLFormControlElement.h
@@ -122,9 +122,6 @@ protected:
virtual bool recalcWillValidate() const;
private:
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 1; }
-
virtual const AtomicString& formControlName() const;
virtual const AtomicString& formControlType() const = 0;
diff --git a/WebCore/html/HTMLFormElement.cpp b/WebCore/html/HTMLFormElement.cpp
index d75de01..c53ea1d 100644
--- a/WebCore/html/HTMLFormElement.cpp
+++ b/WebCore/html/HTMLFormElement.cpp
@@ -529,7 +529,7 @@ void HTMLFormElement::addElementAlias(HTMLFormControlElement* element, const Ato
if (alias.isEmpty())
return;
if (!m_elementAliases)
- m_elementAliases.set(new AliasMap);
+ m_elementAliases = adoptPtr(new AliasMap);
m_elementAliases->set(alias.impl(), element);
}
diff --git a/WebCore/html/HTMLFormElement.h b/WebCore/html/HTMLFormElement.h
index c9fb9ac..151b2e8 100644
--- a/WebCore/html/HTMLFormElement.h
+++ b/WebCore/html/HTMLFormElement.h
@@ -114,9 +114,6 @@ public:
private:
HTMLFormElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 3; }
-
virtual bool rendererIsNeeded(RenderStyle*);
virtual void insertedIntoDocument();
virtual void removedFromDocument();
diff --git a/WebCore/html/HTMLFrameElement.h b/WebCore/html/HTMLFrameElement.h
index 3b1b5ad..d8cf509 100644
--- a/WebCore/html/HTMLFrameElement.h
+++ b/WebCore/html/HTMLFrameElement.h
@@ -39,9 +39,6 @@ public:
private:
HTMLFrameElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
-
virtual void attach();
virtual bool rendererIsNeeded(RenderStyle*);
diff --git a/WebCore/html/HTMLFrameSetElement.cpp b/WebCore/html/HTMLFrameSetElement.cpp
index 09c153d..48c19a1 100644
--- a/WebCore/html/HTMLFrameSetElement.cpp
+++ b/WebCore/html/HTMLFrameSetElement.cpp
@@ -59,15 +59,6 @@ PassRefPtr<HTMLFrameSetElement> HTMLFrameSetElement::create(const QualifiedName&
return adoptRef(new HTMLFrameSetElement(tagName, document));
}
-bool HTMLFrameSetElement::checkDTD(const Node* newChild)
-{
- // FIXME: Old code had adjacent double returns and seemed to want to do something with NOFRAMES (but didn't).
- // What is the correct behavior?
- if (newChild->isTextNode())
- return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
- return newChild->hasTagName(framesetTag) || newChild->hasTagName(frameTag);
-}
-
bool HTMLFrameSetElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
{
if (attrName == bordercolorAttr) {
diff --git a/WebCore/html/HTMLFrameSetElement.h b/WebCore/html/HTMLFrameSetElement.h
index a79793d..c761414 100644
--- a/WebCore/html/HTMLFrameSetElement.h
+++ b/WebCore/html/HTMLFrameSetElement.h
@@ -67,10 +67,6 @@ public:
private:
HTMLFrameSetElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 10; }
- virtual bool checkDTD(const Node* newChild);
-
virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLHRElement.h b/WebCore/html/HTMLHRElement.h
index 3cfaabf..e86bb56 100644
--- a/WebCore/html/HTMLHRElement.h
+++ b/WebCore/html/HTMLHRElement.h
@@ -35,9 +35,6 @@ public:
private:
HTMLHRElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
};
diff --git a/WebCore/html/HTMLHeadElement.cpp b/WebCore/html/HTMLHeadElement.cpp
index c57cc2f..8218311 100644
--- a/WebCore/html/HTMLHeadElement.cpp
+++ b/WebCore/html/HTMLHeadElement.cpp
@@ -47,21 +47,4 @@ PassRefPtr<HTMLHeadElement> HTMLHeadElement::create(const QualifiedName& tagName
return adoptRef(new HTMLHeadElement(tagName, document));
}
-bool HTMLHeadElement::childAllowed(Node* newChild)
-{
- // Do not allow non-whitespace text nodes in the head
- if (newChild->isTextNode())
- return static_cast<Text*>(newChild)->containsOnlyWhitespace();
-
- return HTMLElement::childAllowed(newChild);
-}
-
-bool HTMLHeadElement::checkDTD(const Node* newChild)
-{
- return newChild->hasTagName(noscriptTag) || newChild->hasTagName(titleTag) || newChild->hasTagName(isindexTag) ||
- newChild->hasTagName(baseTag) || newChild->hasTagName(scriptTag) ||
- newChild->hasTagName(styleTag) || newChild->hasTagName(metaTag) ||
- newChild->hasTagName(linkTag) || newChild->isTextNode();
-}
-
}
diff --git a/WebCore/html/HTMLHeadElement.h b/WebCore/html/HTMLHeadElement.h
index c7cfc00..1a5df86 100644
--- a/WebCore/html/HTMLHeadElement.h
+++ b/WebCore/html/HTMLHeadElement.h
@@ -33,14 +33,8 @@ public:
static PassRefPtr<HTMLHeadElement> create(Document*);
static PassRefPtr<HTMLHeadElement> create(const QualifiedName&, Document*);
- virtual int tagPriority() const { return 10; }
-
private:
HTMLHeadElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
- virtual bool childAllowed(Node* newChild);
- virtual bool checkDTD(const Node* newChild);
};
} // namespace
diff --git a/WebCore/html/HTMLHeadingElement.cpp b/WebCore/html/HTMLHeadingElement.cpp
index e2a0f73..47a9ea3 100644
--- a/WebCore/html/HTMLHeadingElement.cpp
+++ b/WebCore/html/HTMLHeadingElement.cpp
@@ -23,12 +23,8 @@
#include "config.h"
#include "HTMLHeadingElement.h"
-#include "HTMLNames.h"
-
namespace WebCore {
-using namespace HTMLNames;
-
inline HTMLHeadingElement::HTMLHeadingElement(const QualifiedName& tagName, Document* document)
: HTMLElement(tagName, document)
{
@@ -39,14 +35,4 @@ PassRefPtr<HTMLHeadingElement> HTMLHeadingElement::create(const QualifiedName& t
return adoptRef(new HTMLHeadingElement(tagName, document));
}
-bool HTMLHeadingElement::checkDTD(const Node* newChild)
-{
- if (newChild->hasTagName(h1Tag) || newChild->hasTagName(h2Tag) ||
- newChild->hasTagName(h3Tag) || newChild->hasTagName(h4Tag) ||
- newChild->hasTagName(h5Tag) || newChild->hasTagName(h6Tag))
- return false;
-
- return inEitherTagList(newChild);
-}
-
}
diff --git a/WebCore/html/HTMLHeadingElement.h b/WebCore/html/HTMLHeadingElement.h
index 575a05c..f09cfe3 100644
--- a/WebCore/html/HTMLHeadingElement.h
+++ b/WebCore/html/HTMLHeadingElement.h
@@ -33,10 +33,6 @@ public:
private:
HTMLHeadingElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 5; }
- virtual bool checkDTD(const Node* newChild);
};
} // namespace WebCore
diff --git a/WebCore/html/HTMLHtmlElement.cpp b/WebCore/html/HTMLHtmlElement.cpp
index 93edf6c..6205d10 100644
--- a/WebCore/html/HTMLHtmlElement.cpp
+++ b/WebCore/html/HTMLHtmlElement.cpp
@@ -50,12 +50,6 @@ PassRefPtr<HTMLHtmlElement> HTMLHtmlElement::create(const QualifiedName& tagName
return adoptRef(new HTMLHtmlElement(tagName, document));
}
-bool HTMLHtmlElement::checkDTD(const Node* newChild)
-{
- return newChild->hasTagName(headTag) || newChild->hasTagName(bodyTag) ||
- newChild->hasTagName(framesetTag) || newChild->hasTagName(noframesTag);
-}
-
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
void HTMLHtmlElement::insertedIntoDocument()
{
diff --git a/WebCore/html/HTMLHtmlElement.h b/WebCore/html/HTMLHtmlElement.h
index 34879ed..e854fb1 100644
--- a/WebCore/html/HTMLHtmlElement.h
+++ b/WebCore/html/HTMLHtmlElement.h
@@ -36,10 +36,6 @@ public:
private:
HTMLHtmlElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 11; }
- virtual bool checkDTD(const Node* newChild);
-
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
virtual void insertedIntoDocument();
#endif
diff --git a/WebCore/html/HTMLIFrameElement.h b/WebCore/html/HTMLIFrameElement.h
index 1d01c66..61cd6b6 100644
--- a/WebCore/html/HTMLIFrameElement.h
+++ b/WebCore/html/HTMLIFrameElement.h
@@ -35,9 +35,6 @@ public:
private:
HTMLIFrameElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 1; }
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLImageElement.h b/WebCore/html/HTMLImageElement.h
index 2b29570..7f38216 100644
--- a/WebCore/html/HTMLImageElement.h
+++ b/WebCore/html/HTMLImageElement.h
@@ -80,9 +80,6 @@ protected:
virtual void willMoveToNewOwnerDocument();
private:
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
-
virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index 50b6ed0..f9c5162 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -50,7 +50,7 @@
#include "HTMLImageLoader.h"
#include "HTMLNames.h"
#include "HTMLOptionElement.h"
-#include "LegacyHTMLTreeBuilder.h"
+#include "HTMLTreeBuilder.h"
#include "KeyboardEvent.h"
#include "LocalizedStrings.h"
#include "MouseEvent.h"
@@ -746,9 +746,9 @@ void HTMLInputElement::setType(const String& t)
}
typedef HashMap<String, HTMLInputElement::InputType, CaseFoldingHash> InputTypeMap;
-static const InputTypeMap* createTypeMap()
+static PassOwnPtr<InputTypeMap> createTypeMap()
{
- InputTypeMap* map = new InputTypeMap;
+ OwnPtr<InputTypeMap> map = adoptPtr(new InputTypeMap);
map->add("button", HTMLInputElement::BUTTON);
map->add("checkbox", HTMLInputElement::CHECKBOX);
map->add("color", HTMLInputElement::COLOR);
@@ -773,12 +773,12 @@ static const InputTypeMap* createTypeMap()
map->add("url", HTMLInputElement::URL);
map->add("week", HTMLInputElement::WEEK);
// No need to register "text" because it is the default type.
- return map;
+ return map.release();
}
void HTMLInputElement::setInputType(const String& t)
{
- static const InputTypeMap* typeMap = createTypeMap();
+ static const InputTypeMap* typeMap = createTypeMap().leakPtr();
InputType newType = t.isNull() ? TEXT : typeMap->get(t);
#ifdef ANDROID_ACCEPT_CHANGES_TO_FOCUSED_TEXTFIELDS
if (newType == PASSWORD && document()->focusedNode() == this)
@@ -1089,7 +1089,7 @@ void HTMLInputElement::parseMappedAttribute(Attribute* attr)
} else if (attr->name() == srcAttr) {
if (renderer() && inputType() == IMAGE) {
if (!m_imageLoader)
- m_imageLoader.set(new HTMLImageLoader(this));
+ m_imageLoader = adoptPtr(new HTMLImageLoader(this));
m_imageLoader->updateFromElementIgnoringPreviousError();
}
} else if (attr->name() == usemapAttr || attr->name() == accesskeyAttr) {
@@ -1212,7 +1212,7 @@ void HTMLInputElement::attach()
if (inputType() == IMAGE) {
if (!m_imageLoader)
- m_imageLoader.set(new HTMLImageLoader(this));
+ m_imageLoader = adoptPtr(new HTMLImageLoader(this));
m_imageLoader->updateFromElement();
if (renderer() && m_imageLoader->haveFiredBeforeLoadEvent()) {
RenderImage* imageObj = toRenderImage(renderer());
@@ -2059,7 +2059,7 @@ void* HTMLInputElement::preDispatchEventHandler(Event *evt)
if ((inputType() == CHECKBOX || inputType() == RADIO) && evt->isMouseEvent()
&& evt->type() == eventNames().clickEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
- EventHandlingState* state = new EventHandlingState(indeterminate(), checked());
+ OwnPtr<EventHandlingState> state = adoptPtr(new EventHandlingState(indeterminate(), checked()));
if (inputType() == CHECKBOX) {
if (indeterminate())
@@ -2081,7 +2081,7 @@ void* HTMLInputElement::preDispatchEventHandler(Event *evt)
setIndeterminate(false);
setChecked(true, true);
}
- result = state;
+ result = state.leakPtr(); // FIXME: Check whether this actually ends up leaking.
}
return result;
}
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index 18cbaa4..e6cdda3 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -218,9 +218,6 @@ private:
virtual void willMoveToNewOwnerDocument();
virtual void didMoveToNewOwnerDocument();
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
-
virtual bool isKeyboardFocusable(KeyboardEvent*) const;
virtual bool isMouseFocusable() const;
virtual bool isEnumeratable() const { return inputType() != IMAGE; }
diff --git a/WebCore/html/HTMLIsIndexElement.h b/WebCore/html/HTMLIsIndexElement.h
index 8c33d71..857ef75 100644
--- a/WebCore/html/HTMLIsIndexElement.h
+++ b/WebCore/html/HTMLIsIndexElement.h
@@ -36,8 +36,6 @@ public:
private:
HTMLIsIndexElement(const QualifiedName&, Document*, HTMLFormElement*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
virtual bool canTriggerImplicitSubmission() const { return true; }
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLKeygenElement.cpp b/WebCore/html/HTMLKeygenElement.cpp
index 5185f51..881a0a8 100644
--- a/WebCore/html/HTMLKeygenElement.cpp
+++ b/WebCore/html/HTMLKeygenElement.cpp
@@ -45,13 +45,14 @@ inline HTMLKeygenElement::HTMLKeygenElement(const QualifiedName& tagName, Docume
{
ASSERT(hasTagName(keygenTag));
+ // FIXME: This markup should go in the shadow tree.
// Add one option element for each key size.
Vector<String> keys;
getSupportedKeySizes(keys);
for (size_t i = 0; i < keys.size(); ++i) {
RefPtr<HTMLOptionElement> option = HTMLOptionElement::create(document, this->form());
- legacyParserAddChild(option);
- option->legacyParserAddChild(Text::create(document, keys[i]));
+ parserAddChild(option);
+ option->parserAddChild(Text::create(document, keys[i]));
}
}
diff --git a/WebCore/html/HTMLKeygenElement.h b/WebCore/html/HTMLKeygenElement.h
index baa9a17..4c08014 100644
--- a/WebCore/html/HTMLKeygenElement.h
+++ b/WebCore/html/HTMLKeygenElement.h
@@ -35,7 +35,6 @@ public:
private:
HTMLKeygenElement(const QualifiedName&, Document*, HTMLFormElement*);
- virtual int tagPriority() const { return 0; }
virtual const AtomicString& formControlType() const;
virtual bool isEnumeratable() const { return false; }
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLLIElement.h b/WebCore/html/HTMLLIElement.h
index 418f7a4..ad12b67 100644
--- a/WebCore/html/HTMLLIElement.h
+++ b/WebCore/html/HTMLLIElement.h
@@ -35,9 +35,6 @@ public:
private:
HTMLLIElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
- virtual int tagPriority() const { return 3; }
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLLabelElement.h b/WebCore/html/HTMLLabelElement.h
index 7964ade..2b09e17 100644
--- a/WebCore/html/HTMLLabelElement.h
+++ b/WebCore/html/HTMLLabelElement.h
@@ -38,8 +38,6 @@ public:
private:
HTMLLabelElement(const QualifiedName&, Document*);
- virtual int tagPriority() const { return 5; }
-
virtual bool isFocusable() const;
virtual void accessKeyAction(bool sendToAnyElement);
diff --git a/WebCore/html/HTMLLinkElement.h b/WebCore/html/HTMLLinkElement.h
index 6d7643a..aec971b 100644
--- a/WebCore/html/HTMLLinkElement.h
+++ b/WebCore/html/HTMLLinkElement.h
@@ -79,9 +79,6 @@ public:
bool isIcon() const { return m_relAttribute.m_isIcon; }
private:
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
-
virtual void parseMappedAttribute(Attribute*);
void process();
diff --git a/WebCore/html/HTMLMapElement.cpp b/WebCore/html/HTMLMapElement.cpp
index eba23ca..873a9ab 100644
--- a/WebCore/html/HTMLMapElement.cpp
+++ b/WebCore/html/HTMLMapElement.cpp
@@ -58,12 +58,6 @@ HTMLMapElement::~HTMLMapElement()
{
}
-bool HTMLMapElement::checkDTD(const Node* newChild)
-{
- return inEitherTagList(newChild) || newChild->hasTagName(areaTag) // HTML 4 DTD
- || newChild->hasTagName(scriptTag); // extensions
-}
-
bool HTMLMapElement::mapMouseEvent(int x, int y, const IntSize& size, HitTestResult& result)
{
HTMLAreaElement* defaultArea = 0;
diff --git a/WebCore/html/HTMLMapElement.h b/WebCore/html/HTMLMapElement.h
index 1394c95..c0c1395 100644
--- a/WebCore/html/HTMLMapElement.h
+++ b/WebCore/html/HTMLMapElement.h
@@ -47,10 +47,6 @@ public:
private:
HTMLMapElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 1; }
- virtual bool checkDTD(const Node*);
-
virtual void parseMappedAttribute(Attribute*);
virtual void insertedIntoDocument();
diff --git a/WebCore/html/HTMLMarqueeElement.h b/WebCore/html/HTMLMarqueeElement.h
index 4932d46..1b3229a 100644
--- a/WebCore/html/HTMLMarqueeElement.h
+++ b/WebCore/html/HTMLMarqueeElement.h
@@ -43,9 +43,6 @@ public:
private:
HTMLMarqueeElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 3; }
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp
index 13b7807..751735d 100644
--- a/WebCore/html/HTMLMediaElement.cpp
+++ b/WebCore/html/HTMLMediaElement.cpp
@@ -162,12 +162,6 @@ void HTMLMediaElement::didMoveToNewOwnerDocument()
HTMLElement::didMoveToNewOwnerDocument();
}
-
-bool HTMLMediaElement::checkDTD(const Node* newChild)
-{
- return newChild->hasTagName(sourceTag) || HTMLElement::checkDTD(newChild);
-}
-
void HTMLMediaElement::attributeChanged(Attribute* attr, bool preserveDecls)
{
HTMLElement::attributeChanged(attr, preserveDecls);
diff --git a/WebCore/html/HTMLMediaElement.h b/WebCore/html/HTMLMediaElement.h
index a73abba..4706178 100644
--- a/WebCore/html/HTMLMediaElement.h
+++ b/WebCore/html/HTMLMediaElement.h
@@ -183,7 +183,6 @@ protected:
virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; }
private:
- virtual bool checkDTD(const Node* newChild);
virtual void attributeChanged(Attribute*, bool preserveDecls);
virtual bool rendererIsNeeded(RenderStyle*);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
diff --git a/WebCore/html/HTMLMenuElement.h b/WebCore/html/HTMLMenuElement.h
index 002df00..6b588ec 100644
--- a/WebCore/html/HTMLMenuElement.h
+++ b/WebCore/html/HTMLMenuElement.h
@@ -33,9 +33,6 @@ public:
private:
HTMLMenuElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 5; }
};
} //namespace
diff --git a/WebCore/html/HTMLMetaElement.h b/WebCore/html/HTMLMetaElement.h
index 6af7483..9b0178e 100644
--- a/WebCore/html/HTMLMetaElement.h
+++ b/WebCore/html/HTMLMetaElement.h
@@ -38,9 +38,6 @@ public:
private:
HTMLMetaElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
-
virtual void parseMappedAttribute(Attribute*);
virtual void insertedIntoDocument();
diff --git a/WebCore/html/HTMLMeterElement.cpp b/WebCore/html/HTMLMeterElement.cpp
index 7c025f7..aaba125 100644
--- a/WebCore/html/HTMLMeterElement.cpp
+++ b/WebCore/html/HTMLMeterElement.cpp
@@ -28,7 +28,7 @@
#include "FormDataList.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
-#include "LegacyHTMLTreeBuilder.h"
+#include "HTMLTreeBuilder.h"
#include "RenderMeter.h"
#include <wtf/StdLibExtras.h>
diff --git a/WebCore/html/HTMLModElement.h b/WebCore/html/HTMLModElement.h
index 7370320..2b09e21 100644
--- a/WebCore/html/HTMLModElement.h
+++ b/WebCore/html/HTMLModElement.h
@@ -34,9 +34,6 @@ public:
private:
HTMLModElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 1; }
};
} //namespace
diff --git a/WebCore/html/HTMLNoScriptElement.cpp b/WebCore/html/HTMLNoScriptElement.cpp
index f232340..5bba16f 100644
--- a/WebCore/html/HTMLNoScriptElement.cpp
+++ b/WebCore/html/HTMLNoScriptElement.cpp
@@ -42,11 +42,6 @@ PassRefPtr<HTMLNoScriptElement> HTMLNoScriptElement::create(const QualifiedName&
return adoptRef(new HTMLNoScriptElement(tagName, document));
}
-bool HTMLNoScriptElement::checkDTD(const Node* newChild)
-{
- return newChild->isTextNode() || inBlockTagList(newChild);
-}
-
void HTMLNoScriptElement::attach()
{
HTMLElement::attach();
diff --git a/WebCore/html/HTMLNoScriptElement.h b/WebCore/html/HTMLNoScriptElement.h
index 8b98205..9a3b92d 100644
--- a/WebCore/html/HTMLNoScriptElement.h
+++ b/WebCore/html/HTMLNoScriptElement.h
@@ -34,7 +34,6 @@ public:
private:
HTMLNoScriptElement(const QualifiedName&, Document*);
- virtual bool checkDTD(const Node*);
virtual void attach();
virtual void recalcStyle(StyleChange);
virtual bool childShouldCreateRenderer(Node*) const;
diff --git a/WebCore/html/HTMLOListElement.h b/WebCore/html/HTMLOListElement.h
index 3067138..179fec0 100644
--- a/WebCore/html/HTMLOListElement.h
+++ b/WebCore/html/HTMLOListElement.h
@@ -38,9 +38,6 @@ public:
private:
HTMLOListElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 5; }
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLObjectElement.cpp b/WebCore/html/HTMLObjectElement.cpp
index 5989ec7..de1ed91 100644
--- a/WebCore/html/HTMLObjectElement.cpp
+++ b/WebCore/html/HTMLObjectElement.cpp
@@ -86,7 +86,7 @@ void HTMLObjectElement::parseMappedAttribute(Attribute* attr)
m_needWidgetUpdate = true;
if (renderer() && isImageType()) {
if (!m_imageLoader)
- m_imageLoader.set(new HTMLImageLoader(this));
+ m_imageLoader = adoptPtr(new HTMLImageLoader(this));
m_imageLoader->updateFromElementIgnoringPreviousError();
}
} else if (attr->name() == classidAttr) {
@@ -152,7 +152,7 @@ void HTMLObjectElement::attach()
if (isImage && renderer() && !m_useFallbackContent) {
if (!m_imageLoader)
- m_imageLoader.set(new HTMLImageLoader(this));
+ m_imageLoader = adoptPtr(new HTMLImageLoader(this));
m_imageLoader->updateFromElement();
}
}
@@ -262,6 +262,32 @@ void HTMLObjectElement::renderFallbackContent()
attach();
}
+// FIXME: This should be removed, all callers are almost certainly wrong.
+static bool isRecognizedTagName(const QualifiedName& tagName)
+{
+ DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ());
+ if (tagList.isEmpty()) {
+ size_t tagCount = 0;
+ QualifiedName** tags = HTMLNames::getHTMLTags(&tagCount);
+ for (size_t i = 0; i < tagCount; i++) {
+ if (*tags[i] == bgsoundTag
+ || *tags[i] == commandTag
+ || *tags[i] == detailsTag
+ || *tags[i] == figcaptionTag
+ || *tags[i] == figureTag
+ || *tags[i] == summaryTag
+ || *tags[i] == trackTag) {
+ // Even though we have atoms for these tags, we don't want to
+ // treat them as "recognized tags" for the purpose of parsing
+ // because that changes how we parse documents.
+ continue;
+ }
+ tagList.add(tags[i]->localName().impl());
+ }
+ }
+ return tagList.contains(tagName.localName().impl());
+}
+
void HTMLObjectElement::updateDocNamedItem()
{
// The rule is "<object> elements with no children other than
@@ -273,7 +299,8 @@ void HTMLObjectElement::updateDocNamedItem()
while (child && isNamedItem) {
if (child->isElementNode()) {
Element* element = static_cast<Element*>(child);
- if (HTMLElement::isRecognizedTagName(element->tagQName()) && !element->hasTagName(paramTag))
+ // FIXME: Use of isRecognizedTagName is almost certainly wrong here.
+ if (isRecognizedTagName(element->tagQName()) && !element->hasTagName(paramTag))
isNamedItem = false;
} else if (child->isTextNode()) {
if (!static_cast<Text*>(child)->containsOnlyWhitespace())
diff --git a/WebCore/html/HTMLObjectElement.h b/WebCore/html/HTMLObjectElement.h
index c904c74..8dc59be 100644
--- a/WebCore/html/HTMLObjectElement.h
+++ b/WebCore/html/HTMLObjectElement.h
@@ -44,8 +44,6 @@ public:
private:
HTMLObjectElement(const QualifiedName&, Document*, bool createdByParser);
- virtual int tagPriority() const { return 5; }
-
virtual void parseMappedAttribute(Attribute*);
virtual void attach();
diff --git a/WebCore/html/HTMLOptGroupElement.cpp b/WebCore/html/HTMLOptGroupElement.cpp
index 7db0924..091e0f2 100644
--- a/WebCore/html/HTMLOptGroupElement.cpp
+++ b/WebCore/html/HTMLOptGroupElement.cpp
@@ -86,12 +86,6 @@ void HTMLOptGroupElement::recalcSelectOptions()
static_cast<HTMLSelectElement*>(select)->setRecalcListItems();
}
-bool HTMLOptGroupElement::checkDTD(const Node* newChild)
-{
- // Make sure to keep this in sync with <select> (other than not allowing an optgroup).
- return newChild->isTextNode() || newChild->hasTagName(HTMLNames::optionTag) || newChild->hasTagName(HTMLNames::hrTag) || newChild->hasTagName(HTMLNames::scriptTag);
-}
-
void HTMLOptGroupElement::attach()
{
if (parentNode()->renderStyle())
diff --git a/WebCore/html/HTMLOptGroupElement.h b/WebCore/html/HTMLOptGroupElement.h
index 095b9d2..a58e957 100644
--- a/WebCore/html/HTMLOptGroupElement.h
+++ b/WebCore/html/HTMLOptGroupElement.h
@@ -42,7 +42,6 @@ public:
private:
HTMLOptGroupElement(const QualifiedName&, Document*, HTMLFormElement*);
- virtual bool checkDTD(const Node*);
virtual const AtomicString& formControlType() const;
virtual bool supportsFocus() const;
virtual bool isFocusable() const;
diff --git a/WebCore/html/HTMLOptionElement.cpp b/WebCore/html/HTMLOptionElement.cpp
index 19f40be..3bf522c 100644
--- a/WebCore/html/HTMLOptionElement.cpp
+++ b/WebCore/html/HTMLOptionElement.cpp
@@ -78,11 +78,6 @@ PassRefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document
return element.release();
}
-bool HTMLOptionElement::checkDTD(const Node* newChild)
-{
- return newChild->isTextNode() || newChild->hasTagName(scriptTag);
-}
-
void HTMLOptionElement::attach()
{
if (parentNode()->renderStyle())
diff --git a/WebCore/html/HTMLOptionElement.h b/WebCore/html/HTMLOptionElement.h
index d0ff23b..deac66a 100644
--- a/WebCore/html/HTMLOptionElement.h
+++ b/WebCore/html/HTMLOptionElement.h
@@ -78,9 +78,6 @@ public:
private:
HTMLOptionElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
- virtual int tagPriority() const { return 2; }
- virtual bool checkDTD(const Node* newChild);
virtual bool supportsFocus() const;
virtual bool isFocusable() const;
virtual bool rendererIsNeeded(RenderStyle*) { return false; }
diff --git a/WebCore/html/HTMLParagraphElement.cpp b/WebCore/html/HTMLParagraphElement.cpp
index 4af5b77..0b3e83f 100644
--- a/WebCore/html/HTMLParagraphElement.cpp
+++ b/WebCore/html/HTMLParagraphElement.cpp
@@ -44,11 +44,6 @@ PassRefPtr<HTMLParagraphElement> HTMLParagraphElement::create(const QualifiedNam
return adoptRef(new HTMLParagraphElement(tagName, document));
}
-bool HTMLParagraphElement::checkDTD(const Node* newChild)
-{
- return inInlineTagList(newChild) || (document()->inCompatMode() && newChild->hasTagName(tableTag));
-}
-
bool HTMLParagraphElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
{
if (attrName == alignAttr) {
diff --git a/WebCore/html/HTMLParagraphElement.h b/WebCore/html/HTMLParagraphElement.h
index 0a31a1c..6dbf071 100644
--- a/WebCore/html/HTMLParagraphElement.h
+++ b/WebCore/html/HTMLParagraphElement.h
@@ -34,10 +34,6 @@ public:
private:
HTMLParagraphElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 3; }
- virtual bool checkDTD(const Node* newChild);
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
};
diff --git a/WebCore/html/HTMLParamElement.h b/WebCore/html/HTMLParamElement.h
index a787927..f13f8fa 100644
--- a/WebCore/html/HTMLParamElement.h
+++ b/WebCore/html/HTMLParamElement.h
@@ -37,20 +37,18 @@ public:
private:
HTMLParamElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
-
virtual void parseMappedAttribute(Attribute*);
virtual bool isURLAttribute(Attribute*) const;
virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
+ // FIXME: These don't need to be stored as members and instead
+ // name() value() could use getAttribute(nameAttr/valueAttr).
AtomicString m_name;
AtomicString m_value;
};
-
-}
+} // namespace WebCore
#endif
diff --git a/WebCore/html/HTMLParserScheduler.h b/WebCore/html/HTMLParserScheduler.h
index 1ea2c65..5be33b0 100644
--- a/WebCore/html/HTMLParserScheduler.h
+++ b/WebCore/html/HTMLParserScheduler.h
@@ -29,6 +29,7 @@
#include "Timer.h"
#include <wtf/CurrentTime.h>
#include <wtf/Noncopyable.h>
+#include <wtf/PassOwnPtr.h>
namespace WebCore {
@@ -36,7 +37,10 @@ class HTMLDocumentParser;
class HTMLParserScheduler : public Noncopyable {
public:
- HTMLParserScheduler(HTMLDocumentParser*);
+ static PassOwnPtr<HTMLParserScheduler> create(HTMLDocumentParser* parser)
+ {
+ return adoptPtr(new HTMLParserScheduler(parser));
+ }
~HTMLParserScheduler();
struct PumpSession {
@@ -70,6 +74,8 @@ public:
bool isScheduledForResume() const { return m_continueNextChunkTimer.isActive(); }
private:
+ HTMLParserScheduler(HTMLDocumentParser*);
+
void continueNextChunkTimerFired(Timer<HTMLParserScheduler>*);
HTMLDocumentParser* m_parser;
diff --git a/WebCore/html/HTMLPlugInElement.cpp b/WebCore/html/HTMLPlugInElement.cpp
index 2ce44a6..9f479fb 100644
--- a/WebCore/html/HTMLPlugInElement.cpp
+++ b/WebCore/html/HTMLPlugInElement.cpp
@@ -143,11 +143,6 @@ void HTMLPlugInElement::parseMappedAttribute(Attribute* attr)
HTMLFrameOwnerElement::parseMappedAttribute(attr);
}
-bool HTMLPlugInElement::checkDTD(const Node* newChild)
-{
- return newChild->hasTagName(paramTag) || HTMLFrameOwnerElement::checkDTD(newChild);
-}
-
void HTMLPlugInElement::defaultEventHandler(Event* event)
{
// Firefox seems to use a fake event listener to dispatch events to plug-in (tested with mouse events only).
diff --git a/WebCore/html/HTMLPlugInElement.h b/WebCore/html/HTMLPlugInElement.h
index 6288e74..eadf38a 100644
--- a/WebCore/html/HTMLPlugInElement.h
+++ b/WebCore/html/HTMLPlugInElement.h
@@ -71,9 +71,6 @@ private:
virtual RenderWidget* renderWidgetForJSBindings() const = 0;
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual bool checkDTD(const Node* newChild);
-
virtual void updateWidget() { }
protected:
diff --git a/WebCore/html/HTMLPreElement.h b/WebCore/html/HTMLPreElement.h
index 1a67c65..3ccdb86 100644
--- a/WebCore/html/HTMLPreElement.h
+++ b/WebCore/html/HTMLPreElement.h
@@ -34,9 +34,6 @@ public:
private:
HTMLPreElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 5; }
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
};
diff --git a/WebCore/html/HTMLPreloadScanner.cpp b/WebCore/html/HTMLPreloadScanner.cpp
index 57ac408..7aafd90 100644
--- a/WebCore/html/HTMLPreloadScanner.cpp
+++ b/WebCore/html/HTMLPreloadScanner.cpp
@@ -31,6 +31,7 @@
#include "CSSHelper.h"
#include "DocLoader.h"
#include "Document.h"
+#include "HTMLTokenizer.h"
#include "HTMLTreeBuilder.h"
#include "HTMLLinkElement.h"
#include "HTMLNames.h"
@@ -120,6 +121,7 @@ private:
HTMLPreloadScanner::HTMLPreloadScanner(Document* document)
: m_document(document)
, m_cssScanner(document)
+ , m_tokenizer(HTMLTokenizer::create())
, m_bodySeen(false)
, m_inStyle(false)
{
@@ -134,7 +136,7 @@ void HTMLPreloadScanner::scan()
{
// FIXME: We should save and re-use these tokens in HTMLDocumentParser if
// the pending script doesn't end up calling document.write.
- while (m_tokenizer.nextToken(m_source, m_token)) {
+ while (m_tokenizer->nextToken(m_source, m_token)) {
processToken();
m_token.clear();
}
@@ -155,12 +157,12 @@ void HTMLPreloadScanner::processToken()
return;
PreloadTask task(m_token);
- m_tokenizer.setState(HTMLTreeBuilder::adjustedLexerState(m_tokenizer.state(), task.tagName(), m_document->frame()));
+ m_tokenizer->setState(HTMLTreeBuilder::adjustedLexerState(m_tokenizer->state(), task.tagName(), m_document->frame()));
if (task.tagName() == scriptTag) {
// The tree builder handles scriptTag separately from the other tokenizer
// state adjustments, so we need to handle it separately too.
- ASSERT(m_tokenizer.state() == HTMLTokenizer::DataState);
- m_tokenizer.setState(HTMLTokenizer::ScriptDataState);
+ ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState);
+ m_tokenizer->setState(HTMLTokenizer::ScriptDataState);
}
if (task.tagName() == bodyTag)
diff --git a/WebCore/html/HTMLPreloadScanner.h b/WebCore/html/HTMLPreloadScanner.h
index ee49ee0..94a90e6 100644
--- a/WebCore/html/HTMLPreloadScanner.h
+++ b/WebCore/html/HTMLPreloadScanner.h
@@ -28,7 +28,6 @@
#define HTMLPreloadScanner_h
#include "CSSPreloadScanner.h"
-#include "HTMLTokenizer.h"
#include "HTMLToken.h"
#include "SegmentedString.h"
#include <wtf/Noncopyable.h>
@@ -37,6 +36,7 @@ namespace WebCore {
class Document;
class HTMLToken;
+class HTMLTokenizer;
class SegmentedString;
class HTMLPreloadScanner : public Noncopyable {
@@ -52,9 +52,9 @@ private:
Document* m_document;
SegmentedString m_source;
- HTMLTokenizer m_tokenizer;
- HTMLToken m_token;
CSSPreloadScanner m_cssScanner;
+ OwnPtr<HTMLTokenizer> m_tokenizer;
+ HTMLToken m_token;
bool m_bodySeen;
bool m_inStyle;
};
diff --git a/WebCore/html/HTMLProgressElement.cpp b/WebCore/html/HTMLProgressElement.cpp
index 5cf7714..de65fcb 100644
--- a/WebCore/html/HTMLProgressElement.cpp
+++ b/WebCore/html/HTMLProgressElement.cpp
@@ -28,7 +28,7 @@
#include "FormDataList.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
-#include "LegacyHTMLTreeBuilder.h"
+#include "HTMLTreeBuilder.h"
#include "RenderProgress.h"
#include <wtf/StdLibExtras.h>
diff --git a/WebCore/html/HTMLQuoteElement.h b/WebCore/html/HTMLQuoteElement.h
index 9261da6..225dde8 100644
--- a/WebCore/html/HTMLQuoteElement.h
+++ b/WebCore/html/HTMLQuoteElement.h
@@ -36,9 +36,6 @@ public:
private:
HTMLQuoteElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 1; }
-
virtual void insertedIntoDocument();
};
diff --git a/WebCore/html/HTMLScriptElement.h b/WebCore/html/HTMLScriptElement.h
index b18278d..a5629ee 100644
--- a/WebCore/html/HTMLScriptElement.h
+++ b/WebCore/html/HTMLScriptElement.h
@@ -49,10 +49,6 @@ private:
virtual String scriptContent() const;
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 1; }
- virtual bool checkDTD(const Node* newChild) { return newChild->isTextNode(); }
-
virtual void parseMappedAttribute(Attribute*);
virtual void insertedIntoDocument();
virtual void removedFromDocument();
diff --git a/WebCore/html/HTMLScriptRunner.cpp b/WebCore/html/HTMLScriptRunner.cpp
index 0d603ed..6d470a0 100644
--- a/WebCore/html/HTMLScriptRunner.cpp
+++ b/WebCore/html/HTMLScriptRunner.cpp
@@ -77,6 +77,11 @@ HTMLScriptRunner::~HTMLScriptRunner()
stopWatchingForLoad(m_parsingBlockingScript);
}
+void HTMLScriptRunner::detach()
+{
+ m_document = 0;
+}
+
static KURL documentURLForScriptExecution(Document* document)
{
if (!document || !document->frame())
@@ -119,6 +124,7 @@ bool HTMLScriptRunner::isPendingScriptReady(const PendingScript& script)
void HTMLScriptRunner::executeParsingBlockingScript()
{
+ ASSERT(m_document);
ASSERT(!m_scriptNestingLevel);
ASSERT(m_document->haveStylesheetsLoaded());
ASSERT(isPendingScriptReady(m_parsingBlockingScript));
@@ -152,6 +158,7 @@ void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript& pendi
void HTMLScriptRunner::executeScript(Element* element, const ScriptSourceCode& sourceCode) const
{
+ ASSERT(m_document);
ScriptElement* scriptElement = toScriptElement(element);
ASSERT(scriptElement);
if (!scriptElement->shouldExecuteAsJavaScript())
@@ -222,6 +229,7 @@ bool HTMLScriptRunner::executeScriptsWaitingForLoad(CachedResource* cachedScript
bool HTMLScriptRunner::executeScriptsWaitingForStylesheets()
{
+ ASSERT(m_document);
// Callers should check hasScriptsWaitingForStylesheets() before calling
// to prevent parser or script re-entry during </style> parsing.
ASSERT(hasScriptsWaitingForStylesheets());
@@ -269,6 +277,7 @@ bool HTMLScriptRunner::requestPendingScript(PendingScript& pendingScript, Elemen
// http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#running-a-script
void HTMLScriptRunner::runScript(Element* script, int startingLineNumber)
{
+ ASSERT(m_document);
ASSERT(!haveParsingBlockingScript());
{
InsertionPointRecord insertionPointRecord(m_host->inputStream());
diff --git a/WebCore/html/HTMLScriptRunner.h b/WebCore/html/HTMLScriptRunner.h
index 981d433..ead9289 100644
--- a/WebCore/html/HTMLScriptRunner.h
+++ b/WebCore/html/HTMLScriptRunner.h
@@ -42,9 +42,14 @@ class ScriptSourceCode;
class HTMLScriptRunner : public Noncopyable {
public:
- HTMLScriptRunner(Document*, HTMLScriptRunnerHost*);
+ static PassOwnPtr<HTMLScriptRunner> create(Document* document, HTMLScriptRunnerHost* host)
+ {
+ return adoptPtr(new HTMLScriptRunner(document, host));
+ }
~HTMLScriptRunner();
+ void detach();
+
// Processes the passed in script and any pending scripts if possible.
bool execute(PassRefPtr<Element> scriptToProcess, int scriptStartLine);
@@ -55,6 +60,8 @@ public:
bool isExecutingScript() const { return !!m_scriptNestingLevel; }
private:
+ HTMLScriptRunner(Document*, HTMLScriptRunnerHost*);
+
Frame* frame() const;
void executeParsingBlockingScript();
diff --git a/WebCore/html/HTMLSelectElement.cpp b/WebCore/html/HTMLSelectElement.cpp
index 6ddcc2d..b1b6d23 100644
--- a/WebCore/html/HTMLSelectElement.cpp
+++ b/WebCore/html/HTMLSelectElement.cpp
@@ -58,13 +58,6 @@ PassRefPtr<HTMLSelectElement> HTMLSelectElement::create(const QualifiedName& tag
return adoptRef(new HTMLSelectElement(tagName, document, form));
}
-bool HTMLSelectElement::checkDTD(const Node* newChild)
-{
- // Make sure to keep <optgroup> in sync with this.
- return newChild->isTextNode() || newChild->hasTagName(optionTag) || newChild->hasTagName(optgroupTag) || newChild->hasTagName(hrTag) ||
- newChild->hasTagName(scriptTag);
-}
-
void HTMLSelectElement::recalcStyle(StyleChange change)
{
HTMLFormControlElementWithState::recalcStyle(change);
diff --git a/WebCore/html/HTMLSelectElement.h b/WebCore/html/HTMLSelectElement.h
index 59c943a..79b0789 100644
--- a/WebCore/html/HTMLSelectElement.h
+++ b/WebCore/html/HTMLSelectElement.h
@@ -86,9 +86,6 @@ protected:
HTMLSelectElement(const QualifiedName&, Document*, HTMLFormElement*);
private:
- virtual int tagPriority() const { return 6; }
- virtual bool checkDTD(const Node* newChild);
-
virtual const AtomicString& formControlType() const;
virtual bool isKeyboardFocusable(KeyboardEvent*) const;
diff --git a/WebCore/html/HTMLSourceElement.h b/WebCore/html/HTMLSourceElement.h
index 7d49a3e..8aa1d06 100644
--- a/WebCore/html/HTMLSourceElement.h
+++ b/WebCore/html/HTMLSourceElement.h
@@ -48,9 +48,6 @@ public:
private:
HTMLSourceElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
- virtual int tagPriority() const { return 0; }
virtual void insertedIntoTree(bool);
virtual bool isURLAttribute(Attribute*) const;
diff --git a/WebCore/html/HTMLStyleElement.h b/WebCore/html/HTMLStyleElement.h
index 07b5bd9..b4013b8 100644
--- a/WebCore/html/HTMLStyleElement.h
+++ b/WebCore/html/HTMLStyleElement.h
@@ -41,10 +41,6 @@ public:
private:
HTMLStyleElement(const QualifiedName&, Document*, bool createdByParser);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 1; }
- virtual bool checkDTD(const Node* newChild) { return newChild->isTextNode(); }
-
// overload from HTMLElement
virtual void parseMappedAttribute(Attribute*);
virtual void insertedIntoDocument();
diff --git a/WebCore/html/HTMLTableCaptionElement.h b/WebCore/html/HTMLTableCaptionElement.h
index d19c7ce..a2dd2fa 100644
--- a/WebCore/html/HTMLTableCaptionElement.h
+++ b/WebCore/html/HTMLTableCaptionElement.h
@@ -37,9 +37,6 @@ public:
private:
HTMLTableCaptionElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 5; }
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
};
diff --git a/WebCore/html/HTMLTableCellElement.h b/WebCore/html/HTMLTableCellElement.h
index a70bdcd..0c97413 100644
--- a/WebCore/html/HTMLTableCellElement.h
+++ b/WebCore/html/HTMLTableCellElement.h
@@ -56,9 +56,6 @@ public:
private:
HTMLTableCellElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
- virtual int tagPriority() const { return 6; }
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
diff --git a/WebCore/html/HTMLTableColElement.cpp b/WebCore/html/HTMLTableColElement.cpp
index 6c2f1fe..20b0f36 100644
--- a/WebCore/html/HTMLTableColElement.cpp
+++ b/WebCore/html/HTMLTableColElement.cpp
@@ -47,26 +47,6 @@ PassRefPtr<HTMLTableColElement> HTMLTableColElement::create(const QualifiedName&
return adoptRef(new HTMLTableColElement(tagName, document));
}
-HTMLTagStatus HTMLTableColElement::endTagRequirement() const
-{
- return hasLocalName(colTag) ? TagStatusForbidden : TagStatusOptional;
-}
-
-int HTMLTableColElement::tagPriority() const
-{
- return hasLocalName(colTag) ? 0 : 1;
-}
-
-bool HTMLTableColElement::checkDTD(const Node* newChild)
-{
- if (hasLocalName(colTag))
- return false;
-
- if (newChild->isTextNode())
- return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
- return newChild->hasTagName(colTag);
-}
-
bool HTMLTableColElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
{
if (attrName == widthAttr) {
diff --git a/WebCore/html/HTMLTableColElement.h b/WebCore/html/HTMLTableColElement.h
index 4a219c1..c7517d1 100644
--- a/WebCore/html/HTMLTableColElement.h
+++ b/WebCore/html/HTMLTableColElement.h
@@ -42,9 +42,6 @@ public:
private:
HTMLTableColElement(const QualifiedName& tagName, Document*);
- virtual HTMLTagStatus endTagRequirement() const;
- virtual int tagPriority() const;
- virtual bool checkDTD(const Node*);
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
virtual bool canHaveAdditionalAttributeStyleDecls() const { return true; }
diff --git a/WebCore/html/HTMLTableElement.cpp b/WebCore/html/HTMLTableElement.cpp
index 56cb32a..ef29bf6 100644
--- a/WebCore/html/HTMLTableElement.cpp
+++ b/WebCore/html/HTMLTableElement.cpp
@@ -63,17 +63,6 @@ PassRefPtr<HTMLTableElement> HTMLTableElement::create(const QualifiedName& tagNa
return adoptRef(new HTMLTableElement(tagName, document));
}
-bool HTMLTableElement::checkDTD(const Node* newChild)
-{
- if (newChild->isTextNode())
- return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
- return newChild->hasTagName(captionTag) ||
- newChild->hasTagName(colTag) || newChild->hasTagName(colgroupTag) ||
- newChild->hasTagName(theadTag) || newChild->hasTagName(tfootTag) ||
- newChild->hasTagName(tbodyTag) || newChild->hasTagName(formTag) ||
- newChild->hasTagName(scriptTag);
-}
-
HTMLTableCaptionElement* HTMLTableElement::caption() const
{
for (Node* child = firstChild(); child; child = child->nextSibling()) {
@@ -251,20 +240,6 @@ void HTMLTableElement::deleteRow(int index, ExceptionCode& ec)
row->remove(ec);
}
-ContainerNode* HTMLTableElement::legacyParserAddChild(PassRefPtr<Node> child)
-{
- if (child->hasTagName(formTag)) {
- // First add the child.
- HTMLElement::legacyParserAddChild(child);
-
- // Now simply return ourselves as the container to insert into.
- // This has the effect of demoting the form to a leaf and moving it safely out of the way.
- return this;
- }
-
- return HTMLElement::legacyParserAddChild(child.get());
-}
-
bool HTMLTableElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
{
if (attrName == backgroundAttr) {
diff --git a/WebCore/html/HTMLTableElement.h b/WebCore/html/HTMLTableElement.h
index c48fee5..da3dc30 100644
--- a/WebCore/html/HTMLTableElement.h
+++ b/WebCore/html/HTMLTableElement.h
@@ -63,8 +63,6 @@ public:
String rules() const;
String summary() const;
- virtual ContainerNode* legacyParserAddChild(PassRefPtr<Node>);
-
virtual void attach();
void addSharedCellDecls(Vector<CSSMutableStyleDeclaration*>&);
@@ -73,10 +71,6 @@ public:
private:
HTMLTableElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 9; }
- virtual bool checkDTD(const Node*);
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
virtual bool isURLAttribute(Attribute*) const;
diff --git a/WebCore/html/HTMLTableRowElement.cpp b/WebCore/html/HTMLTableRowElement.cpp
index 0bafb12..e9b5cec 100644
--- a/WebCore/html/HTMLTableRowElement.cpp
+++ b/WebCore/html/HTMLTableRowElement.cpp
@@ -54,28 +54,6 @@ PassRefPtr<HTMLTableRowElement> HTMLTableRowElement::create(const QualifiedName&
return adoptRef(new HTMLTableRowElement(tagName, document));
}
-bool HTMLTableRowElement::checkDTD(const Node* newChild)
-{
- if (newChild->isTextNode())
- return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
- return newChild->hasTagName(tdTag) || newChild->hasTagName(thTag) ||
- newChild->hasTagName(formTag) || newChild->hasTagName(scriptTag);
-}
-
-ContainerNode* HTMLTableRowElement::legacyParserAddChild(PassRefPtr<Node> child)
-{
- if (child->hasTagName(formTag)) {
- // First add the child.
- HTMLTablePartElement::legacyParserAddChild(child);
-
- // Now simply return ourselves as the container to insert into.
- // This has the effect of demoting the form to a leaf and moving it safely out of the way.
- return this;
- }
-
- return HTMLTablePartElement::legacyParserAddChild(child);
-}
-
int HTMLTableRowElement::rowIndex() const
{
Node *table = parentNode();
diff --git a/WebCore/html/HTMLTableRowElement.h b/WebCore/html/HTMLTableRowElement.h
index 825d763..c433677 100644
--- a/WebCore/html/HTMLTableRowElement.h
+++ b/WebCore/html/HTMLTableRowElement.h
@@ -35,8 +35,6 @@ public:
static PassRefPtr<HTMLTableRowElement> create(Document*);
static PassRefPtr<HTMLTableRowElement> create(const QualifiedName&, Document*);
- virtual ContainerNode* legacyParserAddChild(PassRefPtr<Node>);
-
int rowIndex() const;
void setRowIndex(int);
@@ -51,10 +49,6 @@ public:
private:
HTMLTableRowElement(const QualifiedName&, Document*);
-
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
- virtual int tagPriority() const { return 7; }
- virtual bool checkDTD(const Node*);
};
} // namespace
diff --git a/WebCore/html/HTMLTableSectionElement.cpp b/WebCore/html/HTMLTableSectionElement.cpp
index 93bfef2..982e035 100644
--- a/WebCore/html/HTMLTableSectionElement.cpp
+++ b/WebCore/html/HTMLTableSectionElement.cpp
@@ -47,28 +47,6 @@ PassRefPtr<HTMLTableSectionElement> HTMLTableSectionElement::create(const Qualif
return adoptRef(new HTMLTableSectionElement(tagName, document));
}
-bool HTMLTableSectionElement::checkDTD(const Node* newChild)
-{
- if (newChild->isTextNode())
- return static_cast<const Text*>(newChild)->containsOnlyWhitespace();
- return newChild->hasTagName(trTag) || newChild->hasTagName(formTag) ||
- newChild->hasTagName(scriptTag);
-}
-
-ContainerNode* HTMLTableSectionElement::legacyParserAddChild(PassRefPtr<Node> child)
-{
- if (child->hasTagName(formTag)) {
- // First add the child.
- HTMLTablePartElement::legacyParserAddChild(child);
-
- // Now simply return ourselves as the container to insert into.
- // This has the effect of demoting the form to a leaf and moving it safely out of the way.
- return this;
- }
-
- return HTMLTablePartElement::legacyParserAddChild(child);
-}
-
// used by table row groups to share style decls created by the enclosing table.
void HTMLTableSectionElement::additionalAttributeStyleDecls(Vector<CSSMutableStyleDeclaration*>& results)
{
diff --git a/WebCore/html/HTMLTableSectionElement.h b/WebCore/html/HTMLTableSectionElement.h
index 3e356da..a84cbde 100644
--- a/WebCore/html/HTMLTableSectionElement.h
+++ b/WebCore/html/HTMLTableSectionElement.h
@@ -34,8 +34,6 @@ class HTMLTableSectionElement : public HTMLTablePartElement {
public:
static PassRefPtr<HTMLTableSectionElement> create(const QualifiedName&, Document*);
- virtual ContainerNode* legacyParserAddChild(PassRefPtr<Node>);
-
PassRefPtr<HTMLElement> insertRow(int index, ExceptionCode&);
void deleteRow(int index, ExceptionCode&);
@@ -58,9 +56,6 @@ public:
private:
HTMLTableSectionElement(const QualifiedName& tagName, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; }
- virtual int tagPriority() const { return 8; }
- virtual bool checkDTD(const Node*);
virtual bool canHaveAdditionalAttributeStyleDecls() const { return true; }
virtual void additionalAttributeStyleDecls(Vector<CSSMutableStyleDeclaration*>&);
};
diff --git a/WebCore/html/HTMLTextAreaElement.h b/WebCore/html/HTMLTextAreaElement.h
index 43fe493..bb0039e 100644
--- a/WebCore/html/HTMLTextAreaElement.h
+++ b/WebCore/html/HTMLTextAreaElement.h
@@ -76,8 +76,6 @@ private:
virtual void defaultEventHandler(Event*);
- virtual bool checkDTD(const Node* newChild) { return newChild->isTextNode(); }
-
virtual bool isEnumeratable() const { return true; }
virtual const AtomicString& formControlType() const;
diff --git a/WebCore/html/HTMLTitleElement.h b/WebCore/html/HTMLTitleElement.h
index bcd4283..8b90f56 100644
--- a/WebCore/html/HTMLTitleElement.h
+++ b/WebCore/html/HTMLTitleElement.h
@@ -36,8 +36,6 @@ public:
private:
HTMLTitleElement(const QualifiedName&, Document*);
- virtual bool checkDTD(const Node* newChild) { return newChild->isTextNode(); }
-
virtual void insertedIntoDocument();
virtual void removedFromDocument();
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
diff --git a/WebCore/html/HTMLToken.h b/WebCore/html/HTMLToken.h
index e42a829..42cddb8 100644
--- a/WebCore/html/HTMLToken.h
+++ b/WebCore/html/HTMLToken.h
@@ -128,7 +128,7 @@ public:
{
ASSERT(m_type == Uninitialized);
m_type = DOCTYPE;
- m_doctypeData.set(new DoctypeData());
+ m_doctypeData = adoptPtr(new DoctypeData());
}
void beginDOCTYPE(UChar character)
diff --git a/WebCore/html/HTMLTokenizer.h b/WebCore/html/HTMLTokenizer.h
index 6fb3053..2b93e15 100644
--- a/WebCore/html/HTMLTokenizer.h
+++ b/WebCore/html/HTMLTokenizer.h
@@ -29,6 +29,7 @@
#include "SegmentedString.h"
#include <wtf/Noncopyable.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/AtomicString.h>
@@ -115,7 +116,7 @@ public:
CDATASectionState,
};
- HTMLTokenizer();
+ static PassOwnPtr<HTMLTokenizer> create() { return adoptPtr(new HTMLTokenizer); }
~HTMLTokenizer();
void reset();
@@ -231,6 +232,8 @@ private:
bool m_skipNextNewLine;
};
+ HTMLTokenizer();
+
inline bool processEntity(SegmentedString&);
inline void parseError();
diff --git a/WebCore/html/HTMLTreeBuilder.cpp b/WebCore/html/HTMLTreeBuilder.cpp
index fd0b62e..24eb62f 100644
--- a/WebCore/html/HTMLTreeBuilder.cpp
+++ b/WebCore/html/HTMLTreeBuilder.cpp
@@ -39,7 +39,6 @@
#include "HTMLScriptElement.h"
#include "HTMLToken.h"
#include "HTMLTokenizer.h"
-#include "LegacyHTMLTreeBuilder.h"
#include "LocalizedStrings.h"
#include "MathMLNames.h"
#include "NotImplemented.h"
@@ -50,6 +49,9 @@
#include "XLinkNames.h"
#include "XMLNSNames.h"
#include "XMLNames.h"
+// FIXME: Remove this include once we find a home for the free functions that
+// are using it.
+#include <wtf/dtoa.h>
#include <wtf/UnusedParam.h>
namespace WebCore {
@@ -98,11 +100,6 @@ inline bool isAllWhitespaceOrReplacementCharacters(const String& string)
return isAllSpecialCharacters<isTreeBuilderWhitepaceOrReplacementCharacter>(string);
}
-bool shouldUseLegacyTreeBuilder(Document* document)
-{
- return !document->settings() || !document->settings()->html5TreeBuilderEnabled();
-}
-
bool isNumberedHeaderTag(const AtomicString& tagName)
{
return tagName == h1Tag
@@ -133,8 +130,12 @@ bool isTableBodyContextTag(const AtomicString& tagName)
}
// http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#special
-bool isSpecialTag(const AtomicString& tagName)
+bool isSpecialNode(Node* node)
{
+ if (node->namespaceURI() != xhtmlNamespaceURI)
+ return false;
+ // FIXME: This list is out of sync with the spec.
+ const AtomicString& tagName = node->localName();
return tagName == addressTag
|| tagName == articleTag
|| tagName == asideTag
@@ -167,6 +168,7 @@ bool isSpecialTag(const AtomicString& tagName)
|| tagName == headerTag
|| tagName == hgroupTag
|| tagName == hrTag
+ || tagName == htmlTag
|| tagName == iframeTag
|| tagName == imgTag
|| tagName == inputTag
@@ -199,7 +201,6 @@ bool isSpecialTag(const AtomicString& tagName)
}
// http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#scoping
-// Same as isScopingTag in LegacyHTMLTreeBuilder.cpp
// and isScopeMarker in HTMLElementStack.cpp
bool isScopingTag(const AtomicString& tagName)
{
@@ -241,22 +242,6 @@ bool isFormattingTag(const AtomicString& tagName)
return tagName == aTag || isNonAnchorFormattingTag(tagName);
}
-// http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#phrasing
-bool isPhrasingTag(const AtomicString& tagName)
-{
- return !isSpecialTag(tagName) && !isScopingTag(tagName) && !isFormattingTag(tagName);
-}
-
-bool isNotFormattingAndNotPhrasing(const Element* element)
-{
- // The spec often says "node is not in the formatting category, and is not
- // in the phrasing category". !phrasing && !formatting == scoping || special
- // scoping || special is easier to compute.
- // FIXME: localName() is wrong for non-html content.
- const AtomicString& tagName = element->localName();
- return isScopingTag(tagName) || isSpecialTag(tagName);
-}
-
HTMLFormElement* closestFormAncestor(Element* element)
{
while (element) {
@@ -388,8 +373,8 @@ HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, HTMLDocument* documen
, m_originalInsertionMode(InitialMode)
, m_secondaryInsertionMode(InitialMode)
, m_tokenizer(tokenizer)
- , m_lastScriptElementStartLine(uninitializedLineNumberValue)
, m_scriptToProcessStartLine(uninitializedLineNumberValue)
+ , m_lastScriptElementStartLine(uninitializedLineNumberValue)
{
}
@@ -397,7 +382,7 @@ HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, HTMLDocument* documen
// minimize code duplication between these constructors.
HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission)
: m_framesetOk(true)
- , m_fragmentContext(fragment, contextElement, scriptingPermission, shouldUseLegacyTreeBuilder(fragment->document()))
+ , m_fragmentContext(fragment, contextElement, scriptingPermission)
, m_document(m_fragmentContext.document())
, m_tree(m_document, scriptingPermission, true)
, m_reportErrors(false) // FIXME: Why not report errors in fragments?
@@ -406,12 +391,9 @@ HTMLTreeBuilder::HTMLTreeBuilder(HTMLTokenizer* tokenizer, DocumentFragment* fra
, m_originalInsertionMode(InitialMode)
, m_secondaryInsertionMode(InitialMode)
, m_tokenizer(tokenizer)
- , m_legacyTreeBuilder(shouldUseLegacyTreeBuilder(fragment->document()) ? new LegacyHTMLTreeBuilder(fragment, scriptingPermission) : 0)
- , m_lastScriptElementStartLine(uninitializedLineNumberValue)
, m_scriptToProcessStartLine(uninitializedLineNumberValue)
+ , m_lastScriptElementStartLine(uninitializedLineNumberValue)
{
- if (shouldUseLegacyTreeBuilder(fragment->document()))
- return;
if (contextElement) {
// Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm:
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#fragment-case
@@ -426,19 +408,27 @@ HTMLTreeBuilder::~HTMLTreeBuilder()
{
}
+void HTMLTreeBuilder::detach()
+{
+ // This call makes little sense in fragment mode, but for consistency
+ // DocumentParser expects detach() to always be called before it's destroyed.
+ m_document = 0;
+ // HTMLConstructionSite might be on the callstack when detach() is called
+ // otherwise we'd just call m_tree.clear() here instead.
+ m_tree.detach();
+}
+
HTMLTreeBuilder::FragmentParsingContext::FragmentParsingContext()
: m_fragment(0)
, m_contextElement(0)
- , m_usingLegacyTreeBuilder(false)
, m_scriptingPermission(FragmentScriptingAllowed)
{
}
-HTMLTreeBuilder::FragmentParsingContext::FragmentParsingContext(DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission, bool legacyMode)
- : m_dummyDocumentForFragmentParsing(legacyMode ? 0 : HTMLDocument::create(0, KURL()))
+HTMLTreeBuilder::FragmentParsingContext::FragmentParsingContext(DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission)
+ : m_dummyDocumentForFragmentParsing(HTMLDocument::create(0, KURL()))
, m_fragment(fragment)
, m_contextElement(contextElement)
- , m_usingLegacyTreeBuilder(legacyMode)
, m_scriptingPermission(scriptingPermission)
{
}
@@ -446,8 +436,6 @@ HTMLTreeBuilder::FragmentParsingContext::FragmentParsingContext(DocumentFragment
Document* HTMLTreeBuilder::FragmentParsingContext::document() const
{
ASSERT(m_fragment);
- if (m_usingLegacyTreeBuilder)
- return m_fragment->document();
return m_dummyDocumentForFragmentParsing.get();
}
@@ -472,39 +460,6 @@ HTMLTreeBuilder::FragmentParsingContext::~FragmentParsingContext()
{
}
-static void convertToOldStyle(AtomicHTMLToken& token, Token& oldStyleToken)
-{
- switch (token.type()) {
- case HTMLToken::Uninitialized:
- case HTMLToken::DOCTYPE:
- ASSERT_NOT_REACHED();
- break;
- case HTMLToken::EndOfFile:
- ASSERT_NOT_REACHED();
- notImplemented();
- break;
- case HTMLToken::StartTag:
- case HTMLToken::EndTag: {
- oldStyleToken.beginTag = (token.type() == HTMLToken::StartTag);
- // The LegacyHTMLTreeBuilder seems to work better if we lie here and
- // say that tags are never self closing. As a wise man once said:
- // "You can't handle the truth!"
- oldStyleToken.selfClosingTag = false;
- oldStyleToken.tagName = token.name();
- oldStyleToken.attrs = token.takeAtributes();
- break;
- }
- case HTMLToken::Comment:
- oldStyleToken.tagName = commentAtom;
- oldStyleToken.text = token.comment().impl();
- break;
- case HTMLToken::Character:
- oldStyleToken.tagName = textAtom;
- oldStyleToken.text = StringImpl::create(token.characters().data(), token.characters().size());
- break;
- }
-}
-
PassRefPtr<Element> HTMLTreeBuilder::takeScriptToProcess(int& scriptStartLine)
{
// Unpause ourselves, callers may pause us again when processing the script.
@@ -536,74 +491,8 @@ HTMLTokenizer::State HTMLTreeBuilder::adjustedLexerState(HTMLTokenizer::State st
return state;
}
-void HTMLTreeBuilder::passTokenToLegacyParser(HTMLToken& token)
-{
- if (token.type() == HTMLToken::DOCTYPE) {
- DoctypeToken doctypeToken;
- doctypeToken.m_name.append(token.name().data(), token.name().size());
- doctypeToken.m_publicID = token.publicIdentifier();
- doctypeToken.m_systemID = token.systemIdentifier();
- doctypeToken.m_forceQuirks = token.forceQuirks();
-
- m_legacyTreeBuilder->parseDoctypeToken(&doctypeToken);
- return;
- }
-
- if (token.type() == HTMLToken::EndOfFile)
- return;
-
- // For now, we translate into an old-style token for testing.
- Token oldStyleToken;
- AtomicHTMLToken atomicToken(token);
- convertToOldStyle(atomicToken, oldStyleToken);
-
- RefPtr<Node> result = m_legacyTreeBuilder->parseToken(&oldStyleToken);
- if (token.type() == HTMLToken::StartTag) {
- // This work is supposed to be done by the parser, but
- // when using the old parser for we have to do this manually.
- if (oldStyleToken.tagName == scriptTag) {
- m_tokenizer->setState(HTMLTokenizer::ScriptDataState);
- m_lastScriptElement = static_pointer_cast<Element>(result);
- m_lastScriptElementStartLine = m_tokenizer->lineNumber();
- } else if (oldStyleToken.tagName == preTag || oldStyleToken.tagName == listingTag)
- m_tokenizer->setSkipLeadingNewLineForListing(true);
- else
- m_tokenizer->setState(adjustedLexerState(m_tokenizer->state(), oldStyleToken.tagName, m_document->frame()));
- } else if (token.type() == HTMLToken::EndTag) {
- if (oldStyleToken.tagName == scriptTag) {
- if (m_lastScriptElement) {
- ASSERT(m_lastScriptElementStartLine != uninitializedLineNumberValue);
- if (m_fragmentContext.scriptingPermission() == FragmentScriptingNotAllowed) {
- // FIXME: This is a horrible hack for platform/Pasteboard.
- // Clear the <script> tag when using the Parser to create
- // a DocumentFragment for pasting so that javascript content
- // does not show up in pasted HTML.
- m_lastScriptElement->removeChildren();
- } else if (insertionMode() != AfterFramesetMode) {
- ASSERT(!m_scriptToProcess); // Caller never called takeScriptToProcess!
- ASSERT(m_scriptToProcessStartLine == uninitializedLineNumberValue); // Caller never called takeScriptToProcess!
- // Pause ourselves so that parsing stops until the script can be processed by the caller.
- m_isPaused = true;
- m_scriptToProcess = m_lastScriptElement.get();
- // Lexer line numbers are 0-based, ScriptSourceCode expects 1-based lines,
- // so we convert here before passing the line number off to HTMLScriptRunner.
- m_scriptToProcessStartLine = m_lastScriptElementStartLine + 1;
- }
- m_lastScriptElement = 0;
- m_lastScriptElementStartLine = uninitializedLineNumberValue;
- }
- } else if (oldStyleToken.tagName == framesetTag)
- setInsertionMode(AfterFramesetMode);
- }
-}
-
void HTMLTreeBuilder::constructTreeFromToken(HTMLToken& rawToken)
{
- if (m_legacyTreeBuilder) {
- passTokenToLegacyParser(rawToken);
- return;
- }
-
AtomicHTMLToken token(rawToken);
processToken(token);
@@ -754,7 +643,7 @@ void HTMLTreeBuilder::processCloseWhenNestedTag(AtomicHTMLToken& token)
processFakeEndTag(node->tagQName());
break;
}
- if (isNotFormattingAndNotPhrasing(node) && !node->hasTagName(addressTag) && !node->hasTagName(divTag) && !node->hasTagName(pTag))
+ if (isSpecialNode(node) && !node->hasTagName(addressTag) && !node->hasTagName(divTag) && !node->hasTagName(pTag))
break;
nodeRecord = nodeRecord->next();
}
@@ -1034,7 +923,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken& token)
return;
}
if (token.name() == tableTag) {
- if (m_document->parseMode() != Document::Compat && m_tree.openElements()->inScope(pTag))
+ if (m_document->parseMode() != Document::Compat && m_tree.openElements()->inButtonScope(pTag))
processFakeEndTag(pTag);
m_tree.insertHTMLElement(token);
m_framesetOk = false;
@@ -1715,7 +1604,7 @@ void HTMLTreeBuilder::processAnyOtherEndTagForInBody(AtomicHTMLToken& token)
m_tree.openElements()->popUntilPopped(node);
return;
}
- if (isNotFormattingAndNotPhrasing(node)) {
+ if (isSpecialNode(node)) {
parseError(token);
return;
}
@@ -1731,7 +1620,7 @@ HTMLElementStack::ElementRecord* HTMLTreeBuilder::furthestBlockForFormattingElem
for (; record; record = record->next()) {
if (record->element() == formattingElement)
return furthestBlock;
- if (isNotFormattingAndNotPhrasing(record->element()))
+ if (isSpecialNode(record->element()))
furthestBlock = record;
}
ASSERT_NOT_REACHED();
@@ -1745,9 +1634,10 @@ void HTMLTreeBuilder::reparentChildren(Element* oldParent, Element* newParent)
Node* child = oldParent->firstChild();
while (child) {
Node* nextChild = child->nextSibling();
- ExceptionCode ec;
- newParent->appendChild(child, ec);
- ASSERT(!ec);
+ oldParent->parserRemoveChild(child);
+ newParent->parserAddChild(child);
+ if (newParent->attached() && !child->attached())
+ child->attach();
child = nextChild;
}
}
@@ -1818,15 +1708,18 @@ void HTMLTreeBuilder::callTheAdoptionAgency(AtomicHTMLToken& token)
if (lastNode == furthestBlock)
bookmark.moveToAfter(nodeEntry);
// 6.6
- // Use appendChild instead of parserAddChild to handle possible reparenting.
- ExceptionCode ec;
- node->element()->appendChild(lastNode->element(), ec, true);
- ASSERT(!ec);
+ if (Element* parent = lastNode->element()->parentElement())
+ parent->parserRemoveChild(lastNode->element());
+ node->element()->parserAddChild(lastNode->element());
+ if (lastNode->element()->parentElement()->attached() && !lastNode->element()->attached())
+ lastNode->element()->lazyAttach();
// 6.7
lastNode = node;
}
// 7
const AtomicString& commonAncestorTag = commonAncestor->localName();
+ if (Element* parent = lastNode->element()->parentElement())
+ parent->parserRemoveChild(lastNode->element());
// FIXME: If this moves to HTMLConstructionSite, this check should use
// causesFosterParenting(tagName) instead.
if (commonAncestorTag == tableTag
@@ -1834,9 +1727,9 @@ void HTMLTreeBuilder::callTheAdoptionAgency(AtomicHTMLToken& token)
|| isTableBodyContextTag(commonAncestorTag))
m_tree.fosterParent(lastNode->element());
else {
- ExceptionCode ec;
- commonAncestor->appendChild(lastNode->element(), ec, true);
- ASSERT(!ec);
+ commonAncestor->parserAddChild(lastNode->element());
+ if (lastNode->element()->parentElement()->attached() && !lastNode->element()->attached())
+ lastNode->element()->lazyAttach();
}
// 8
RefPtr<Element> newElement = m_tree.createHTMLElementFromElementRecord(formattingElementRecord);
@@ -2394,6 +2287,8 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
m_scriptToProcess = m_tree.currentElement();
m_scriptToProcessStartLine = m_lastScriptElementStartLine + 1;
m_tree.openElements()->pop();
+ if (isParsingFragment() && m_fragmentContext.scriptingPermission() == FragmentScriptingNotAllowed)
+ m_scriptToProcess->removeAllChildren();
setInsertionMode(m_originalInsertionMode);
return;
}
@@ -2479,30 +2374,19 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
if (m_tree.currentElement()->namespaceURI() != xhtmlNamespaceURI) {
// FIXME: This code just wants an Element* iterator, instead of an ElementRecord*
HTMLElementStack::ElementRecord* nodeRecord = m_tree.openElements()->topRecord();
- if (!nodeRecord->element()->hasLocalName(token.name())) {
+ if (!nodeRecord->element()->hasLocalName(token.name()))
parseError(token);
- // FIXME: This return is not in the spec but it needed for now
- // to prevent walking off the bottom of the stack.
- // http://www.w3.org/Bugs/Public/show_bug.cgi?id=10118
- if (!m_tree.openElements()->contains(token.name()))
- return;
- }
while (1) {
if (nodeRecord->element()->hasLocalName(token.name())) {
m_tree.openElements()->popUntilPopped(nodeRecord->element());
- return;
+ break;
}
nodeRecord = nodeRecord->next();
- if (nodeRecord->element()->namespaceURI() == xhtmlNamespaceURI) {
- processUsingSecondaryInsertionModeAndAdjustInsertionMode(token);
- // FIXME: This is a hack around a spec bug and is likely wrong.
- // http://www.w3.org/Bugs/Public/show_bug.cgi?id=9581
- if (nodeRecord != m_tree.openElements()->topRecord())
- return;
- }
+ if (nodeRecord->element()->namespaceURI() == xhtmlNamespaceURI)
+ break;
}
- return;
}
+ // Any other end tag (also the last two steps of "An end tag, if the current node is not an element in the HTML namespace."
processUsingSecondaryInsertionModeAndAdjustInsertionMode(token);
break;
}
@@ -2935,19 +2819,13 @@ void HTMLTreeBuilder::processScriptStartTag(AtomicHTMLToken& token)
void HTMLTreeBuilder::finished()
{
- // We should call m_document->finishedParsing() here, except
- // m_legacyTreeBuilder->finished() does it for us.
- if (m_legacyTreeBuilder) {
- m_legacyTreeBuilder->finished();
- return;
- }
-
+ ASSERT(m_document);
if (isParsingFragment()) {
m_fragmentContext.finished();
return;
}
- // Warning, this may delete the parser, so don't try to do anything else after this.
+ // Warning, this may detach the parser. Do not do anything else after this.
m_document->finishedParsing();
}
@@ -2967,4 +2845,40 @@ bool HTMLTreeBuilder::pluginsEnabled(Frame* frame)
return frame->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin);
}
+// FIXME: Move this function to a more appropriate place.
+String serializeForNumberType(double number)
+{
+ // According to HTML5, "the best representation of the number n as a floating
+ // point number" is a string produced by applying ToString() to n.
+ NumberToStringBuffer buffer;
+ return String(buffer, numberToString(number, buffer));
+ }
+
+// FIXME: Move this function to a more appropriate place.
+bool parseToDoubleForNumberType(const String& src, double* out)
+{
+ // See HTML5 2.4.4.3 `Real numbers.'
+
+ if (src.isEmpty())
+ return false;
+ // String::toDouble() accepts leading + \t \n \v \f \r and SPACE, which are invalid in HTML5.
+ // So, check the first character.
+ if (src[0] != '-' && (src[0] < '0' || src[0] > '9'))
+ return false;
+
+ bool valid = false;
+ double value = src.toDouble(&valid);
+ if (!valid)
+ return false;
+ // NaN and Infinity are not valid numbers according to the standard.
+ if (!isfinite(value))
+ return false;
+ // -0 -> 0
+ if (!value)
+ value = 0;
+ if (out)
+ *out = value;
+ return true;
+}
+
}
diff --git a/WebCore/html/HTMLTreeBuilder.h b/WebCore/html/HTMLTreeBuilder.h
index 24cb542..c30e6b8 100644
--- a/WebCore/html/HTMLTreeBuilder.h
+++ b/WebCore/html/HTMLTreeBuilder.h
@@ -47,16 +47,22 @@ class DocumentFragment;
class Frame;
class HTMLToken;
class HTMLDocument;
-class LegacyHTMLTreeBuilder;
class Node;
class HTMLTreeBuilder : public Noncopyable {
public:
- // FIXME: Replace constructors with create() functions returning PassOwnPtrs
- HTMLTreeBuilder(HTMLTokenizer*, HTMLDocument*, bool reportErrors);
- HTMLTreeBuilder(HTMLTokenizer*, DocumentFragment*, Element* contextElement, FragmentScriptingPermission);
+ static PassOwnPtr<HTMLTreeBuilder> create(HTMLTokenizer* tokenizer, HTMLDocument* document, bool reportErrors)
+ {
+ return adoptPtr(new HTMLTreeBuilder(tokenizer, document, reportErrors));
+ }
+ static PassOwnPtr<HTMLTreeBuilder> create(HTMLTokenizer* tokenizer, DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission)
+ {
+ return adoptPtr(new HTMLTreeBuilder(tokenizer, fragment, contextElement, scriptingPermission));
+ }
~HTMLTreeBuilder();
+ void detach();
+
void setPaused(bool paused) { m_isPaused = paused; }
bool isPaused() const { return m_isPaused; }
@@ -70,10 +76,6 @@ public:
static HTMLTokenizer::State adjustedLexerState(HTMLTokenizer::State, const AtomicString& tagName, Frame*);
- // FIXME: This is a dirty, rotten hack to keep HTMLFormControlElement happy
- // until we stop using the legacy parser. DO NOT CALL THIS METHOD.
- LegacyHTMLTreeBuilder* legacyTreeBuilder() const { return m_legacyTreeBuilder.get(); }
-
static bool scriptEnabled(Frame*);
static bool pluginsEnabled(Frame*);
@@ -108,9 +110,10 @@ private:
AfterAfterFramesetMode,
};
- bool isParsingFragment() const { return !!m_fragmentContext.fragment(); }
+ HTMLTreeBuilder(HTMLTokenizer*, HTMLDocument*, bool reportErrors);
+ HTMLTreeBuilder(HTMLTokenizer*, DocumentFragment*, Element* contextElement, FragmentScriptingPermission);
- void passTokenToLegacyParser(HTMLToken&);
+ bool isParsingFragment() const { return !!m_fragmentContext.fragment(); }
void processToken(AtomicHTMLToken&);
@@ -200,12 +203,12 @@ private:
class FragmentParsingContext : public Noncopyable {
public:
FragmentParsingContext();
- FragmentParsingContext(DocumentFragment*, Element* contextElement, FragmentScriptingPermission, bool usingLegacyTreeBuilder);
+ FragmentParsingContext(DocumentFragment*, Element* contextElement, FragmentScriptingPermission);
~FragmentParsingContext();
Document* document() const;
DocumentFragment* fragment() const { return m_fragment; }
- Element* contextElement() const { ASSERT(m_fragment); ASSERT(!m_usingLegacyTreeBuilder); return m_contextElement; }
+ Element* contextElement() const { ASSERT(m_fragment); return m_contextElement; }
FragmentScriptingPermission scriptingPermission() const { ASSERT(m_fragment); return m_scriptingPermission; }
void finished();
@@ -214,7 +217,6 @@ private:
RefPtr<Document> m_dummyDocumentForFragmentParsing;
DocumentFragment* m_fragment;
Element* m_contextElement;
- bool m_usingLegacyTreeBuilder;
// FragmentScriptingNotAllowed causes the Parser to remove children
// from <script> tags (so javascript doesn't show up in pastes).
@@ -244,18 +246,27 @@ private:
// from within parser actions.
HTMLTokenizer* m_tokenizer;
- // We're re-using logic from the old LegacyHTMLTreeBuilder while this class is being written.
- OwnPtr<LegacyHTMLTreeBuilder> m_legacyTreeBuilder;
-
- // These members are intentionally duplicated as the first set is a hack
- // on top of the legacy parser which will eventually be removed.
- RefPtr<Element> m_lastScriptElement; // FIXME: Hack for <script> support on top of the old parser.
- int m_lastScriptElementStartLine; // FIXME: Hack for <script> support on top of the old parser.
-
RefPtr<Element> m_scriptToProcess; // <script> tag which needs processing before resuming the parser.
int m_scriptToProcessStartLine; // Starting line number of the script tag needing processing.
+
+ // FIXME: We probably want to remove this member. Originally, it was
+ // created to service the legacy tree builder, but it seems to be used for
+ // some other things now.
+ int m_lastScriptElementStartLine;
};
+// FIXME: Move these functions to a more appropriate place.
+
+// Converts the specified string to a floating number.
+// If the conversion fails, the return value is false. Take care that leading
+// or trailing unnecessary characters make failures. This returns false for an
+// empty string input.
+// The double* parameter may be 0.
+bool parseToDoubleForNumberType(const String&, double*);
+// Converts the specified number to a string. This is an implementation of
+// HTML5's "algorithm to convert a number to a string" for NUMBER/RANGE types.
+String serializeForNumberType(double);
+
}
#endif
diff --git a/WebCore/html/HTMLUListElement.h b/WebCore/html/HTMLUListElement.h
index 996626c..f91bf1c 100644
--- a/WebCore/html/HTMLUListElement.h
+++ b/WebCore/html/HTMLUListElement.h
@@ -35,9 +35,6 @@ public:
private:
HTMLUListElement(const QualifiedName&, Document*);
- virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
- virtual int tagPriority() const { return 5; }
-
virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
virtual void parseMappedAttribute(Attribute*);
};
diff --git a/WebCore/html/HTMLVideoElement.cpp b/WebCore/html/HTMLVideoElement.cpp
index ed2d35c..cd9c7ec 100644
--- a/WebCore/html/HTMLVideoElement.cpp
+++ b/WebCore/html/HTMLVideoElement.cpp
@@ -76,7 +76,7 @@ void HTMLVideoElement::attach()
updateDisplayState();
if (shouldDisplayPosterImage()) {
if (!m_imageLoader)
- m_imageLoader.set(new HTMLImageLoader(this));
+ m_imageLoader = adoptPtr(new HTMLImageLoader(this));
m_imageLoader->updateFromElement();
if (renderer()) {
RenderImage* imageRenderer = toRenderImage(renderer());
@@ -105,7 +105,7 @@ void HTMLVideoElement::parseMappedAttribute(Attribute* attr)
#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
if (shouldDisplayPosterImage()) {
if (!m_imageLoader)
- m_imageLoader.set(new HTMLImageLoader(this));
+ m_imageLoader = adoptPtr(new HTMLImageLoader(this));
m_imageLoader->updateFromElementIgnoringPreviousError();
} else {
if (m_imageLoader)
diff --git a/WebCore/html/HTMLVideoElement.h b/WebCore/html/HTMLVideoElement.h
index 04a0beb..d893411 100644
--- a/WebCore/html/HTMLVideoElement.h
+++ b/WebCore/html/HTMLVideoElement.h
@@ -63,7 +63,6 @@ public:
private:
HTMLVideoElement(const QualifiedName&, Document*);
- virtual int tagPriority() const { return 5; }
virtual bool rendererIsNeeded(RenderStyle*);
#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
diff --git a/WebCore/html/HTMLViewSourceDocument.cpp b/WebCore/html/HTMLViewSourceDocument.cpp
index e0e71ee..b307ea2 100644
--- a/WebCore/html/HTMLViewSourceDocument.cpp
+++ b/WebCore/html/HTMLViewSourceDocument.cpp
@@ -53,7 +53,7 @@ HTMLViewSourceDocument::HTMLViewSourceDocument(Frame* frame, const KURL& url, co
setUsesBeforeAfterRules(true);
}
-DocumentParser* HTMLViewSourceDocument::createParser()
+PassRefPtr<DocumentParser> HTMLViewSourceDocument::createParser()
{
// Use HTMLDocumentParser if applicable, otherwise use TextDocumentParser.
if (m_type == "text/html" || m_type == "application/xhtml+xml" || m_type == "image/svg+xml" || DOMImplementation::isXMLMIMEType(m_type)
@@ -61,7 +61,7 @@ DocumentParser* HTMLViewSourceDocument::createParser()
|| m_type == "application/vnd.wap.xhtml+xml"
#endif
)
- return new HTMLViewSourceParser(this);
+ return HTMLViewSourceParser::create(this);
return createTextDocumentParser(this);
}
diff --git a/WebCore/html/HTMLViewSourceDocument.h b/WebCore/html/HTMLViewSourceDocument.h
index 8805848..f459016 100644
--- a/WebCore/html/HTMLViewSourceDocument.h
+++ b/WebCore/html/HTMLViewSourceDocument.h
@@ -49,7 +49,7 @@ private:
HTMLViewSourceDocument(Frame*, const KURL&, const String& mimeType);
// Returns HTMLViewSourceParser or TextDocumentParser based on m_type.
- virtual DocumentParser* createParser();
+ virtual PassRefPtr<DocumentParser> createParser();
void processDoctypeToken(const String& source, HTMLToken&);
void processTagToken(const String& source, HTMLToken&);
diff --git a/WebCore/html/HTMLViewSourceParser.cpp b/WebCore/html/HTMLViewSourceParser.cpp
index 3da4c23..8a7984d 100644
--- a/WebCore/html/HTMLViewSourceParser.cpp
+++ b/WebCore/html/HTMLViewSourceParser.cpp
@@ -32,6 +32,12 @@
namespace WebCore {
+HTMLViewSourceParser::HTMLViewSourceParser(HTMLViewSourceDocument* document)
+ : DecodedDataDocumentParser(document)
+ , m_tokenizer(HTMLTokenizer::create())
+{
+}
+
HTMLViewSourceParser::~HTMLViewSourceParser()
{
}
@@ -43,7 +49,7 @@ void HTMLViewSourceParser::insert(const SegmentedString&)
void HTMLViewSourceParser::pumpTokenizer()
{
- while (m_tokenizer.nextToken(m_input.current(), m_token)) {
+ while (m_tokenizer->nextToken(m_input.current(), m_token)) {
m_token.end(m_input.current().numberOfCharactersConsumed());
document()->addSource(sourceForToken(), m_token);
updateTokenizerState();
@@ -81,12 +87,12 @@ void HTMLViewSourceParser::updateTokenizerState()
return;
AtomicString tagName(m_token.name().data(), m_token.name().size());
- m_tokenizer.setState(HTMLTreeBuilder::adjustedLexerState(m_tokenizer.state(), tagName, m_document->frame()));
+ m_tokenizer->setState(HTMLTreeBuilder::adjustedLexerState(m_tokenizer->state(), tagName, document()->frame()));
if (tagName == HTMLNames::scriptTag) {
// The tree builder handles scriptTag separately from the other tokenizer
// state adjustments, so we need to handle it separately too.
- ASSERT(m_tokenizer.state() == HTMLTokenizer::DataState);
- m_tokenizer.setState(HTMLTokenizer::ScriptDataState);
+ ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState);
+ m_tokenizer->setState(HTMLTokenizer::ScriptDataState);
}
}
diff --git a/WebCore/html/HTMLViewSourceParser.h b/WebCore/html/HTMLViewSourceParser.h
index 2571301..34caf43 100644
--- a/WebCore/html/HTMLViewSourceParser.h
+++ b/WebCore/html/HTMLViewSourceParser.h
@@ -39,28 +39,27 @@ class HTMLTokenizer;
class HTMLScriptRunner;
class HTMLTreeBuilder;
class HTMLPreloadScanner;
-class LegacyHTMLTreeBuilder;
class ScriptController;
class ScriptSourceCode;
class HTMLViewSourceParser : public DecodedDataDocumentParser {
public:
- // FIXME: Make private with a create method.
- HTMLViewSourceParser(HTMLViewSourceDocument* document)
- : DecodedDataDocumentParser(document)
+ static PassRefPtr<HTMLViewSourceParser> create(HTMLViewSourceDocument* document)
{
+ return adoptRef(new HTMLViewSourceParser(document));
}
-
virtual ~HTMLViewSourceParser();
private:
+ HTMLViewSourceParser(HTMLViewSourceDocument*);
+
// DocumentParser
virtual void insert(const SegmentedString&);
virtual void append(const SegmentedString&);
virtual void finish();
virtual bool finishWasCalled();
- HTMLViewSourceDocument* document() const { return static_cast<HTMLViewSourceDocument*>(m_document); }
+ HTMLViewSourceDocument* document() const { return static_cast<HTMLViewSourceDocument*>(DecodedDataDocumentParser::document()); }
void pumpTokenizer();
String sourceForToken();
@@ -69,7 +68,7 @@ private:
HTMLInputStream m_input;
SegmentedString m_source;
HTMLToken m_token;
- HTMLTokenizer m_tokenizer;
+ OwnPtr<HTMLTokenizer> m_tokenizer;
};
}
diff --git a/WebCore/html/LegacyHTMLTreeBuilder.cpp b/WebCore/html/LegacyHTMLTreeBuilder.cpp
deleted file mode 100644
index f39579c..0000000
--- a/WebCore/html/LegacyHTMLTreeBuilder.cpp
+++ /dev/null
@@ -1,1786 +0,0 @@
-/*
- Copyright (C) 1997 Martin Jones (mjones@kde.org)
- (C) 1997 Torben Weis (weis@kde.org)
- (C) 1999,2001 Lars Knoll (knoll@kde.org)
- (C) 2000,2001 Dirk Mueller (mueller@kde.org)
- Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
- Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.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 "LegacyHTMLTreeBuilder.h"
-
-#include "CharacterNames.h"
-#include "CSSPropertyNames.h"
-#include "CSSValueKeywords.h"
-#include "Chrome.h"
-#include "ChromeClient.h"
-#include "Comment.h"
-#include "Console.h"
-#include "DOMWindow.h"
-#include "DocumentFragment.h"
-#include "DocumentType.h"
-#include "Frame.h"
-#include "HTMLBodyElement.h"
-#include "HTMLDocument.h"
-#include "HTMLDivElement.h"
-#include "HTMLDListElement.h"
-#include "HTMLElementFactory.h"
-#include "HTMLFormElement.h"
-#include "HTMLHeadElement.h"
-#include "HTMLHRElement.h"
-#include "HTMLHtmlElement.h"
-#include "HTMLIsIndexElement.h"
-#include "HTMLMapElement.h"
-#include "HTMLNames.h"
-#include "HTMLParserQuirks.h"
-#include "HTMLTableCellElement.h"
-#include "HTMLTableRowElement.h"
-#include "HTMLTableSectionElement.h"
-#include "LocalizedStrings.h"
-#include "Page.h"
-#include "ScriptableDocumentParser.h"
-#include "Settings.h"
-#include "Text.h"
-#include "TreeDepthLimit.h"
-#include <wtf/StdLibExtras.h>
-#include <wtf/dtoa.h>
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-static const unsigned cMaxRedundantTagDepth = 20;
-static const unsigned cResidualStyleMaxDepth = 200;
-static const unsigned cResidualStyleIterationLimit = 10;
-
-
-static const int minBlockLevelTagPriority = 3;
-
-// A cap on the number of tags with priority minBlockLevelTagPriority or higher
-// allowed in m_blockStack. The cap is enforced by adding such new elements as
-// siblings instead of children once it is reached.
-static const size_t cMaxBlockDepth = 4096;
-
-
-typedef HashSet<AtomicStringImpl*> TagNameSet;
-
-template< size_t ArraySize >
-static void addTags(TagNameSet& set, QualifiedName (&names)[ArraySize])
-{
- for (size_t x = 0; x < ArraySize; x++) {
- const QualifiedName& name = names[x];
- set.add(name.localName().impl());
- }
-}
-
-struct HTMLStackElem : Noncopyable {
- HTMLStackElem(const AtomicString& t, int lvl, Node* n, bool r, HTMLStackElem* nx)
- : tagName(t)
- , level(lvl)
- , strayTableContent(false)
- , node(n)
- , didRefNode(r)
- , next(nx)
- {
- }
-
- void derefNode()
- {
- if (didRefNode)
- node->deref();
- }
-
- AtomicString tagName;
- int level;
- bool strayTableContent;
- Node* node;
- bool didRefNode;
- HTMLStackElem* next;
-};
-
-/**
- * The parser parses tokenized input into the document, building up the
- * document tree. If the document is well-formed, parsing it is straightforward.
- *
- * Unfortunately, we have to handle many HTML documents that are not well-formed,
- * so the parser has to be tolerant about errors.
- *
- * We have to take care of at least the following error conditions:
- *
- * 1. The element being added is explicitly forbidden inside some outer tag.
- * In this case we should close all tags up to the one, which forbids
- * the element, and add it afterwards.
- *
- * 2. We are not allowed to add the element directly. It could be that
- * the person writing the document forgot some tag in between (or that the
- * tag in between is optional). This could be the case with the following
- * tags: HTML HEAD BODY TBODY TR TD LI (did I forget any?).
- *
- * 3. We want to add a block element inside to an inline element. Close all
- * inline elements up to the next higher block element.
- *
- * 4. If this doesn't help, close elements until we are allowed to add the
- * element or ignore the tag.
- *
- */
-
-LegacyHTMLTreeBuilder::LegacyHTMLTreeBuilder(HTMLDocument* doc, bool reportErrors)
- : m_document(doc)
- , m_current(doc)
- , m_didRefCurrent(false)
- , m_blockStack(0)
- , m_blocksInStack(0)
- , m_treeDepth(0)
- , m_hasPElementInScope(NotInScope)
- , m_inBody(false)
- , m_haveContent(false)
- , m_haveFrameSet(false)
- , m_isParsingFragment(false)
- , m_reportErrors(reportErrors)
- , m_handlingResidualStyleAcrossBlocks(false)
- , m_inStrayTableContent(0)
- , m_scriptingPermission(FragmentScriptingAllowed)
- , m_parserQuirks(m_document->page() ? m_document->page()->chrome()->client()->createHTMLParserQuirks() : 0)
-{
-}
-
-LegacyHTMLTreeBuilder::LegacyHTMLTreeBuilder(DocumentFragment* frag, FragmentScriptingPermission scriptingPermission)
- : m_document(frag->document())
- , m_current(frag)
- , m_didRefCurrent(true)
- , m_blockStack(0)
- , m_blocksInStack(0)
- , m_treeDepth(0)
- , m_hasPElementInScope(NotInScope)
- , m_inBody(true)
- , m_haveContent(false)
- , m_haveFrameSet(false)
- , m_isParsingFragment(true)
- , m_reportErrors(false)
- , m_handlingResidualStyleAcrossBlocks(false)
- , m_inStrayTableContent(0)
- , m_scriptingPermission(scriptingPermission)
- , m_parserQuirks(m_document->page() ? m_document->page()->chrome()->client()->createHTMLParserQuirks() : 0)
-{
- if (frag)
- frag->ref();
-}
-
-LegacyHTMLTreeBuilder::~LegacyHTMLTreeBuilder()
-{
- freeBlock();
- if (m_didRefCurrent)
- m_current->deref();
-}
-
-void LegacyHTMLTreeBuilder::reset()
-{
- ASSERT(!m_isParsingFragment);
-
- setCurrent(m_document);
-
- freeBlock();
-
- m_treeDepth = 0;
- m_inBody = false;
- m_haveFrameSet = false;
- m_haveContent = false;
- m_inStrayTableContent = 0;
-
- m_currentFormElement = 0;
- m_currentMapElement = 0;
- m_head = 0;
- m_isindexElement = 0;
-
- m_skipModeTag = nullAtom;
-
- if (m_parserQuirks)
- m_parserQuirks->reset();
-}
-
-void LegacyHTMLTreeBuilder::setCurrent(Node* newCurrent)
-{
- bool didRefNewCurrent = newCurrent && newCurrent != m_document;
- if (didRefNewCurrent)
- newCurrent->ref();
- if (m_didRefCurrent)
- m_current->deref();
- m_current = newCurrent;
- m_didRefCurrent = didRefNewCurrent;
-}
-
-inline static int tagPriorityOfNode(Node* n)
-{
- return n->isHTMLElement() ? static_cast<HTMLElement*>(n)->tagPriority() : 0;
-}
-
-inline void LegacyHTMLTreeBuilder::limitDepth(int tagPriority)
-{
- while (m_treeDepth >= maxDOMTreeDepth)
- popBlock(m_blockStack->tagName);
- if (tagPriority >= minBlockLevelTagPriority) {
- while (m_blocksInStack >= cMaxBlockDepth)
- popBlock(m_blockStack->tagName);
- }
-}
-
-inline bool LegacyHTMLTreeBuilder::insertNodeAfterLimitDepth(Node* n, bool flat)
-{
- limitDepth(tagPriorityOfNode(n));
- return insertNode(n, flat);
-}
-
-PassRefPtr<Node> LegacyHTMLTreeBuilder::parseToken(Token* t)
-{
- if (!m_skipModeTag.isNull()) {
- if (!t->beginTag && t->tagName == m_skipModeTag)
- // Found the end tag for the current skip mode, so we're done skipping.
- m_skipModeTag = nullAtom;
- else if (m_current->localName() == t->tagName)
- // Do not skip </iframe>.
- // FIXME: What does that comment mean? How can it be right to parse a token without clearing m_skipModeTag?
- ;
- else
- return 0;
- }
-
- // Apparently some sites use </br> instead of <br>. Be compatible with IE and Firefox and treat this like <br>.
- if (t->isCloseTag(brTag) && m_document->inCompatMode()) {
- reportError(MalformedBRError);
- t->beginTag = true;
- }
-
- if (!t->beginTag) {
- processCloseTag(t);
- return 0;
- }
-
- // Ignore spaces, if we're not inside a paragraph or other inline code.
- // Do not alter the text if it is part of a scriptTag.
- if (t->tagName == textAtom && t->text && m_current->localName() != scriptTag) {
- if (m_inBody && !skipMode() && m_current->localName() != styleTag &&
- m_current->localName() != titleTag && !t->text->containsOnlyWhitespace())
- m_haveContent = true;
-
- // HTML5 requires text node coalescing.
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#insert-a-character
- Node* previousChild = m_current->lastChild();
- if (previousChild && previousChild->isTextNode()) {
- // Only coalesce text nodes if the text node wouldn't be foster parented.
- if (!m_current->hasTagName(htmlTag)
- && !m_current->hasTagName(tableTag)
- && !m_current->hasTagName(trTag)
- && !m_current->hasTagName(theadTag)
- && !m_current->hasTagName(tbodyTag)
- && !m_current->hasTagName(tfootTag)
- && !m_current->hasTagName(titleTag)) {
- // Technically we're only supposed to merge into the previous
- // text node if it was the last node inserted by the parser.
- // (This was a spec modification made to make it easier for
- // mozilla to run their parser in a thread.)
- // In practice it does not seem to matter.
- CharacterData* textNode = static_cast<CharacterData*>(previousChild);
- textNode->parserAppendData(t->text);
- return textNode;
- }
- }
-
- RefPtr<Node> n;
- String text = t->text.get();
- unsigned charsLeft = text.length();
- while (charsLeft) {
- // split large blocks of text to nodes of manageable size
- n = Text::createWithLengthLimit(m_document, text, charsLeft);
- if (!insertNodeAfterLimitDepth(n.get(), t->selfClosingTag))
- return 0;
- }
- return n;
- }
-
- RefPtr<Node> n = getNode(t);
- // just to be sure, and to catch currently unimplemented stuff
- if (!n)
- return 0;
-
- // set attributes
- if (n->isHTMLElement()) {
- HTMLElement* e = static_cast<HTMLElement*>(n.get());
- if (m_scriptingPermission == FragmentScriptingAllowed || t->tagName != scriptTag)
- e->setAttributeMap(t->attrs.get(), m_scriptingPermission);
-
- // take care of optional close tags
- if (e->endTagRequirement() == TagStatusOptional)
- popBlock(t->tagName);
-
- // If the node does not have a forbidden end tag requirement, and if the broken XML self-closing
- // syntax was used, report an error.
- if (t->brokenXMLStyle && e->endTagRequirement() != TagStatusForbidden) {
- if (t->tagName == scriptTag)
- reportError(IncorrectXMLCloseScriptWarning);
- else
- reportError(IncorrectXMLSelfCloseError, &t->tagName);
- }
- }
-
- if (!insertNodeAfterLimitDepth(n.get(), t->selfClosingTag)) {
- // we couldn't insert the node
-
- if (n->isElementNode()) {
- Element* e = static_cast<Element*>(n.get());
- e->setAttributeMap(0);
- }
-
- if (m_currentMapElement == n)
- m_currentMapElement = 0;
-
- if (m_currentFormElement == n)
- m_currentFormElement = 0;
-
- if (m_head == n)
- m_head = 0;
-
- return 0;
- }
- return n;
-}
-
-void LegacyHTMLTreeBuilder::parseDoctypeToken(DoctypeToken* t)
-{
- // Ignore any doctype after the first. Ignore doctypes in fragments.
- if (m_document->doctype() || m_isParsingFragment || m_current != m_document)
- return;
-
- // Make a new doctype node and set it as our doctype.
- m_document->legacyParserAddChild(DocumentType::create(m_document, String::adopt(t->m_name), String::adopt(t->m_publicID), String::adopt(t->m_systemID)));
- if (t->m_forceQuirks)
- m_document->setParseMode(Document::Compat);
-}
-
-static bool isTableSection(const Node* n)
-{
- return n->hasTagName(tbodyTag) || n->hasTagName(tfootTag) || n->hasTagName(theadTag);
-}
-
-static bool isTablePart(const Node* n)
-{
- return n->hasTagName(trTag) || n->hasTagName(tdTag) || n->hasTagName(thTag)
- || isTableSection(n);
-}
-
-static bool isTableRelated(const Node* n)
-{
- return n->hasTagName(tableTag) || isTablePart(n);
-}
-
-static bool isScopingTag(const AtomicString& tagName)
-{
- return tagName == appletTag || tagName == captionTag || tagName == tdTag
- || tagName == thTag || tagName == buttonTag || tagName == marqueeTag
- || tagName == objectTag || tagName == tableTag || tagName == htmlTag;
-}
-
-bool LegacyHTMLTreeBuilder::insertNode(Node* n, bool flat)
-{
- RefPtr<Node> protectNode(n);
-
- const AtomicString& localName = n->localName();
-
- // <table> is never allowed inside stray table content. Always pop out of the stray table content
- // and close up the first table, and then start the second table as a sibling.
- if (m_inStrayTableContent && localName == tableTag)
- popBlock(tableTag);
-
- if (m_parserQuirks && !m_parserQuirks->shouldInsertNode(m_current, n))
- return false;
-
- int tagPriority = tagPriorityOfNode(n);
-
- // let's be stupid and just try to insert it.
- // this should work if the document is well-formed
- Node* newNode = m_current->legacyParserAddChild(n);
- if (!newNode)
- return handleError(n, flat, localName, tagPriority); // Try to handle the error.
-
- // don't push elements without end tags (e.g., <img>) on the stack
- bool parentAttached = m_current->attached();
- if (tagPriority > 0 && !flat) {
- if (newNode == m_current) {
- // This case should only be hit when a demoted <form> is placed inside a table.
- ASSERT(localName == formTag);
- reportError(FormInsideTablePartError, &m_current->localName());
- HTMLFormElement* form = static_cast<HTMLFormElement*>(n);
- form->setDemoted(true);
- } else {
- // The pushBlock function transfers ownership of current to the block stack
- // so we're guaranteed that m_didRefCurrent is false. The code below is an
- // optimized version of setCurrent that takes advantage of that fact and also
- // assumes that newNode is neither 0 nor a pointer to the document.
- pushBlock(localName, tagPriority);
- newNode->beginParsingChildren();
- ASSERT(!m_didRefCurrent);
- newNode->ref();
- m_current = newNode;
- m_didRefCurrent = true;
- }
- if (parentAttached && !n->attached() && !m_isParsingFragment)
- n->attach();
- } else {
- if (parentAttached && !n->attached() && !m_isParsingFragment)
- n->attach();
- n->finishParsingChildren();
- }
-
- if (localName == htmlTag && m_document->frame() && !m_isParsingFragment)
- m_document->frame()->loader()->dispatchDocumentElementAvailable();
-
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::handleError(Node* n, bool flat, const AtomicString& localName, int tagPriority)
-{
- // Error handling code. This is just ad hoc handling of specific parent/child combinations.
- bool handled = false;
-
- // 1. Check out the element's tag name to decide how to deal with errors.
- if (n->isHTMLElement()) {
- HTMLElement* h = static_cast<HTMLElement*>(n);
- if (h->hasLocalName(trTag) || h->hasLocalName(thTag) || h->hasLocalName(tdTag)) {
- if (m_inStrayTableContent && !isTableRelated(m_current)) {
- reportError(MisplacedTablePartError, &localName, &m_current->localName());
- // pop out to the nearest enclosing table-related tag.
- while (m_blockStack && !isTableRelated(m_current))
- popOneBlock();
- return insertNode(n);
- }
- } else if (h->hasLocalName(headTag)) {
- if (!m_current->isDocumentNode() && !m_current->hasTagName(htmlTag)) {
- reportError(MisplacedHeadError);
- return false;
- }
- } else if (h->hasLocalName(metaTag) || h->hasLocalName(linkTag) || h->hasLocalName(baseTag)) {
- bool createdHead = false;
- if (!m_head) {
- createHead();
- createdHead = true;
- }
- if (m_head) {
- if (!createdHead)
- reportError(MisplacedHeadContentError, &localName, &m_current->localName());
- if (m_head->legacyParserAddChild(n)) {
- if (!n->attached() && !m_isParsingFragment)
- n->attach();
- return true;
- }
- return false;
- }
- } else if (h->hasLocalName(htmlTag)) {
- if (!m_current->isDocumentNode() ) {
- if (m_document->documentElement() && m_document->documentElement()->hasTagName(htmlTag) && !m_isParsingFragment) {
- reportError(RedundantHTMLBodyError, &localName);
- // we have another <HTML> element.... apply attributes to existing one
- // make sure we don't overwrite already existing attributes
- NamedNodeMap* map = static_cast<Element*>(n)->attributes(true);
- Element* existingHTML = static_cast<Element*>(m_document->documentElement());
- NamedNodeMap* bmap = existingHTML->attributes(false);
- for (unsigned l = 0; map && l < map->length(); ++l) {
- Attribute* it = map->attributeItem(l);
- if (!bmap->getAttributeItem(it->name()))
- existingHTML->setAttribute(it->name(), it->value());
- }
- }
- return false;
- }
- } else if (h->hasLocalName(titleTag) || h->hasLocalName(styleTag) || h->hasLocalName(scriptTag)) {
- bool createdHead = false;
- if (!m_head) {
- createHead();
- createdHead = true;
- }
- if (m_head) {
- Node* newNode = m_head->legacyParserAddChild(n);
- if (!newNode) {
- setSkipMode(h->tagQName());
- return false;
- }
-
- if (!createdHead)
- reportError(MisplacedHeadContentError, &localName, &m_current->localName());
-
- pushBlock(localName, tagPriority);
- newNode->beginParsingChildren();
- setCurrent(newNode);
- if (!n->attached() && !m_isParsingFragment)
- n->attach();
- return true;
- }
- if (m_inBody) {
- setSkipMode(h->tagQName());
- return false;
- }
- } else if (h->hasLocalName(bodyTag)) {
- if (m_inBody && m_document->body() && !m_isParsingFragment) {
- // we have another <BODY> element.... apply attributes to existing one
- // make sure we don't overwrite already existing attributes
- // some sites use <body bgcolor=rightcolor>...<body bgcolor=wrongcolor>
- reportError(RedundantHTMLBodyError, &localName);
- NamedNodeMap* map = static_cast<Element*>(n)->attributes(true);
- Element* existingBody = m_document->body();
- NamedNodeMap* bmap = existingBody->attributes(false);
- for (unsigned l = 0; map && l < map->length(); ++l) {
- Attribute* it = map->attributeItem(l);
- if (!bmap->getAttributeItem(it->name()))
- existingBody->setAttribute(it->name(), it->value());
- }
- return false;
- } else if (!m_current->isDocumentNode())
- return false;
- } else if (h->hasLocalName(areaTag)) {
- if (m_currentMapElement) {
- reportError(MisplacedAreaError, &m_current->localName());
- m_currentMapElement->legacyParserAddChild(n);
- if (!n->attached() && !m_isParsingFragment)
- n->attach();
- handled = true;
- return true;
- }
- return false;
- } else if (h->hasLocalName(colgroupTag) || h->hasLocalName(captionTag)) {
- if (isTableRelated(m_current)) {
- while (m_blockStack && isTablePart(m_current))
- popOneBlock();
- return insertNode(n);
- }
- }
- } else if (n->isCommentNode() && !m_head)
- return false;
-
- // 2. Next we examine our currently active element to do some further error handling.
- if (m_current->isHTMLElement()) {
- HTMLElement* h = static_cast<HTMLElement*>(m_current);
- const AtomicString& currentTagName = h->localName();
- if (h->hasLocalName(htmlTag)) {
- HTMLElement* elt = n->isHTMLElement() ? static_cast<HTMLElement*>(n) : 0;
- if (elt && (elt->hasLocalName(scriptTag) || elt->hasLocalName(styleTag) ||
- elt->hasLocalName(metaTag) || elt->hasLocalName(linkTag) ||
- elt->hasLocalName(objectTag) || elt->hasLocalName(embedTag) ||
- elt->hasLocalName(titleTag) || elt->hasLocalName(isindexTag) ||
- elt->hasLocalName(baseTag))) {
- if (!m_head) {
- m_head = HTMLHeadElement::create(m_document);
- insertNode(m_head.get());
- handled = true;
- }
- } else {
- if (n->isTextNode()) {
- Text* t = static_cast<Text*>(n);
- if (t->containsOnlyWhitespace()) {
- if (m_head && !m_inBody) {
- // We're between </head> and <body>. According to
- // the HTML5 parsing algorithm, we're supposed to
- // insert whitespace text nodes into the HTML element.
- ExceptionCode ec;
- m_current->appendChild(n, ec);
- return true;
- }
- return false;
- }
- }
- if (!m_haveFrameSet) {
- // Ensure that head exists.
- // But not for older versions of Mail, where the implicit <head> isn't expected - <rdar://problem/6863795>
- if (!m_isParsingFragment && shouldCreateImplicitHead(m_document))
- createHead();
-
- popBlock(headTag);
- startBody();
- insertNode(HTMLBodyElement::create(m_document).get());
- handled = true;
- } else
- reportError(MisplacedFramesetContentError, &localName);
- }
- } else if (h->hasLocalName(headTag)) {
- if (n->hasTagName(htmlTag))
- return false;
- else {
- // This means the body starts here...
- if (!m_haveFrameSet) {
- ASSERT(currentTagName == headTag);
- popBlock(currentTagName);
- startBody();
- insertNode(HTMLBodyElement::create(m_document).get());
- handled = true;
- } else
- reportError(MisplacedFramesetContentError, &localName);
- }
- } else if (h->hasLocalName(addressTag) || h->hasLocalName(fontTag)
- || h->hasLocalName(styleTag) || h->hasLocalName(titleTag)) {
- reportError(MisplacedContentRetryError, &localName, &currentTagName);
- popBlock(currentTagName);
- handled = true;
- } else if (h->hasLocalName(captionTag)) {
- // Illegal content in a caption. Close the caption and try again.
- reportError(MisplacedCaptionContentError, &localName);
- popBlock(currentTagName);
- if (isTablePart(n))
- return insertNode(n, flat);
- } else if (h->hasLocalName(tableTag) || h->hasLocalName(trTag) || isTableSection(h)) {
- if (n->hasTagName(tableTag)) {
- reportError(MisplacedTableError, &currentTagName);
- if (m_isParsingFragment && !h->hasLocalName(tableTag))
- // fragment may contain table parts without <table> ancestor, pop them one by one
- popBlock(h->localName());
- popBlock(localName); // end the table
- handled = true; // ...and start a new one
- } else {
- ExceptionCode ec = 0;
- Node* node = m_current;
- Node* parent = node->parentNode();
- // A script may have removed the current node's parent from the DOM
- // http://bugs.webkit.org/show_bug.cgi?id=7137
- // FIXME: we should do real recovery here and re-parent with the correct node.
- if (!parent)
- return false;
- Node* grandparent = parent->parentNode();
-
- if (n->isTextNode() ||
- (h->hasLocalName(trTag) &&
- isTableSection(parent) && grandparent && grandparent->hasTagName(tableTag)) ||
- ((!n->hasTagName(tdTag) && !n->hasTagName(thTag) &&
- !n->hasTagName(formTag) && !n->hasTagName(scriptTag)) && isTableSection(node) &&
- parent->hasTagName(tableTag))) {
- node = (node->hasTagName(tableTag)) ? node :
- ((node->hasTagName(trTag)) ? grandparent : parent);
- // This can happen with fragments
- if (!node)
- return false;
- Node* parent = node->parentNode();
- if (!parent)
- return false;
- parent->insertBefore(n, node, ec);
- if (!ec) {
- reportError(StrayTableContentError, &localName, &currentTagName);
- if (n->isHTMLElement() && tagPriority > 0 &&
- !flat && static_cast<HTMLElement*>(n)->endTagRequirement() != TagStatusForbidden)
- {
- pushBlock(localName, tagPriority);
- n->beginParsingChildren();
- setCurrent(n);
- m_inStrayTableContent++;
- m_blockStack->strayTableContent = true;
- }
- return true;
- }
- }
-
- if (!ec) {
- if (m_current->hasTagName(trTag)) {
- reportError(TablePartRequiredError, &localName, &tdTag.localName());
- insertNode(HTMLTableCellElement::create(tdTag, m_document).get());
- } else if (m_current->hasTagName(tableTag)) {
- // Don't report an error in this case, since making a <tbody> happens all the time when you have <table><tr>,
- // and it isn't really a parse error per se.
- insertNode(HTMLTableSectionElement::create(tbodyTag, m_document).get());
- } else {
- reportError(TablePartRequiredError, &localName, &trTag.localName());
- insertNode(HTMLTableRowElement::create(m_document).get());
- }
- handled = true;
- }
- }
- } else if (h->hasLocalName(objectTag)) {
- reportError(MisplacedContentRetryError, &localName, &currentTagName);
- popBlock(objectTag);
- handled = true;
- } else if (h->hasLocalName(pTag) || isHeadingTag(currentTagName)) {
- if (!isInline(n)) {
- popBlock(currentTagName);
- handled = true;
- }
- } else if (h->hasLocalName(optionTag) || h->hasLocalName(optgroupTag)) {
- if (localName == optgroupTag) {
- popBlock(currentTagName);
- handled = true;
- } else if (localName == selectTag) {
- // IE treats a nested select as </select>. Let's do the same
- popBlock(localName);
- }
- } else if (h->hasLocalName(selectTag)) {
- if (localName == inputTag || localName == textareaTag) {
- reportError(MisplacedContentRetryError, &localName, &currentTagName);
- popBlock(currentTagName);
- handled = true;
- }
- } else if (h->hasLocalName(colgroupTag)) {
- popBlock(currentTagName);
- handled = true;
- } else if (!h->hasLocalName(bodyTag)) {
- if (isInline(m_current)) {
- popInlineBlocks();
- handled = true;
- }
- }
- } else if (m_current->isDocumentNode()) {
- if (n->isTextNode()) {
- Text* t = static_cast<Text*>(n);
- if (t->containsOnlyWhitespace())
- return false;
- }
-
- if (!m_document->documentElement()) {
- insertNode(HTMLHtmlElement::create(m_document).get());
- handled = true;
- }
- }
-
- // 3. If we couldn't handle the error, just return false and attempt to error-correct again.
- if (!handled) {
- reportError(IgnoredContentError, &localName, &m_current->localName());
- return false;
- }
- return insertNode(n);
-}
-
-typedef bool (LegacyHTMLTreeBuilder::*CreateErrorCheckFunc)(Token* t, RefPtr<Node>&);
-typedef HashMap<AtomicStringImpl*, CreateErrorCheckFunc> FunctionMap;
-
-bool LegacyHTMLTreeBuilder::textCreateErrorCheck(Token* t, RefPtr<Node>& result)
-{
- result = Text::create(m_document, t->text.get());
- return false;
-}
-
-bool LegacyHTMLTreeBuilder::commentCreateErrorCheck(Token* t, RefPtr<Node>& result)
-{
- result = Comment::create(m_document, t->text.get());
- return false;
-}
-
-bool LegacyHTMLTreeBuilder::headCreateErrorCheck(Token*, RefPtr<Node>& result)
-{
- if (!m_head || m_current->localName() == htmlTag) {
- m_head = HTMLHeadElement::create(m_document);
- result = m_head;
- } else
- reportError(MisplacedHeadError);
- return false;
-}
-
-bool LegacyHTMLTreeBuilder::bodyCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- // body no longer allowed if we have a frameset
- if (m_haveFrameSet)
- return false;
-
- // Ensure that head exists (unless parsing a fragment).
- // But not for older versions of Mail, where the implicit <head> isn't expected - <rdar://problem/6863795>
- if (!m_isParsingFragment && shouldCreateImplicitHead(m_document))
- createHead();
-
- popBlock(headTag);
- startBody();
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::framesetCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- popBlock(headTag);
- if (m_inBody && !m_haveFrameSet && !m_haveContent) {
- popBlock(bodyTag);
- // ### actually for IE document.body returns the now hidden "body" element
- // we can't implement that behaviour now because it could cause too many
- // regressions and the headaches are not worth the work as long as there is
- // no site actually relying on that detail (Dirk)
- if (m_document->body() && !m_isParsingFragment)
- m_document->body()->setAttribute(styleAttr, "display:none");
- m_inBody = false;
- }
- if ((m_haveContent || m_haveFrameSet) && m_current->localName() == htmlTag)
- return false;
- m_haveFrameSet = true;
- startBody();
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::formCreateErrorCheck(Token* t, RefPtr<Node>& result)
-{
- // Only create a new form if we're not already inside one.
- // This is consistent with other browsers' behavior.
- if (!m_currentFormElement) {
- m_currentFormElement = HTMLFormElement::create(m_document);
- result = m_currentFormElement;
- pCloserCreateErrorCheck(t, result);
- }
- return false;
-}
-
-bool LegacyHTMLTreeBuilder::isindexCreateErrorCheck(Token* t, RefPtr<Node>& result)
-{
- RefPtr<Node> n = handleIsindex(t);
- if (!m_inBody)
- m_isindexElement = n.release();
- else {
- t->selfClosingTag = true;
- result = n.release();
- }
- return false;
-}
-
-bool LegacyHTMLTreeBuilder::selectCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::ddCreateErrorCheck(Token* t, RefPtr<Node>& result)
-{
- pCloserCreateErrorCheck(t, result);
- popBlock(dtTag);
- popBlock(ddTag);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::dtCreateErrorCheck(Token* t, RefPtr<Node>& result)
-{
- pCloserCreateErrorCheck(t, result);
- popBlock(ddTag);
- popBlock(dtTag);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::rpCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- popBlock(rpTag);
- popBlock(rtTag);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::rtCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- popBlock(rpTag);
- popBlock(rtTag);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::nestedCreateErrorCheck(Token* t, RefPtr<Node>&)
-{
- popBlock(t->tagName);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::nestedPCloserCreateErrorCheck(Token* t, RefPtr<Node>& result)
-{
- pCloserCreateErrorCheck(t, result);
- popBlock(t->tagName);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::nestedStyleCreateErrorCheck(Token* t, RefPtr<Node>&)
-{
- return allowNestedRedundantTag(t->tagName);
-}
-
-bool LegacyHTMLTreeBuilder::colCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- if (!m_current->hasTagName(tableTag))
- return true;
- RefPtr<Element> implicitColgroup = HTMLElementFactory::createHTMLElement(colgroupTag, m_document, 0, true);
- insertNode(implicitColgroup.get());
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::tableCellCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- popBlock(tdTag);
- popBlock(thTag);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::tableSectionCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- popBlock(theadTag);
- popBlock(tbodyTag);
- popBlock(tfootTag);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::noembedCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- setSkipMode(noembedTag);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::noframesCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- setSkipMode(noframesTag);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::noscriptCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- if (!m_isParsingFragment) {
- Frame* frame = m_document->frame();
- if (frame && frame->script()->canExecuteScripts(NotAboutToExecuteScript))
- setSkipMode(noscriptTag);
- }
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::pCloserCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- if (hasPElementInScope())
- popBlock(pTag);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::pCloserStrictCreateErrorCheck(Token*, RefPtr<Node>&)
-{
- if (m_document->inCompatMode())
- return true;
- if (hasPElementInScope())
- popBlock(pTag);
- return true;
-}
-
-bool LegacyHTMLTreeBuilder::mapCreateErrorCheck(Token*, RefPtr<Node>& result)
-{
- m_currentMapElement = HTMLMapElement::create(m_document);
- result = m_currentMapElement;
- return false;
-}
-
-static void mapTagToFunc(FunctionMap& map, const QualifiedName& tag, CreateErrorCheckFunc func)
-{
- map.set(tag.localName().impl(), func);
-}
-
-template< size_t ArraySize >
-static void mapTagsToFunc(FunctionMap& map, QualifiedName (&names)[ArraySize], CreateErrorCheckFunc func)
-{
- for (size_t x = 0; x < ArraySize; x++) {
- const QualifiedName& name = names[x];
- mapTagToFunc(map, name, func);
- }
-}
-
-PassRefPtr<Node> LegacyHTMLTreeBuilder::getNode(Token* t)
-{
- // Init our error handling table.
- DEFINE_STATIC_LOCAL(FunctionMap, gFunctionMap, ());
- if (gFunctionMap.isEmpty()) {
- QualifiedName nestedCreateErrorTags[] = { aTag, buttonTag, nobrTag, trTag };
- mapTagsToFunc(gFunctionMap, nestedCreateErrorTags, &LegacyHTMLTreeBuilder::nestedCreateErrorCheck);
-
- QualifiedName nestedStyleCreateErrorTags[] = { bTag, bigTag, iTag, markTag, sTag, smallTag, strikeTag, ttTag, uTag };
- mapTagsToFunc(gFunctionMap, nestedStyleCreateErrorTags, &LegacyHTMLTreeBuilder::nestedStyleCreateErrorCheck);
-
- QualifiedName pCloserCreateErrorTags[] = { addressTag, articleTag,
- asideTag, blockquoteTag, centerTag, dirTag, divTag, dlTag,
- fieldsetTag, footerTag, h1Tag, h2Tag, h3Tag, h4Tag, h5Tag, h6Tag,
- headerTag, hgroupTag, hrTag, listingTag, menuTag, navTag, olTag,
- pTag, plaintextTag, preTag, sectionTag, ulTag };
- mapTagsToFunc(gFunctionMap, pCloserCreateErrorTags, &LegacyHTMLTreeBuilder::pCloserCreateErrorCheck);
-
- mapTagToFunc(gFunctionMap, bodyTag, &LegacyHTMLTreeBuilder::bodyCreateErrorCheck);
- mapTagToFunc(gFunctionMap, colTag, &LegacyHTMLTreeBuilder::colCreateErrorCheck);
- mapTagToFunc(gFunctionMap, ddTag, &LegacyHTMLTreeBuilder::ddCreateErrorCheck);
- mapTagToFunc(gFunctionMap, dtTag, &LegacyHTMLTreeBuilder::dtCreateErrorCheck);
- mapTagToFunc(gFunctionMap, formTag, &LegacyHTMLTreeBuilder::formCreateErrorCheck);
- mapTagToFunc(gFunctionMap, framesetTag, &LegacyHTMLTreeBuilder::framesetCreateErrorCheck);
- mapTagToFunc(gFunctionMap, headTag, &LegacyHTMLTreeBuilder::headCreateErrorCheck);
- mapTagToFunc(gFunctionMap, isindexTag, &LegacyHTMLTreeBuilder::isindexCreateErrorCheck);
- mapTagToFunc(gFunctionMap, mapTag, &LegacyHTMLTreeBuilder::mapCreateErrorCheck);
- mapTagToFunc(gFunctionMap, liTag, &LegacyHTMLTreeBuilder::nestedPCloserCreateErrorCheck);
- mapTagToFunc(gFunctionMap, noembedTag, &LegacyHTMLTreeBuilder::noembedCreateErrorCheck);
- mapTagToFunc(gFunctionMap, noframesTag, &LegacyHTMLTreeBuilder::noframesCreateErrorCheck);
- mapTagToFunc(gFunctionMap, noscriptTag, &LegacyHTMLTreeBuilder::noscriptCreateErrorCheck);
- mapTagToFunc(gFunctionMap, tableTag, &LegacyHTMLTreeBuilder::pCloserStrictCreateErrorCheck);
- mapTagToFunc(gFunctionMap, rpTag, &LegacyHTMLTreeBuilder::rpCreateErrorCheck);
- mapTagToFunc(gFunctionMap, rtTag, &LegacyHTMLTreeBuilder::rtCreateErrorCheck);
- mapTagToFunc(gFunctionMap, selectTag, &LegacyHTMLTreeBuilder::selectCreateErrorCheck);
- mapTagToFunc(gFunctionMap, tdTag, &LegacyHTMLTreeBuilder::tableCellCreateErrorCheck);
- mapTagToFunc(gFunctionMap, thTag, &LegacyHTMLTreeBuilder::tableCellCreateErrorCheck);
- mapTagToFunc(gFunctionMap, tbodyTag, &LegacyHTMLTreeBuilder::tableSectionCreateErrorCheck);
- mapTagToFunc(gFunctionMap, tfootTag, &LegacyHTMLTreeBuilder::tableSectionCreateErrorCheck);
- mapTagToFunc(gFunctionMap, theadTag, &LegacyHTMLTreeBuilder::tableSectionCreateErrorCheck);
-
- gFunctionMap.set(commentAtom.impl(), &LegacyHTMLTreeBuilder::commentCreateErrorCheck);
- gFunctionMap.set(textAtom.impl(), &LegacyHTMLTreeBuilder::textCreateErrorCheck);
- }
-
- bool proceed = true;
- RefPtr<Node> result;
- if (CreateErrorCheckFunc errorCheckFunc = gFunctionMap.get(t->tagName.impl()))
- proceed = (this->*errorCheckFunc)(t, result);
- if (proceed)
- result = HTMLElementFactory::createHTMLElement(QualifiedName(nullAtom, t->tagName, xhtmlNamespaceURI), m_document, m_currentFormElement.get());
- return result.release();
-}
-
-bool LegacyHTMLTreeBuilder::allowNestedRedundantTag(const AtomicString& tagName)
-{
- // www.liceo.edu.mx is an example of a site that achieves a level of nesting of
- // about 1500 tags, all from a bunch of <b>s. We will only allow at most 20
- // nested tags of the same type before just ignoring them all together.
- unsigned i = 0;
- for (HTMLStackElem* curr = m_blockStack;
- i < cMaxRedundantTagDepth && curr && curr->tagName == tagName;
- curr = curr->next, i++) { }
- return i != cMaxRedundantTagDepth;
-}
-
-void LegacyHTMLTreeBuilder::processCloseTag(Token* t)
-{
- // Support for really broken html.
- // we never close the body tag, since some stupid web pages close it before the actual end of the doc.
- // let's rely on the end() call to close things.
- if (t->tagName == htmlTag || t->tagName == bodyTag || t->tagName == commentAtom)
- return;
-
- bool checkForCloseTagErrors = true;
- if (t->tagName == formTag && m_currentFormElement) {
- m_currentFormElement = 0;
- checkForCloseTagErrors = false;
- } else if (t->tagName == mapTag)
- m_currentMapElement = 0;
- else if (t->tagName == pTag)
- checkForCloseTagErrors = false;
-
- HTMLStackElem* oldElem = m_blockStack;
- popBlock(t->tagName, checkForCloseTagErrors);
- if (oldElem == m_blockStack && t->tagName == pTag) {
- // We encountered a stray </p>. Amazingly Gecko, WinIE, and MacIE all treat
- // this as a valid break, i.e., <p></p>. So go ahead and make the empty
- // paragraph.
- t->beginTag = true;
- parseToken(t);
- popBlock(t->tagName);
- reportError(StrayParagraphCloseError);
- }
-}
-
-bool LegacyHTMLTreeBuilder::isHeadingTag(const AtomicString& tagName)
-{
- DEFINE_STATIC_LOCAL(TagNameSet, headingTags, ());
- if (headingTags.isEmpty()) {
- QualifiedName tagNames[] = { h1Tag, h2Tag, h3Tag, h4Tag, h5Tag, h6Tag };
- addTags(headingTags, tagNames);
- }
- return headingTags.contains(tagName.impl());
-}
-
-bool LegacyHTMLTreeBuilder::isInline(Node* node) const
-{
- if (node->isTextNode())
- return true;
-
- if (node->isHTMLElement()) {
- HTMLElement* e = static_cast<HTMLElement*>(node);
- if (e->hasLocalName(aTag) || e->hasLocalName(fontTag) || e->hasLocalName(ttTag) ||
- e->hasLocalName(uTag) || e->hasLocalName(bTag) || e->hasLocalName(iTag) ||
- e->hasLocalName(sTag) || e->hasLocalName(strikeTag) || e->hasLocalName(bigTag) ||
- e->hasLocalName(smallTag) || e->hasLocalName(emTag) || e->hasLocalName(strongTag) ||
- e->hasLocalName(dfnTag) || e->hasLocalName(codeTag) || e->hasLocalName(sampTag) ||
- e->hasLocalName(kbdTag) || e->hasLocalName(varTag) || e->hasLocalName(citeTag) ||
- e->hasLocalName(abbrTag) || e->hasLocalName(acronymTag) || e->hasLocalName(subTag) ||
- e->hasLocalName(supTag) || e->hasLocalName(spanTag) || e->hasLocalName(nobrTag) ||
- e->hasLocalName(noframesTag) || e->hasLocalName(nolayerTag) ||
- e->hasLocalName(noembedTag) || e->hasLocalName(markTag))
- return true;
-#if !ENABLE(XHTMLMP)
- if (e->hasLocalName(noscriptTag) && !m_isParsingFragment) {
- Frame* frame = m_document->frame();
- if (frame && frame->script()->canExecuteScripts(NotAboutToExecuteScript))
- return true;
- }
-#endif
- }
-
- return false;
-}
-
-bool LegacyHTMLTreeBuilder::isResidualStyleTag(const AtomicString& tagName)
-{
- DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, residualStyleTags, ());
- if (residualStyleTags.isEmpty()) {
- QualifiedName tagNames[] = { aTag, fontTag, ttTag, uTag, bTag, iTag,
- sTag, strikeTag, bigTag, smallTag, emTag, strongTag, dfnTag,
- codeTag, sampTag, kbdTag, varTag, nobrTag, markTag };
- addTags(residualStyleTags, tagNames);
- }
- return residualStyleTags.contains(tagName.impl());
-}
-
-bool LegacyHTMLTreeBuilder::isAffectedByResidualStyle(const AtomicString& tagName)
-{
- DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, unaffectedTags, ());
- if (unaffectedTags.isEmpty()) {
- QualifiedName tagNames[] = { bodyTag, tableTag, theadTag, tbodyTag,
- tfootTag, trTag, thTag, tdTag, captionTag, colgroupTag, colTag,
- optionTag, optgroupTag, selectTag, objectTag, datagridTag, datalistTag };
- addTags(unaffectedTags, tagNames);
- }
- return !unaffectedTags.contains(tagName.impl());
-}
-
-void LegacyHTMLTreeBuilder::handleResidualStyleCloseTagAcrossBlocks(HTMLStackElem* elem)
-{
- HTMLStackElem* maxElem = 0;
- bool finished = false;
- bool strayTableContent = elem->strayTableContent;
-
- unsigned iterationCount = 0;
-
- m_handlingResidualStyleAcrossBlocks = true;
- while (!finished && (iterationCount++ < cResidualStyleIterationLimit)) {
- // Find the outermost element that crosses over to a higher level. If there exists another higher-level
- // element, we will do another pass, until we have corrected the innermost one.
- ExceptionCode ec = 0;
- HTMLStackElem* curr = m_blockStack;
- HTMLStackElem* prev = 0;
- HTMLStackElem* prevMaxElem = 0;
- maxElem = 0;
- finished = true;
- while (curr && curr != elem) {
- if (curr->level > elem->level) {
- if (!isAffectedByResidualStyle(curr->tagName))
- return;
- if (maxElem)
- // We will need another pass.
- finished = false;
- maxElem = curr;
- prevMaxElem = prev;
- }
-
- prev = curr;
- curr = curr->next;
- }
-
- if (!curr || !maxElem)
- return;
-
- Node* residualElem = prev->node;
- Node* blockElem = prevMaxElem ? prevMaxElem->node : m_current;
- Node* parentElem = elem->node;
-
- // Check to see if the reparenting that is going to occur is allowed according to the DOM.
- // FIXME: We should either always allow it or perform an additional fixup instead of
- // just bailing here.
- // Example: <p><font><center>blah</font></center></p> isn't doing a fixup right now.
- if (!parentElem->childAllowed(blockElem))
- return;
-
- m_hasPElementInScope = Unknown;
-
- if (maxElem->node->parentNode() != elem->node) {
- // Walk the stack and remove any elements that aren't residual style tags. These
- // are basically just being closed up. Example:
- // <font><span>Moo<p>Goo</font></p>.
- // In the above example, the <span> doesn't need to be reopened. It can just close.
- HTMLStackElem* currElem = maxElem->next;
- HTMLStackElem* prevElem = maxElem;
- while (currElem != elem) {
- HTMLStackElem* nextElem = currElem->next;
- if (!isResidualStyleTag(currElem->tagName)) {
- prevElem->next = nextElem;
- prevElem->derefNode();
- prevElem->node = currElem->node;
- prevElem->didRefNode = currElem->didRefNode;
- delete currElem;
- m_treeDepth--;
- } else
- prevElem = currElem;
- currElem = nextElem;
- }
-
- // We have to reopen residual tags in between maxElem and elem. An example of this case is:
- // <font><i>Moo<p>Foo</font>.
- // In this case, we need to transform the part before the <p> into:
- // <font><i>Moo</i></font><i>
- // so that the <i> will remain open. This involves the modification of elements
- // in the block stack.
- // This will also affect how we ultimately reparent the block, since we want it to end up
- // under the reopened residual tags (e.g., the <i> in the above example.)
- RefPtr<Node> prevNode = 0;
- currElem = maxElem;
- while (currElem->node != residualElem) {
- if (isResidualStyleTag(currElem->node->localName())) {
- // Create a clone of this element.
- // We call releaseRef to get a raw pointer since we plan to hand over ownership to currElem.
- Node* currNode = currElem->node->cloneNode(false).releaseRef();
- reportError(ResidualStyleError, &currNode->localName());
-
- // Change the stack element's node to point to the clone.
- // The stack element adopts the reference we obtained above by calling release().
- currElem->derefNode();
- currElem->node = currNode;
- currElem->didRefNode = true;
-
- // Attach the previous node as a child of this new node.
- if (prevNode)
- currNode->appendChild(prevNode, ec);
- else // The new parent for the block element is going to be the innermost clone.
- parentElem = currNode; // FIXME: We shifted parentElem to be a residual inline. We never checked to see if blockElem could be legally placed inside the inline though.
-
- prevNode = currNode;
- }
-
- currElem = currElem->next;
- }
-
- // Now append the chain of new residual style elements if one exists.
- if (prevNode)
- elem->node->appendChild(prevNode, ec); // FIXME: This append can result in weird stuff happening, like an inline chain being put into a table section.
- }
-
- // Check if the block is still in the tree. If it isn't, then we don't
- // want to remove it from its parent (that would crash) or insert it into
- // a new parent later. See http://bugs.webkit.org/show_bug.cgi?id=6778
- bool isBlockStillInTree = blockElem->parentNode();
-
- // We need to make a clone of |residualElem| and place it just inside |blockElem|.
- // All content of |blockElem| is reparented to be under this clone. We then
- // reparent |blockElem| using real DOM calls so that attachment/detachment will
- // be performed to fix up the rendering tree.
- // So for this example: <b>...<p>Foo</b>Goo</p>
- // The end result will be: <b>...</b><p><b>Foo</b>Goo</p>
- //
- // Step 1: Remove |blockElem| from its parent, doing a batch detach of all the kids.
- if (isBlockStillInTree)
- blockElem->parentNode()->removeChild(blockElem, ec);
-
- Node* newNodePtr = 0;
- if (blockElem->firstChild()) {
- // Step 2: Clone |residualElem|.
- RefPtr<Node> newNode = residualElem->cloneNode(false); // Shallow clone. We don't pick up the same kids.
- newNodePtr = newNode.get();
- reportError(ResidualStyleError, &newNode->localName());
-
- // Step 3: Place |blockElem|'s children under |newNode|. Remove all of the children of |blockElem|
- // before we've put |newElem| into the document. That way we'll only do one attachment of all
- // the new content (instead of a bunch of individual attachments).
- Node* currNode = blockElem->firstChild();
- while (currNode) {
- Node* nextNode = currNode->nextSibling();
- newNode->appendChild(currNode, ec);
- currNode = nextNode;
- }
-
- // Step 4: Place |newNode| under |blockElem|. |blockElem| is still out of the document, so no
- // attachment can occur yet.
- blockElem->appendChild(newNode.release(), ec);
- } else
- finished = true;
-
- // Step 5: Reparent |blockElem|. Now the full attachment of the fixed up tree takes place.
- if (isBlockStillInTree)
- parentElem->appendChild(blockElem, ec);
-
- // Step 6: Pull |elem| out of the stack, since it is no longer enclosing us. Also update
- // the node associated with the previous stack element so that when it gets popped,
- // it doesn't make the residual element the next current node.
- HTMLStackElem* currElem = maxElem;
- HTMLStackElem* prevElem = 0;
- while (currElem != elem) {
- prevElem = currElem;
- currElem = currElem->next;
- }
- prevElem->next = elem->next;
- prevElem->derefNode();
- prevElem->node = elem->node;
- prevElem->didRefNode = elem->didRefNode;
- m_treeDepth--;
- if (!finished) {
- // Repurpose |elem| to represent |newNode| and insert it at the appropriate position
- // in the stack. We do not do this for the innermost block, because in that case the new
- // node is effectively no longer open.
- elem->next = maxElem;
- elem->node = prevMaxElem->node;
- elem->didRefNode = prevMaxElem->didRefNode;
- elem->strayTableContent = false;
- prevMaxElem->next = elem;
- ASSERT(newNodePtr);
- prevMaxElem->node = newNodePtr;
- newNodePtr->ref();
- prevMaxElem->didRefNode = true;
- m_treeDepth++;
- } else
- delete elem;
- }
-
- // FIXME: If we ever make a case like this work:
- // <table><b><i><form></b></form></i></table>
- // Then this check will be too simplistic. Right now the <i><form> chain will end up inside the <tbody>, which is pretty crazy.
- if (strayTableContent)
- m_inStrayTableContent--;
-
- // Step 7: Reopen intermediate inlines, e.g., <b><p><i>Foo</b>Goo</p>.
- // In the above example, Goo should stay italic.
- // We cap the number of tags we're willing to reopen based off cResidualStyleMaxDepth.
-
- HTMLStackElem* curr = m_blockStack;
- HTMLStackElem* residualStyleStack = 0;
- unsigned stackDepth = 1;
- unsigned redundantStyleCount = 0;
- while (curr && curr != maxElem) {
- // We will actually schedule this tag for reopening
- // after we complete the close of this entire block.
- if (isResidualStyleTag(curr->tagName) && stackDepth++ < cResidualStyleMaxDepth) {
- // We've overloaded the use of stack elements and are just reusing the
- // struct with a slightly different meaning to the variables. Instead of chaining
- // from innermost to outermost, we build up a list of all the tags we need to reopen
- // from the outermost to the innermost, i.e., residualStyleStack will end up pointing
- // to the outermost tag we need to reopen.
- // We also set curr->node to be the actual element that corresponds to the ID stored in
- // curr->id rather than the node that you should pop to when the element gets pulled off
- // the stack.
- if (residualStyleStack && curr->tagName == residualStyleStack->tagName && curr->node->attributes()->mapsEquivalent(residualStyleStack->node->attributes()))
- redundantStyleCount++;
- else
- redundantStyleCount = 0;
-
- if (redundantStyleCount < cMaxRedundantTagDepth)
- moveOneBlockToStack(residualStyleStack);
- else
- popOneBlock();
- } else
- popOneBlock();
-
- curr = m_blockStack;
- }
-
- reopenResidualStyleTags(residualStyleStack, 0); // Stray table content can't be an issue here, since some element above will always become the root of new stray table content.
-
- m_handlingResidualStyleAcrossBlocks = false;
-}
-
-void LegacyHTMLTreeBuilder::reopenResidualStyleTags(HTMLStackElem* elem, Node* malformedTableParent)
-{
- // Loop for each tag that needs to be reopened.
- while (elem) {
- // Create a shallow clone of the DOM node for this element.
- RefPtr<Node> newNode = elem->node->cloneNode(false);
- reportError(ResidualStyleError, &newNode->localName());
-
- // Append the new node. In the malformed table case, we need to insert before the table,
- // which will be the last child.
- ExceptionCode ec = 0;
- if (malformedTableParent)
- malformedTableParent->insertBefore(newNode, malformedTableParent->lastChild(), ec);
- else
- m_current->appendChild(newNode, ec);
- // FIXME: Is it really OK to ignore the exceptions here?
-
- // Now push a new stack element for this node we just created.
- pushBlock(elem->tagName, elem->level);
- newNode->beginParsingChildren();
-
- // Set our strayTableContent boolean if needed, so that the reopened tag also knows
- // that it is inside a malformed table.
- m_blockStack->strayTableContent = malformedTableParent != 0;
- if (m_blockStack->strayTableContent)
- m_inStrayTableContent++;
-
- // Clear our malformed table parent variable.
- malformedTableParent = 0;
-
- // Update |current| manually to point to the new node.
- setCurrent(newNode.get());
-
- // Advance to the next tag that needs to be reopened.
- HTMLStackElem* next = elem->next;
- elem->derefNode();
- delete elem;
- elem = next;
- }
-}
-
-void LegacyHTMLTreeBuilder::pushBlock(const AtomicString& tagName, int level)
-{
- m_blockStack = new HTMLStackElem(tagName, level, m_current, m_didRefCurrent, m_blockStack);
- if (level >= minBlockLevelTagPriority)
- m_blocksInStack++;
- m_treeDepth++;
- m_didRefCurrent = false;
- if (tagName == pTag)
- m_hasPElementInScope = InScope;
- else if (isScopingTag(tagName))
- m_hasPElementInScope = NotInScope;
-}
-
-void LegacyHTMLTreeBuilder::popBlock(const AtomicString& tagName, bool reportErrors)
-{
- HTMLStackElem* elem = m_blockStack;
-
- if (m_parserQuirks && elem && !m_parserQuirks->shouldPopBlock(elem->tagName, tagName))
- return;
-
- int maxLevel = 0;
-
- while (elem && (elem->tagName != tagName)) {
- if (maxLevel < elem->level)
- maxLevel = elem->level;
- elem = elem->next;
- }
-
- if (!elem) {
- if (reportErrors)
- reportError(StrayCloseTagError, &tagName, 0, true);
- return;
- }
-
- if (maxLevel > elem->level) {
- // We didn't match because the tag is in a different scope, e.g.,
- // <b><p>Foo</b>. Try to correct the problem.
- if (!isResidualStyleTag(tagName))
- return;
- return handleResidualStyleCloseTagAcrossBlocks(elem);
- }
-
- bool isAffectedByStyle = isAffectedByResidualStyle(elem->tagName);
- HTMLStackElem* residualStyleStack = 0;
- Node* malformedTableParent = 0;
-
- elem = m_blockStack;
- unsigned stackDepth = 1;
- unsigned redundantStyleCount = 0;
- while (elem) {
- if (elem->tagName == tagName) {
- int strayTable = m_inStrayTableContent;
- popOneBlock();
- elem = 0;
-
- // This element was the root of some malformed content just inside an implicit or
- // explicit <tbody> or <tr>.
- // If we end up needing to reopen residual style tags, the root of the reopened chain
- // must also know that it is the root of malformed content inside a <tbody>/<tr>.
- if (strayTable && (m_inStrayTableContent < strayTable) && residualStyleStack) {
- Node* curr = m_current;
- while (curr && !curr->hasTagName(tableTag))
- curr = curr->parentNode();
- malformedTableParent = curr ? curr->parentNode() : 0;
- }
- }
- else {
- if (m_currentFormElement && elem->tagName == formTag)
- // A <form> is being closed prematurely (and this is
- // malformed HTML). Set an attribute on the form to clear out its
- // bottom margin.
- m_currentFormElement->setMalformed(true);
-
- // Schedule this tag for reopening
- // after we complete the close of this entire block.
- if (isAffectedByStyle && isResidualStyleTag(elem->tagName) && stackDepth++ < cResidualStyleMaxDepth) {
- // We've overloaded the use of stack elements and are just reusing the
- // struct with a slightly different meaning to the variables. Instead of chaining
- // from innermost to outermost, we build up a list of all the tags we need to reopen
- // from the outermost to the innermost, i.e., residualStyleStack will end up pointing
- // to the outermost tag we need to reopen.
- // We also set elem->node to be the actual element that corresponds to the ID stored in
- // elem->id rather than the node that you should pop to when the element gets pulled off
- // the stack.
- if (residualStyleStack && elem->tagName == residualStyleStack->tagName && elem->node->attributes()->mapsEquivalent(residualStyleStack->node->attributes()))
- redundantStyleCount++;
- else
- redundantStyleCount = 0;
-
- if (redundantStyleCount < cMaxRedundantTagDepth)
- moveOneBlockToStack(residualStyleStack);
- else
- popOneBlock();
- } else
- popOneBlock();
- elem = m_blockStack;
- }
- }
-
- reopenResidualStyleTags(residualStyleStack, malformedTableParent);
-}
-
-inline HTMLStackElem* LegacyHTMLTreeBuilder::popOneBlockCommon()
-{
- HTMLStackElem* elem = m_blockStack;
-
- // Form elements restore their state during the parsing process.
- // Also, a few elements (<applet>, <object>) need to know when all child elements (<param>s) are available.
- if (m_current && elem->node != m_current)
- m_current->finishParsingChildren();
-
- if (m_blockStack->level >= minBlockLevelTagPriority) {
- ASSERT(m_blocksInStack > 0);
- m_blocksInStack--;
- }
- m_treeDepth--;
- m_blockStack = elem->next;
- m_current = elem->node;
- m_didRefCurrent = elem->didRefNode;
-
- if (elem->strayTableContent)
- m_inStrayTableContent--;
-
- if (elem->tagName == pTag)
- m_hasPElementInScope = NotInScope;
- else if (isScopingTag(elem->tagName))
- m_hasPElementInScope = Unknown;
-
- return elem;
-}
-
-void LegacyHTMLTreeBuilder::popOneBlock()
-{
- // Store the current node before popOneBlockCommon overwrites it.
- Node* lastCurrent = m_current;
- bool didRefLastCurrent = m_didRefCurrent;
-
- delete popOneBlockCommon();
-
- if (didRefLastCurrent)
- lastCurrent->deref();
-}
-
-void LegacyHTMLTreeBuilder::moveOneBlockToStack(HTMLStackElem*& head)
-{
- // We'll be using the stack element we're popping, but for the current node.
- // See the two callers for details.
-
- // Store the current node before popOneBlockCommon overwrites it.
- Node* lastCurrent = m_current;
- bool didRefLastCurrent = m_didRefCurrent;
-
- // Pop the block, but don't deref the current node as popOneBlock does because
- // we'll be using the pointer in the new stack element.
- HTMLStackElem* elem = popOneBlockCommon();
-
- // Transfer the current node into the stack element.
- // No need to deref the old elem->node because popOneBlockCommon transferred
- // it into the m_current/m_didRefCurrent fields.
- elem->node = lastCurrent;
- elem->didRefNode = didRefLastCurrent;
- elem->next = head;
- head = elem;
-}
-
-void LegacyHTMLTreeBuilder::checkIfHasPElementInScope()
-{
- m_hasPElementInScope = NotInScope;
- HTMLStackElem* elem = m_blockStack;
- while (elem) {
- const AtomicString& tagName = elem->tagName;
- if (tagName == pTag) {
- m_hasPElementInScope = InScope;
- return;
- } else if (isScopingTag(tagName))
- return;
- elem = elem->next;
- }
-}
-
-void LegacyHTMLTreeBuilder::popInlineBlocks()
-{
- while (m_blockStack && isInline(m_current))
- popOneBlock();
-}
-
-void LegacyHTMLTreeBuilder::freeBlock()
-{
- while (m_blockStack)
- popOneBlock();
- ASSERT(!m_blocksInStack);
- ASSERT(!m_treeDepth);
-}
-
-void LegacyHTMLTreeBuilder::createHead()
-{
- if (m_head)
- return;
-
- if (!m_document->documentElement() && !m_isParsingFragment) {
- insertNode(HTMLHtmlElement::create(m_document).get());
- ASSERT(m_document->documentElement() || m_isParsingFragment);
- }
-
- m_head = HTMLHeadElement::create(m_document);
-
- if (m_isParsingFragment)
- return;
-
- HTMLElement* body = m_document->body();
- ExceptionCode ec = 0;
- m_document->documentElement()->insertBefore(m_head.get(), body, ec);
- if (ec)
- m_head = 0;
-
- // If the body does not exist yet, then the <head> should be pushed as the current block.
- if (m_head && !body) {
- pushBlock(m_head->localName(), m_head->tagPriority());
- setCurrent(m_head.get());
- }
-}
-
-PassRefPtr<Node> LegacyHTMLTreeBuilder::handleIsindex(Token* t)
-{
- RefPtr<Node> n = HTMLDivElement::create(m_document);
-
- NamedNodeMap* attrs = t->attrs.get();
-
- RefPtr<HTMLIsIndexElement> isIndex = HTMLIsIndexElement::create(m_document, m_currentFormElement.get());
- isIndex->setAttributeMap(attrs);
- isIndex->setAttribute(typeAttr, "khtml_isindex");
-
- String text = searchableIndexIntroduction();
- if (attrs) {
- if (Attribute* a = attrs->getAttributeItem(promptAttr))
- text = a->value().string() + " ";
- t->attrs = 0;
- }
-
- n->legacyParserAddChild(HTMLHRElement::create(m_document));
- n->legacyParserAddChild(Text::create(m_document, text));
- n->legacyParserAddChild(isIndex.release());
- n->legacyParserAddChild(HTMLHRElement::create(m_document));
-
- return n.release();
-}
-
-void LegacyHTMLTreeBuilder::startBody()
-{
- if (m_inBody)
- return;
-
- m_inBody = true;
-
- if (m_isindexElement) {
- insertNode(m_isindexElement.get(), true /* don't descend into this node */);
- m_isindexElement = 0;
- }
-}
-
-void LegacyHTMLTreeBuilder::finished()
-{
- // In the case of a completely empty document, here's the place to create the HTML element.
- if (m_current && m_current->isDocumentNode() && !m_document->documentElement())
- insertNode(HTMLHtmlElement::create(m_document).get());
-
- // This ensures that "current" is not left pointing to a node when the document is destroyed.
- freeBlock();
- setCurrent(0);
-
- // Warning, this may delete the parser, so don't try to do anything else after this.
- if (!m_isParsingFragment)
- m_document->finishedParsing();
-}
-
-void LegacyHTMLTreeBuilder::reportErrorToConsole(HTMLParserErrorCode errorCode, const AtomicString* tagName1, const AtomicString* tagName2, bool closeTags)
-{
- Frame* frame = m_document->frame();
- if (!frame)
- return;
-
- ScriptableDocumentParser* parser = m_document->scriptableDocumentParser();
- int lineNumber = parser->lineNumber() + 1;
-
- AtomicString tag1;
- AtomicString tag2;
- if (tagName1) {
- if (*tagName1 == "#text")
- tag1 = "Text";
- else if (*tagName1 == "#comment")
- tag1 = "<!-- comment -->";
- else
- tag1 = (closeTags ? "</" : "<") + *tagName1 + ">";
- }
- if (tagName2) {
- if (*tagName2 == "#text")
- tag2 = "Text";
- else if (*tagName2 == "#comment")
- tag2 = "<!-- comment -->";
- else
- tag2 = (closeTags ? "</" : "<") + *tagName2 + ">";
- }
-
- const char* errorMsg = htmlParserErrorMessageTemplate(errorCode);
- if (!errorMsg)
- return;
-
- String message;
- if (parser->processingContentWrittenByScript())
- message += htmlParserDocumentWriteMessage();
- message += errorMsg;
- message.replace("%tag1", tag1);
- message.replace("%tag2", tag2);
-
- frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType,
- isWarning(errorCode) ? WarningMessageLevel : ErrorMessageLevel,
- message, lineNumber, m_document->url().string());
-}
-
-#ifdef BUILDING_ON_LEOPARD
-bool shouldCreateImplicitHead(Document* document)
-{
- ASSERT(document);
-
- Settings* settings = document->page() ? document->page()->settings() : 0;
- return settings ? !settings->needsLeopardMailQuirks() : true;
-}
-#elif defined(BUILDING_ON_TIGER)
-bool shouldCreateImplicitHead(Document* document)
-{
- ASSERT(document);
-
- Settings* settings = document->page() ? document->page()->settings() : 0;
- return settings ? !settings->needsTigerMailQuirks() : true;
-}
-#endif
-
-
-String serializeForNumberType(double number)
-{
- // According to HTML5, "the best representation of the number n as a floating
- // point number" is a string produced by applying ToString() to n.
- DtoaBuffer buffer;
- unsigned length;
- doubleToStringInJavaScriptFormat(number, buffer, &length);
- return String(buffer, length);
-}
-
-bool parseToDoubleForNumberType(const String& src, double* out)
-{
- // See HTML5 2.4.4.3 `Real numbers.'
-
- if (src.isEmpty())
- return false;
- // String::toDouble() accepts leading + \t \n \v \f \r and SPACE, which are invalid in HTML5.
- // So, check the first character.
- if (src[0] != '-' && (src[0] < '0' || src[0] > '9'))
- return false;
-
- bool valid = false;
- double value = src.toDouble(&valid);
- if (!valid)
- return false;
- // NaN and Infinity are not valid numbers according to the standard.
- if (!isfinite(value))
- return false;
- // -0 -> 0
- if (!value)
- value = 0;
- if (out)
- *out = value;
- return true;
-}
-
-}
diff --git a/WebCore/html/LegacyHTMLTreeBuilder.h b/WebCore/html/LegacyHTMLTreeBuilder.h
deleted file mode 100644
index ed2b857..0000000
--- a/WebCore/html/LegacyHTMLTreeBuilder.h
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- Copyright (C) 1997 Martin Jones (mjones@kde.org)
- (C) 1997 Torben Weis (weis@kde.org)
- (C) 1998 Waldo Bastian (bastian@kde.org)
- (C) 1999 Lars Knoll (knoll@kde.org)
- Copyright (C) 2004, 2005, 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
- 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 LegacyHTMLTreeBuilder_h
-#define LegacyHTMLTreeBuilder_h
-
-#include "FragmentScriptingPermission.h"
-#include "HTMLParserErrorCodes.h"
-#include "NamedNodeMap.h"
-#include "QualifiedName.h"
-#include <wtf/Forward.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class DoctypeToken;
-class Document;
-class DocumentFragment;
-class HTMLDocument;
-class HTMLFormElement;
-class HTMLHeadElement;
-class HTMLMapElement;
-class HTMLParserQuirks;
-class Node;
-
-struct HTMLStackElem;
-
-/**
- * @internal
- * represents one HTML tag. Consists of a numerical id, and the list
- * of attributes. Can also represent text. In this case the id = 0 and
- * text contains the text.
- */
-struct Token {
- Token()
- : beginTag(true)
- , selfClosingTag(false)
- , brokenXMLStyle(false)
- , m_sourceInfo(0)
- { }
- ~Token() { }
-
- void addAttribute(AtomicString& attrName, const AtomicString& v, bool viewSourceMode);
-
- bool isOpenTag(const QualifiedName& fullName) const { return beginTag && fullName.localName() == tagName; }
- bool isCloseTag(const QualifiedName& fullName) const { return !beginTag && fullName.localName() == tagName; }
-
- void reset()
- {
- attrs = 0;
- text = 0;
- tagName = nullAtom;
- beginTag = true;
- selfClosingTag = false;
- brokenXMLStyle = false;
- if (m_sourceInfo)
- m_sourceInfo->clear();
- }
-
- void addViewSourceChar(UChar c)
- {
- if (!m_sourceInfo.get())
- m_sourceInfo.set(new Vector<UChar>);
- m_sourceInfo->append(c);
- }
-
- RefPtr<NamedNodeMap> attrs;
- RefPtr<StringImpl> text;
- AtomicString tagName;
- bool beginTag;
- bool selfClosingTag;
- bool brokenXMLStyle;
- OwnPtr<Vector<UChar> > m_sourceInfo;
-};
-
-enum DoctypeState {
- DoctypeBegin,
- DoctypeBeforeName,
- DoctypeName,
- DoctypeAfterName,
- DoctypeBeforePublicID,
- DoctypePublicID,
- DoctypeAfterPublicID,
- DoctypeBeforeSystemID,
- DoctypeSystemID,
- DoctypeAfterSystemID,
- DoctypeBogus
-};
-
-class DoctypeToken {
-public:
- DoctypeToken() {}
-
- void reset()
- {
- m_name.clear();
- m_publicID.clear();
- m_systemID.clear();
- m_state = DoctypeBegin;
- m_source.clear();
- m_forceQuirks = false;
- }
-
- DoctypeState state() { return m_state; }
- void setState(DoctypeState s) { m_state = s; }
-
- Vector<UChar> m_name;
- Vector<UChar> m_publicID;
- Vector<UChar> m_systemID;
- DoctypeState m_state;
-
- Vector<UChar> m_source;
-
- bool m_forceQuirks; // Used by the HTML5 parser.
-};
-
-//-----------------------------------------------------------------------------
-
-/**
- * The parser for HTML. It receives a stream of tokens from the LegacyHTMLDocumentParser, and
- * builds up the Document structure from it.
- */
-class LegacyHTMLTreeBuilder : public Noncopyable {
-public:
- LegacyHTMLTreeBuilder(HTMLDocument*, bool reportErrors);
- LegacyHTMLTreeBuilder(DocumentFragment*, FragmentScriptingPermission = FragmentScriptingAllowed);
- virtual ~LegacyHTMLTreeBuilder();
-
- /**
- * parses one token delivered by the tokenizer
- */
- PassRefPtr<Node> parseToken(Token*);
-
- // Parses a doctype token.
- void parseDoctypeToken(DoctypeToken*);
-
- /**
- * tokenizer says it's not going to be sending us any more tokens
- */
- void finished();
-
- /**
- * resets the parser
- */
- void reset();
-
- bool skipMode() const { return !m_skipModeTag.isNull(); }
- bool isHandlingResidualStyleAcrossBlocks() const { return m_handlingResidualStyleAcrossBlocks; }
-
-private:
- void setCurrent(Node*);
- void derefCurrent();
- void setSkipMode(const QualifiedName& qName) { m_skipModeTag = qName.localName(); }
-
- PassRefPtr<Node> getNode(Token*);
- bool bodyCreateErrorCheck(Token*, RefPtr<Node>&);
- bool canvasCreateErrorCheck(Token*, RefPtr<Node>&);
- bool colCreateErrorCheck(Token*, RefPtr<Node>&);
- bool commentCreateErrorCheck(Token*, RefPtr<Node>&);
- bool ddCreateErrorCheck(Token*, RefPtr<Node>&);
- bool dtCreateErrorCheck(Token*, RefPtr<Node>&);
- bool formCreateErrorCheck(Token*, RefPtr<Node>&);
- bool framesetCreateErrorCheck(Token*, RefPtr<Node>&);
- bool headCreateErrorCheck(Token*, RefPtr<Node>&);
- bool iframeCreateErrorCheck(Token*, RefPtr<Node>&);
- bool isindexCreateErrorCheck(Token*, RefPtr<Node>&);
- bool mapCreateErrorCheck(Token*, RefPtr<Node>&);
- bool nestedCreateErrorCheck(Token*, RefPtr<Node>&);
- bool nestedPCloserCreateErrorCheck(Token*, RefPtr<Node>&);
- bool nestedStyleCreateErrorCheck(Token*, RefPtr<Node>&);
- bool noembedCreateErrorCheck(Token*, RefPtr<Node>&);
- bool noframesCreateErrorCheck(Token*, RefPtr<Node>&);
- bool nolayerCreateErrorCheck(Token*, RefPtr<Node>&);
- 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>&);
- bool textCreateErrorCheck(Token*, RefPtr<Node>&);
-
- void processCloseTag(Token*);
-
- void limitDepth(int tagPriority);
- bool insertNodeAfterLimitDepth(Node*, bool flat = false);
- bool insertNode(Node*, bool flat = false);
- bool handleError(Node*, bool flat, const AtomicString& localName, int tagPriority);
-
- void pushBlock(const AtomicString& tagName, int level);
- void popBlock(const AtomicString& tagName, bool reportErrors = false);
- void popBlock(const QualifiedName& qName, bool reportErrors = false) { return popBlock(qName.localName(), reportErrors); } // Convenience function for readability.
- void popOneBlock();
- void moveOneBlockToStack(HTMLStackElem*& head);
- inline HTMLStackElem* popOneBlockCommon();
- void popInlineBlocks();
-
- void freeBlock();
-
- void createHead();
-
- static bool isResidualStyleTag(const AtomicString& tagName);
- static bool isAffectedByResidualStyle(const AtomicString& tagName);
- void handleResidualStyleCloseTagAcrossBlocks(HTMLStackElem*);
- void reopenResidualStyleTags(HTMLStackElem*, Node* malformedTableParent);
-
- bool allowNestedRedundantTag(const AtomicString& tagName);
-
- static bool isHeadingTag(const AtomicString& tagName);
-
- bool isInline(Node*) const;
-
- void startBody(); // inserts the isindex element
- PassRefPtr<Node> handleIsindex(Token*);
-
- void checkIfHasPElementInScope();
- bool hasPElementInScope()
- {
- if (m_hasPElementInScope == Unknown)
- checkIfHasPElementInScope();
- return m_hasPElementInScope == InScope;
- }
-
- void reportError(HTMLParserErrorCode errorCode, const AtomicString* tagName1 = 0, const AtomicString* tagName2 = 0, bool closeTags = false)
- { if (!m_reportErrors) return; reportErrorToConsole(errorCode, tagName1, tagName2, closeTags); }
-
- void reportErrorToConsole(HTMLParserErrorCode, const AtomicString* tagName1, const AtomicString* tagName2, bool closeTags);
-
- Document* m_document;
-
- // The currently active element (the one new elements will be added to). Can be a document fragment, a document or an element.
- Node* m_current;
- // We can't ref a document, but we don't want to constantly check if a node is a document just to decide whether to deref.
- bool m_didRefCurrent;
-
- HTMLStackElem* m_blockStack;
-
- // The number of tags with priority minBlockLevelTagPriority or higher
- // currently in m_blockStack. The parser enforces a cap on this value by
- // adding such new elements as siblings instead of children once it is reached.
- size_t m_blocksInStack;
- // Depth of the tree.
- unsigned m_treeDepth;
-
- enum ElementInScopeState { NotInScope, InScope, Unknown };
- ElementInScopeState m_hasPElementInScope;
-
- RefPtr<HTMLFormElement> m_currentFormElement; // currently active form
- RefPtr<HTMLMapElement> m_currentMapElement; // current map
- RefPtr<HTMLHeadElement> m_head; // head element; needed for HTML which defines <base> after </head>
- RefPtr<Node> m_isindexElement; // a possible <isindex> element in the head
-
- bool m_inBody;
- bool m_haveContent;
- bool m_haveFrameSet;
-
- AtomicString m_skipModeTag; // tells the parser to discard all tags until it reaches the one specified
-
- bool m_isParsingFragment;
- bool m_reportErrors;
- bool m_handlingResidualStyleAcrossBlocks;
- int m_inStrayTableContent;
- FragmentScriptingPermission m_scriptingPermission;
-
- OwnPtr<HTMLParserQuirks> m_parserQuirks;
-};
-
-#if defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_TIGER)
-bool shouldCreateImplicitHead(Document*);
-#else
-inline bool shouldCreateImplicitHead(Document*) { return true; }
-#endif
-
-// Converts the specified string to a floating number.
-// If the conversion fails, the return value is false. Take care that leading or trailing unnecessary characters make failures. This returns false for an empty string input.
-// The double* parameter may be 0.
-bool parseToDoubleForNumberType(const String&, double*);
-// Converts the specified number to a string. This is an implementation of
-// HTML5's "algorithm to convert a number to a string" for NUMBER/RANGE types.
-String serializeForNumberType(double);
-
-}
-
-#endif // LegacyHTMLTreeBuilder_h
diff --git a/WebCore/html/StepRange.cpp b/WebCore/html/StepRange.cpp
index 9afde1b..aeaf62f 100644
--- a/WebCore/html/StepRange.cpp
+++ b/WebCore/html/StepRange.cpp
@@ -23,7 +23,7 @@
#include "HTMLInputElement.h"
#include "HTMLNames.h"
-#include "LegacyHTMLTreeBuilder.h"
+#include "HTMLTreeBuilder.h"
#include "PlatformString.h"
#include <wtf/MathExtras.h>
diff --git a/WebCore/html/ThreadableBlobRegistry.cpp b/WebCore/html/ThreadableBlobRegistry.cpp
index 1df290d..d92d570 100644
--- a/WebCore/html/ThreadableBlobRegistry.cpp
+++ b/WebCore/html/ThreadableBlobRegistry.cpp
@@ -56,7 +56,7 @@ static void postTaskToMainThread(ScriptExecutionContext* scriptExecutionContext,
static void registerBlobURLTask(ScriptExecutionContext*, const KURL& url, PassOwnPtr<BlobData> blobData)
{
- BlobRegistry::instance().registerBlobURL(url, blobData);
+ blobRegistry().registerBlobURL(url, blobData);
}
void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext* scriptExecutionContext, const KURL& url, PassOwnPtr<BlobData> blobData)
@@ -69,7 +69,7 @@ void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext* scriptExecu
static void registerBlobURLFromTask(ScriptExecutionContext*, const KURL& url, const KURL& srcURL)
{
- BlobRegistry::instance().registerBlobURL(url, srcURL);
+ blobRegistry().registerBlobURL(url, srcURL);
}
void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext* scriptExecutionContext, const KURL& url, const KURL& srcURL)
@@ -82,7 +82,7 @@ void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext* scriptExecu
static void unregisterBlobURLTask(ScriptExecutionContext*, const KURL& url)
{
- BlobRegistry::instance().unregisterBlobURL(url);
+ blobRegistry().unregisterBlobURL(url);
}
void ThreadableBlobRegistry::unregisterBlobURL(ScriptExecutionContext* scriptExecutionContext, const KURL& url)
diff --git a/WebCore/html/ValidityState.cpp b/WebCore/html/ValidityState.cpp
index e286b64..0c25dac 100644
--- a/WebCore/html/ValidityState.cpp
+++ b/WebCore/html/ValidityState.cpp
@@ -26,7 +26,7 @@
#include "HTMLInputElement.h"
#include "HTMLNames.h"
-#include "LegacyHTMLTreeBuilder.h"
+#include "HTMLTreeBuilder.h"
#include "KURL.h"
#include "LocalizedStrings.h"
#include "RegularExpression.h"
diff --git a/WebCore/html/ValidityState.h b/WebCore/html/ValidityState.h
index 04f11a1..eecb9be 100644
--- a/WebCore/html/ValidityState.h
+++ b/WebCore/html/ValidityState.h
@@ -33,7 +33,7 @@ class ValidityState : public Noncopyable {
public:
static PassOwnPtr<ValidityState> create(HTMLFormControlElement* control)
{
- return new ValidityState(control);
+ return adoptPtr(new ValidityState(control));
}
void ref() { m_control->ref(); }
diff --git a/WebCore/html/canvas/CanvasRenderingContext.cpp b/WebCore/html/canvas/CanvasRenderingContext.cpp
index fed8cb2..1e897d3 100644
--- a/WebCore/html/canvas/CanvasRenderingContext.cpp
+++ b/WebCore/html/canvas/CanvasRenderingContext.cpp
@@ -25,7 +25,9 @@
#include "config.h"
#include "CanvasRenderingContext.h"
-
+#if ENABLE(ACCELERATED_2D_CANVAS) || ENABLE(3D_CANVAS)
+#include "GraphicsContext3D.h"
+#endif
#include "HTMLCanvasElement.h"
namespace WebCore {
@@ -45,4 +47,13 @@ void CanvasRenderingContext::deref()
m_canvas->deref();
}
+bool CanvasRenderingContext::paintsIntoCanvasBuffer() const
+{
+#if ENABLE(ACCELERATED_2D_CANVAS) || ENABLE(3D_CANVAS)
+ if (GraphicsContext3D* context3D = graphicsContext3D())
+ return context3D->paintsIntoCanvasBuffer();
+#endif
+ return true;
+}
+
} // namespace WebCore
diff --git a/WebCore/html/canvas/CanvasRenderingContext.h b/WebCore/html/canvas/CanvasRenderingContext.h
index cb26363..2cdbe1d 100644
--- a/WebCore/html/canvas/CanvasRenderingContext.h
+++ b/WebCore/html/canvas/CanvasRenderingContext.h
@@ -54,6 +54,7 @@ namespace WebCore {
virtual GraphicsContext3D* graphicsContext3D() const { return 0; }
virtual void paintRenderingResultsToCanvas() {}
+ bool paintsIntoCanvasBuffer() const;
private:
HTMLCanvasElement* m_canvas;
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
index 58ec1d0..2a7b96a 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
@@ -1451,7 +1451,7 @@ PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageEleme
if (!cachedImage || !image->cachedImage()->image())
return CanvasPattern::create(Image::nullImage(), repeatX, repeatY, true);
- bool originClean = !canvas()->securityOrigin().taintsCanvas(KURL(KURL(), cachedImage->url())) && cachedImage->image()->hasSingleSecurityOrigin();
+ bool originClean = !canvas()->securityOrigin().taintsCanvas(KURL(KURL(), cachedImage->response().url())) && cachedImage->image()->hasSingleSecurityOrigin();
return CanvasPattern::create(cachedImage->image(), repeatX, repeatY, originClean);
}
@@ -1727,7 +1727,19 @@ void CanvasRenderingContext2D::strokeText(const String& text, float x, float y,
PassRefPtr<TextMetrics> CanvasRenderingContext2D::measureText(const String& text)
{
RefPtr<TextMetrics> metrics = TextMetrics::create();
+
+#if PLATFORM(QT)
+ // We always use complex text shaping since it can't be turned off for QPainterPath::addText().
+ Font::CodePath oldCodePath = Font::codePath();
+ Font::setCodePath(Font::Complex);
+#endif
+
metrics->setWidth(accessFont().width(TextRun(text.characters(), text.length())));
+
+#if PLATFORM(QT)
+ Font::setCodePath(oldCodePath);
+#endif
+
return metrics;
}
@@ -1838,7 +1850,18 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
#endif
c->setTextDrawingMode(fill ? cTextFill : cTextStroke);
+
+#if PLATFORM(QT)
+ // We always use complex text shaping since it can't be turned off for QPainterPath::addText().
+ Font::CodePath oldCodePath = Font::codePath();
+ Font::setCodePath(Font::Complex);
+#endif
+
c->drawBidiText(font, textRun, location);
+
+#if PLATFORM(QT)
+ Font::setCodePath(oldCodePath);
+#endif
}
const Font& CanvasRenderingContext2D::accessFont()
@@ -1851,7 +1874,8 @@ const Font& CanvasRenderingContext2D::accessFont()
void CanvasRenderingContext2D::paintRenderingResultsToCanvas()
{
#if ENABLE(ACCELERATED_2D_CANVAS)
- drawingContext()->syncSoftwareCanvas();
+ if (GraphicsContext* c = drawingContext())
+ c->syncSoftwareCanvas();
#endif
}
diff --git a/WebCore/html/canvas/Float32Array.cpp b/WebCore/html/canvas/Float32Array.cpp
index c95fb48..e6e8439 100644
--- a/WebCore/html/canvas/Float32Array.cpp
+++ b/WebCore/html/canvas/Float32Array.cpp
@@ -37,7 +37,7 @@ PassRefPtr<Float32Array> Float32Array::create(unsigned length)
return TypedArrayBase<float>::create<Float32Array>(length);
}
-PassRefPtr<Float32Array> Float32Array::create(float* array, unsigned length)
+PassRefPtr<Float32Array> Float32Array::create(const float* array, unsigned length)
{
return TypedArrayBase<float>::create<Float32Array>(array, length);
}
diff --git a/WebCore/html/canvas/Float32Array.h b/WebCore/html/canvas/Float32Array.h
index 8112264..ab57087 100644
--- a/WebCore/html/canvas/Float32Array.h
+++ b/WebCore/html/canvas/Float32Array.h
@@ -35,7 +35,7 @@ namespace WebCore {
class Float32Array : public TypedArrayBase<float> {
public:
static PassRefPtr<Float32Array> create(unsigned length);
- static PassRefPtr<Float32Array> create(float* array, unsigned length);
+ static PassRefPtr<Float32Array> create(const float* array, unsigned length);
static PassRefPtr<Float32Array> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length);
using TypedArrayBase<float>::set;
diff --git a/WebCore/html/canvas/TypedArrayBase.h b/WebCore/html/canvas/TypedArrayBase.h
index c55896b..e69c2b5 100644
--- a/WebCore/html/canvas/TypedArrayBase.h
+++ b/WebCore/html/canvas/TypedArrayBase.h
@@ -67,7 +67,7 @@ class TypedArrayBase : public ArrayBufferView {
}
template <class Subclass>
- static PassRefPtr<Subclass> create(T* array, unsigned length)
+ static PassRefPtr<Subclass> create(const T* array, unsigned length)
{
RefPtr<Subclass> a = create<Subclass>(length);
if (a)
diff --git a/WebCore/html/canvas/WebGLBuffer.cpp b/WebCore/html/canvas/WebGLBuffer.cpp
index fc98a9d..d43868d 100644
--- a/WebCore/html/canvas/WebGLBuffer.cpp
+++ b/WebCore/html/canvas/WebGLBuffer.cpp
@@ -29,6 +29,7 @@
#include "WebGLBuffer.h"
+#include "ArrayBufferView.h"
#include "CheckedInt.h"
#include "WebGLRenderingContext.h"
diff --git a/WebCore/html/canvas/WebGLBuffer.h b/WebCore/html/canvas/WebGLBuffer.h
index a7a25b9..f18a9bf 100644
--- a/WebCore/html/canvas/WebGLBuffer.h
+++ b/WebCore/html/canvas/WebGLBuffer.h
@@ -33,6 +33,7 @@
#include <wtf/RefCounted.h>
namespace WebCore {
+class ArrayBufferView;
class WebGLBuffer : public WebGLObject {
public:
diff --git a/WebCore/html/canvas/WebGLFramebuffer.cpp b/WebCore/html/canvas/WebGLFramebuffer.cpp
index bfa08b7..6291705 100644
--- a/WebCore/html/canvas/WebGLFramebuffer.cpp
+++ b/WebCore/html/canvas/WebGLFramebuffer.cpp
@@ -101,7 +101,7 @@ unsigned long WebGLFramebuffer::getColorBufferFormat()
return GraphicsContext3D::RGB;
}
} else if (m_colorAttachment->isTexture())
- return (reinterpret_cast<WebGLTexture*>(m_colorAttachment))->getInternalFormat();
+ return (reinterpret_cast<WebGLTexture*>(m_colorAttachment))->getInternalFormat(0);
}
return 0;
}
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 4465833..44d3e08 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -36,8 +36,10 @@
#include "FrameView.h"
#include "HTMLCanvasElement.h"
#include "HTMLImageElement.h"
+#include "HTMLVideoElement.h"
#include "ImageBuffer.h"
#include "ImageData.h"
+#include "IntSize.h"
#include "NotImplemented.h"
#include "RenderBox.h"
#include "RenderLayer.h"
@@ -98,6 +100,7 @@ WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
, m_needsUpdate(true)
, m_markedCanvasDirty(false)
, m_activeTextureUnit(0)
+ , m_videoCache(4)
, m_packAlignment(4)
, m_unpackAlignment(4)
, m_unpackFlipY(false)
@@ -127,10 +130,10 @@ WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
m_context->getIntegerv(GraphicsContext3D::MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTextureSize);
m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextureSize, m_maxCubeMapTextureSize);
- if (!isGLES2Compliant()) {
+ if (!isGLES2NPOTStrict())
createFallbackBlackTextures1x1();
+ if (!isGLES2Compliant())
initVertexAttrib0();
- }
m_context->reshape(canvas()->width(), canvas()->height());
m_context->viewport(0, 0, canvas()->width(), canvas()->height());
}
@@ -303,7 +306,7 @@ void WebGLRenderingContext::bindTexture(unsigned long target, WebGLTexture* text
return;
}
m_context->bindTexture(target, objectOrZero(texture));
- if (!isGLES2Compliant() && texture)
+ if (texture)
texture->setTarget(target, maxLevel);
// FIXME: do we want to do this on all platforms?
@@ -335,20 +338,16 @@ void WebGLRenderingContext::blendColor(double red, double green, double blue, do
void WebGLRenderingContext::blendEquation(unsigned long mode)
{
- if (!isGLES2Compliant()) {
- if (!validateBlendEquation(mode))
- return;
- }
+ if (!validateBlendEquation(mode))
+ return;
m_context->blendEquation(mode);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha)
{
- if (!isGLES2Compliant()) {
- if (!validateBlendEquation(modeRGB) || !validateBlendEquation(modeAlpha))
- return;
- }
+ if (!validateBlendEquation(modeRGB) || !validateBlendEquation(modeAlpha))
+ return;
m_context->blendEquationSeparate(modeRGB, modeAlpha);
cleanupAfterGraphicsCall(false);
}
@@ -372,9 +371,11 @@ void WebGLRenderingContext::bufferData(unsigned long target, int size, unsigned
WebGLBuffer* buffer = validateBufferDataParameters(target, usage);
if (!buffer)
return;
- if (!buffer->associateBufferData(size)) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
+ if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+ if (!buffer->associateBufferData(size)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
}
m_context->bufferData(target, size, usage);
@@ -387,12 +388,14 @@ void WebGLRenderingContext::bufferData(unsigned long target, ArrayBuffer* data,
WebGLBuffer* buffer = validateBufferDataParameters(target, usage);
if (!buffer)
return;
- if (!buffer->associateBufferData(data)) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
+ if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+ if (!buffer->associateBufferData(data)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
}
- m_context->bufferData(target, data, usage);
+ m_context->bufferData(target, data->byteLength(), data->data(), usage);
cleanupAfterGraphicsCall(false);
}
@@ -402,12 +405,14 @@ void WebGLRenderingContext::bufferData(unsigned long target, ArrayBufferView* da
WebGLBuffer* buffer = validateBufferDataParameters(target, usage);
if (!buffer)
return;
- if (!buffer->associateBufferData(data)) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
+ if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+ if (!buffer->associateBufferData(data)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
}
- m_context->bufferData(target, data, usage);
+ m_context->bufferData(target, data->byteLength(), data->baseAddress(), usage);
cleanupAfterGraphicsCall(false);
}
@@ -417,12 +422,14 @@ void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, Arr
WebGLBuffer* buffer = validateBufferDataParameters(target, GraphicsContext3D::STATIC_DRAW);
if (!buffer)
return;
- if (!buffer->associateBufferSubData(offset, data)) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
+ if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+ if (!buffer->associateBufferSubData(offset, data)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
}
- m_context->bufferSubData(target, offset, data);
+ m_context->bufferSubData(target, offset, data->byteLength(), data->data());
cleanupAfterGraphicsCall(false);
}
@@ -432,22 +439,22 @@ void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, Arr
WebGLBuffer* buffer = validateBufferDataParameters(target, GraphicsContext3D::STATIC_DRAW);
if (!buffer)
return;
- if (!buffer->associateBufferSubData(offset, data)) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
+ if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+ if (!buffer->associateBufferSubData(offset, data)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
}
- m_context->bufferSubData(target, offset, data);
+ m_context->bufferSubData(target, offset, data->byteLength(), data->baseAddress());
cleanupAfterGraphicsCall(false);
}
unsigned long WebGLRenderingContext::checkFramebufferStatus(unsigned long target)
{
- if (!isGLES2Compliant()) {
- if (target != GraphicsContext3D::FRAMEBUFFER) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
- return 0;
- }
+ if (target != GraphicsContext3D::FRAMEBUFFER) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return 0;
}
if (!m_framebufferBinding || !m_framebufferBinding->object())
return GraphicsContext3D::FRAMEBUFFER_COMPLETE;
@@ -457,11 +464,9 @@ unsigned long WebGLRenderingContext::checkFramebufferStatus(unsigned long target
void WebGLRenderingContext::clear(unsigned long mask)
{
- if (!isGLES2Compliant()) {
- if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
+ if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
}
m_context->clear(mask);
cleanupAfterGraphicsCall(true);
@@ -522,15 +527,14 @@ void WebGLRenderingContext::copyTexImage2D(unsigned long target, long level, uns
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
- if (level && WebGLTexture::isNPOT(width, height)) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return;
- }
+ }
+ if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
}
m_context->copyTexImage2D(target, level, internalformat, x, y, width, height, border);
// FIXME: if the framebuffer is not complete, none of the below should be executed.
- if (!isGLES2Compliant())
- tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
+ tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
if (m_framebufferBinding)
m_framebufferBinding->onAttachedObjectChange(tex);
cleanupAfterGraphicsCall(false);
@@ -543,7 +547,7 @@ void WebGLRenderingContext::copyTexSubImage2D(unsigned long target, long level,
return;
if (!isGLES2Compliant()) {
if (m_framebufferBinding && m_framebufferBinding->object()
- && !isTexInternalFormatColorBufferCombinationValid(tex->getInternalFormat(),
+ && !isTexInternalFormatColorBufferCombinationValid(tex->getInternalFormat(level),
m_framebufferBinding->getColorBufferFormat())) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
@@ -713,10 +717,8 @@ void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha
void WebGLRenderingContext::disable(unsigned long cap)
{
- if (!isGLES2Compliant()) {
- if (!validateCapability(cap))
- return;
- }
+ if (!validateCapability(cap))
+ return;
m_context->disable(cap);
cleanupAfterGraphicsCall(false);
}
@@ -916,26 +918,27 @@ void WebGLRenderingContext::drawArrays(unsigned long mode, long first, long coun
return;
}
- // Ensure we have a valid rendering state
- CheckedInt<int32_t> checkedFirst(first);
- CheckedInt<int32_t> checkedCount(count);
- CheckedInt<int32_t> checkedSum = checkedFirst + checkedCount;
- if (!checkedSum.valid() || !validateRenderingState(checkedSum.value())) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
+ if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+ // Ensure we have a valid rendering state
+ CheckedInt<int32_t> checkedFirst(first);
+ CheckedInt<int32_t> checkedCount(count);
+ CheckedInt<int32_t> checkedSum = checkedFirst + checkedCount;
+ if (!checkedSum.valid() || !validateRenderingState(checkedSum.value())) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ return;
+ }
}
bool vertexAttrib0Simulated = false;
- if (!isGLES2Compliant()) {
+ if (!isGLES2Compliant())
vertexAttrib0Simulated = simulateVertexAttrib0(first + count - 1);
+ if (!isGLES2NPOTStrict())
handleNPOTTextures(true);
- }
m_context->drawArrays(mode, first, count);
- if (!isGLES2Compliant()) {
+ if (!isGLES2Compliant() && vertexAttrib0Simulated)
+ restoreStatesAfterVertexAttrib0Simulation();
+ if (!isGLES2NPOTStrict())
handleNPOTTextures(false);
- if (vertexAttrib0Simulated)
- restoreStatesAfterVertexAttrib0Simulation();
- }
cleanupAfterGraphicsCall(true);
}
@@ -960,40 +963,41 @@ void WebGLRenderingContext::drawElements(unsigned long mode, long count, unsigne
return;
}
- // Ensure we have a valid rendering state
- long numElements;
-
- if (!validateElementArraySize(count, type, offset)) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
-
- if (!validateIndexArrayConservative(type, numElements) || !validateRenderingState(numElements))
- if (!validateIndexArrayPrecise(count, type, offset, numElements) || !validateRenderingState(numElements)) {
+ long numElements = 0;
+ if (!isErrorGeneratedOnOutOfBoundsAccesses()) {
+ // Ensure we have a valid rendering state
+ if (!validateElementArraySize(count, type, offset)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
+ if (!validateIndexArrayConservative(type, numElements) || !validateRenderingState(numElements)) {
+ if (!validateIndexArrayPrecise(count, type, offset, numElements) || !validateRenderingState(numElements)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ return;
+ }
+ }
+ }
bool vertexAttrib0Simulated = false;
if (!isGLES2Compliant()) {
+ if (!numElements)
+ validateIndexArrayPrecise(count, type, offset, numElements);
vertexAttrib0Simulated = simulateVertexAttrib0(numElements);
- handleNPOTTextures(true);
}
+ if (!isGLES2NPOTStrict())
+ handleNPOTTextures(true);
m_context->drawElements(mode, count, type, offset);
- if (!isGLES2Compliant()) {
+ if (!isGLES2Compliant() && vertexAttrib0Simulated)
+ restoreStatesAfterVertexAttrib0Simulation();
+ if (!isGLES2NPOTStrict())
handleNPOTTextures(false);
- if (vertexAttrib0Simulated)
- restoreStatesAfterVertexAttrib0Simulation();
- }
cleanupAfterGraphicsCall(true);
}
void WebGLRenderingContext::enable(unsigned long cap)
{
- if (!isGLES2Compliant()) {
- if (!validateCapability(cap))
- return;
- }
+ if (!validateCapability(cap))
+ return;
m_context->enable(cap);
cleanupAfterGraphicsCall(false);
}
@@ -1116,15 +1120,12 @@ void WebGLRenderingContext::generateMipmap(unsigned long target)
WebGLTexture* tex = validateTextureBinding(target, false);
if (!tex)
return;
- if (!isGLES2Compliant()) {
- if (!tex->canGenerateMipmaps()) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return;
- }
+ if (!tex->canGenerateMipmaps()) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ return;
}
m_context->generateMipmap(target);
- if (!isGLES2Compliant())
- tex->generateMipmapLevelInfo();
+ tex->generateMipmapLevelInfo();
cleanupAfterGraphicsCall(false);
}
@@ -1804,11 +1805,9 @@ long WebGLRenderingContext::getVertexAttribOffset(unsigned long index, unsigned
void WebGLRenderingContext::hint(unsigned long target, unsigned long mode)
{
- if (!isGLES2Compliant()) {
- if (target != GraphicsContext3D::GENERATE_MIPMAP_HINT) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
- return;
- }
+ if (target != GraphicsContext3D::GENERATE_MIPMAP_HINT) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return;
}
m_context->hint(target, mode);
cleanupAfterGraphicsCall(false);
@@ -1824,10 +1823,8 @@ bool WebGLRenderingContext::isBuffer(WebGLBuffer* buffer)
bool WebGLRenderingContext::isEnabled(unsigned long cap)
{
- if (!isGLES2Compliant()) {
- if (!validateCapability(cap))
- return false;
- }
+ if (!validateCapability(cap))
+ return false;
return m_context->isEnabled(cap);
}
@@ -2086,7 +2083,7 @@ void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsi
WebGLTexture* tex = validateTextureBinding(target, true);
if (!tex)
return;
- if (!isGLES2Compliant()) {
+ if (!isGLES2NPOTStrict()) {
if (level && WebGLTexture::isNPOT(width, height)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
@@ -2094,8 +2091,7 @@ void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsi
}
m_context->texImage2D(target, level, internalformat, width, height,
border, format, type, pixels);
- if (!isGLES2Compliant())
- tex->setLevelInfo(target, level, internalformat, width, height, type);
+ tex->setLevelInfo(target, level, internalformat, width, height, type);
if (m_framebufferBinding)
m_framebufferBinding->onAttachedObjectChange(tex);
cleanupAfterGraphicsCall(false);
@@ -2128,11 +2124,11 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned
void* data = pixels ? pixels->baseAddress() : 0;
Vector<uint8_t> tempData;
bool changeUnpackAlignment = false;
- if (pixels && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
+ if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
if (!m_context->extractTextureData(width, height, format, type,
m_unpackAlignment,
m_unpackFlipY, m_unpackPremultiplyAlpha,
- pixels,
+ data,
tempData))
return;
data = tempData.data();
@@ -2188,19 +2184,32 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned
m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
}
+PassRefPtr<Image> WebGLRenderingContext::videoFrameToImage(HTMLVideoElement* video)
+{
+ if (!video || !video->videoWidth() || !video->videoHeight()) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return 0;
+ }
+ IntSize size(video->videoWidth(), video->videoHeight());
+ ImageBuffer* buf = m_videoCache.imageBuffer(size);
+ if (!buf) {
+ m_context->synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY);
+ return 0;
+ }
+ IntRect destRect(0, 0, size.width(), size.height());
+ // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback.
+ video->paintCurrentFrameInContext(buf->context(), destRect);
+ return buf->copyImage();
+}
+
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat,
unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode& ec)
{
- // FIXME: Need to implement this call
- UNUSED_PARAM(target);
- UNUSED_PARAM(level);
- UNUSED_PARAM(internalformat);
- UNUSED_PARAM(format);
- UNUSED_PARAM(type);
- UNUSED_PARAM(video);
-
ec = 0;
- cleanupAfterGraphicsCall(false);
+ RefPtr<Image> image = videoFrameToImage(video);
+ if (!video)
+ return;
+ texImage2DImpl(target, level, internalformat, format, type, image.get(), m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
}
void WebGLRenderingContext::texParameter(unsigned long target, unsigned long pname, float paramf, int parami, bool isFloat)
@@ -2208,32 +2217,29 @@ void WebGLRenderingContext::texParameter(unsigned long target, unsigned long pna
WebGLTexture* tex = validateTextureBinding(target, false);
if (!tex)
return;
- if (!isGLES2Compliant()) {
- switch (pname) {
- case GraphicsContext3D::TEXTURE_MIN_FILTER:
- case GraphicsContext3D::TEXTURE_MAG_FILTER:
- break;
- case GraphicsContext3D::TEXTURE_WRAP_S:
- case GraphicsContext3D::TEXTURE_WRAP_T:
- if (isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT
- || !isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami != GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
- return;
- }
- break;
- default:
+ switch (pname) {
+ case GraphicsContext3D::TEXTURE_MIN_FILTER:
+ case GraphicsContext3D::TEXTURE_MAG_FILTER:
+ break;
+ case GraphicsContext3D::TEXTURE_WRAP_S:
+ case GraphicsContext3D::TEXTURE_WRAP_T:
+ if (isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT
+ || !isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami != GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
return;
}
- if (isFloat)
- tex->setParameterf(pname, paramf);
- else
- tex->setParameteri(pname, parami);
+ break;
+ default:
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return;
}
- if (isFloat)
+ if (isFloat) {
+ tex->setParameterf(pname, paramf);
m_context->texParameterf(target, pname, paramf);
- else
+ } else {
+ tex->setParameteri(pname, parami);
m_context->texParameteri(target, pname, parami);
+ }
cleanupAfterGraphicsCall(false);
}
@@ -2284,11 +2290,11 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsig
void* data = pixels ? pixels->baseAddress() : 0;
Vector<uint8_t> tempData;
bool changeUnpackAlignment = false;
- if (pixels && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
+ if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
if (!m_context->extractTextureData(width, height, format, type,
m_unpackAlignment,
m_unpackFlipY, m_unpackPremultiplyAlpha,
- pixels,
+ data,
tempData))
return;
data = tempData.data();
@@ -2342,16 +2348,11 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsig
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode& ec)
{
- // FIXME: Need to implement this call
- UNUSED_PARAM(target);
- UNUSED_PARAM(level);
- UNUSED_PARAM(xoffset);
- UNUSED_PARAM(yoffset);
- UNUSED_PARAM(format);
- UNUSED_PARAM(type);
- UNUSED_PARAM(video);
ec = 0;
- cleanupAfterGraphicsCall(false);
+ RefPtr<Image> image = videoFrameToImage(video);
+ if (!video)
+ return;
+ texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
}
void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, float x, ExceptionCode& ec)
@@ -2999,6 +3000,16 @@ bool WebGLRenderingContext::isGLES2Compliant()
return m_context->isGLES2Compliant();
}
+bool WebGLRenderingContext::isGLES2NPOTStrict()
+{
+ return m_context->isGLES2NPOTStrict();
+}
+
+bool WebGLRenderingContext::isErrorGeneratedOnOutOfBoundsAccesses()
+{
+ return m_context->isErrorGeneratedOnOutOfBoundsAccesses();
+}
+
void WebGLRenderingContext::handleNPOTTextures(bool prepareToDraw)
{
bool resetActiveUnit = false;
@@ -3536,14 +3547,14 @@ bool WebGLRenderingContext::simulateVertexAttrib0(long numVertex)
|| state.value[1] != m_vertexAttrib0BufferValue[1]
|| state.value[2] != m_vertexAttrib0BufferValue[2]
|| state.value[3] != m_vertexAttrib0BufferValue[3]) {
- RefPtr<Float32Array> bufferData = Float32Array::create((numVertex + 1) * 4);
+ OwnArrayPtr<float> bufferData(new float[(numVertex + 1) * 4]);
for (long ii = 0; ii < numVertex + 1; ++ii) {
- bufferData->set(ii * 4, state.value[0]);
- bufferData->set(ii * 4 + 1, state.value[1]);
- bufferData->set(ii * 4 + 2, state.value[2]);
- bufferData->set(ii * 4 + 3, state.value[3]);
+ bufferData[ii * 4] = state.value[0];
+ bufferData[ii * 4 + 1] = state.value[1];
+ bufferData[ii * 4 + 2] = state.value[2];
+ bufferData[ii * 4 + 3] = state.value[3];
}
- m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, bufferData.get(), GraphicsContext3D::DYNAMIC_DRAW);
+ m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, bufferDataSize, bufferData.get(), GraphicsContext3D::DYNAMIC_DRAW);
m_vertexAttrib0BufferSize = bufferDataSize;
m_vertexAttrib0BufferValue[0] = state.value[0];
m_vertexAttrib0BufferValue[1] = state.value[1];
@@ -3564,6 +3575,42 @@ void WebGLRenderingContext::restoreStatesAfterVertexAttrib0Simulation()
m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, objectOrZero(m_boundArrayBuffer.get()));
}
+WebGLRenderingContext::LRUImageBufferCache::LRUImageBufferCache(int capacity)
+ : m_buffers(new OwnPtr<ImageBuffer>[capacity])
+ , m_capacity(capacity)
+{
+}
+
+ImageBuffer* WebGLRenderingContext::LRUImageBufferCache::imageBuffer(const IntSize& size)
+{
+ int i;
+ for (i = 0; i < m_capacity; ++i) {
+ ImageBuffer* buf = m_buffers[i].get();
+ if (!buf)
+ break;
+ if (buf->size() != size)
+ continue;
+ bubbleToFront(i);
+ return buf;
+ }
+
+ OwnPtr<ImageBuffer> temp = ImageBuffer::create(size);
+ if (!temp)
+ return 0;
+ i = std::min(m_capacity - 1, i);
+ m_buffers[i] = temp.release();
+
+ ImageBuffer* buf = m_buffers[i].get();
+ bubbleToFront(i);
+ return buf;
+}
+
+void WebGLRenderingContext::LRUImageBufferCache::bubbleToFront(int idx)
+{
+ for (int i = idx; i > 0; --i)
+ m_buffers[i].swap(m_buffers[i-1]);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLRenderingContext.h b/WebCore/html/canvas/WebGLRenderingContext.h
index 48fa7c8..66ec8d8 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.h
+++ b/WebCore/html/canvas/WebGLRenderingContext.h
@@ -35,6 +35,8 @@
#include "Uint8Array.h"
#include "WebGLGetInfo.h"
+#include <wtf/OwnArrayPtr.h>
+
namespace WebCore {
class WebGLActiveInfo;
@@ -49,7 +51,9 @@ class WebGLTexture;
class WebGLUniformLocation;
class HTMLImageElement;
class HTMLVideoElement;
+class ImageBuffer;
class ImageData;
+class IntSize;
class WebKitCSSMatrix;
class WebGLRenderingContext : public CanvasRenderingContext {
@@ -281,8 +285,6 @@ public:
void removeObject(WebGLObject*);
- bool paintsIntoCanvasBuffer() const { return m_context->paintsIntoCanvasBuffer(); }
-
private:
friend class WebGLObject;
@@ -303,6 +305,8 @@ public:
}
bool isGLES2Compliant();
+ bool isGLES2NPOTStrict();
+ bool isErrorGeneratedOnOutOfBoundsAccesses();
// Helper to return the size in bytes of OpenGL data types
// like GL_FLOAT, GL_INT, etc.
@@ -320,6 +324,8 @@ public:
bool validateWebGLObject(WebGLObject* object);
+ PassRefPtr<Image> videoFrameToImage(HTMLVideoElement* video);
+
OwnPtr<GraphicsContext3D> m_context;
bool m_needsUpdate;
bool m_markedCanvasDirty;
@@ -387,6 +393,19 @@ public:
RefPtr<WebGLTexture> m_blackTexture2D;
RefPtr<WebGLTexture> m_blackTextureCubeMap;
+ // Fixed-size cache of reusable image buffers for video texImage2D calls.
+ class LRUImageBufferCache {
+ public:
+ LRUImageBufferCache(int capacity);
+ // The pointer returned is owned by the image buffer map.
+ ImageBuffer* imageBuffer(const IntSize& size);
+ private:
+ void bubbleToFront(int idx);
+ OwnArrayPtr<OwnPtr<ImageBuffer> > m_buffers;
+ int m_capacity;
+ };
+ LRUImageBufferCache m_videoCache;
+
int m_maxTextureSize;
int m_maxCubeMapTextureSize;
int m_maxTextureLevel;
diff --git a/WebCore/html/canvas/WebGLRenderingContext.idl b/WebCore/html/canvas/WebGLRenderingContext.idl
index 960dd0b..7a63752 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.idl
+++ b/WebCore/html/canvas/WebGLRenderingContext.idl
@@ -464,213 +464,210 @@ module html {
const unsigned int UNPACK_FLIP_Y_WEBGL = 0x9240;
const unsigned int UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241;
- void activeTexture(in unsigned long texture) raises(DOMException);
- void attachShader(in WebGLProgram program, in WebGLShader shader) raises(DOMException);
- void bindAttribLocation(in WebGLProgram program, in unsigned long index, in DOMString name) raises(DOMException);
- void bindBuffer(in unsigned long target, in WebGLBuffer buffer) raises(DOMException);
- void bindFramebuffer(in unsigned long target, in WebGLFramebuffer framebuffer) raises(DOMException);
- void bindRenderbuffer(in unsigned long target, in WebGLRenderbuffer renderbuffer) raises(DOMException);
- void bindTexture(in unsigned long target, in WebGLTexture texture) raises(DOMException);
- void blendColor(in double red, in double green, in double blue, in double alpha);
- void blendEquation( in unsigned long mode );
- void blendEquationSeparate(in unsigned long modeRGB, in unsigned long modeAlpha);
- void blendFunc(in unsigned long sfactor, in unsigned long dfactor);
- void blendFuncSeparate(in unsigned long srcRGB, in unsigned long dstRGB, in unsigned long srcAlpha, in unsigned long dstAlpha);
- void bufferData(in unsigned long target, in ArrayBuffer data, in unsigned long usage) raises (DOMException);
- void bufferData(in unsigned long target, in ArrayBufferView data, in unsigned long usage) raises (DOMException);
- void bufferData(in unsigned long target, in long size, in unsigned long usage) raises (DOMException);
- void bufferSubData(in unsigned long target, in long offset, in ArrayBuffer data) raises (DOMException);
- void bufferSubData(in unsigned long target, in long offset, in ArrayBufferView data) raises (DOMException);
-
- unsigned long checkFramebufferStatus(in unsigned long target);
- void clear(in unsigned long mask);
- void clearColor(in double red, in double green, in double blue, in double alpha);
- void clearDepth(in double depth);
- void clearStencil(in long s);
- void colorMask(in boolean red, in boolean green, in boolean blue, in boolean alpha);
- void compileShader(in WebGLShader shader) raises(DOMException);
+ [StrictTypeChecking] void activeTexture(in unsigned long texture) raises(DOMException);
+ [StrictTypeChecking] void attachShader(in WebGLProgram program, in WebGLShader shader) raises(DOMException);
+ [StrictTypeChecking] void bindAttribLocation(in WebGLProgram program, in unsigned long index, in DOMString name) raises(DOMException);
+ [StrictTypeChecking] void bindBuffer(in unsigned long target, in WebGLBuffer buffer) raises(DOMException);
+ [StrictTypeChecking] void bindFramebuffer(in unsigned long target, in WebGLFramebuffer framebuffer) raises(DOMException);
+ [StrictTypeChecking] void bindRenderbuffer(in unsigned long target, in WebGLRenderbuffer renderbuffer) raises(DOMException);
+ [StrictTypeChecking] void bindTexture(in unsigned long target, in WebGLTexture texture) raises(DOMException);
+ [StrictTypeChecking] void blendColor(in double red, in double green, in double blue, in double alpha);
+ [StrictTypeChecking] void blendEquation( in unsigned long mode );
+ [StrictTypeChecking] void blendEquationSeparate(in unsigned long modeRGB, in unsigned long modeAlpha);
+ [StrictTypeChecking] void blendFunc(in unsigned long sfactor, in unsigned long dfactor);
+ [StrictTypeChecking] void blendFuncSeparate(in unsigned long srcRGB, in unsigned long dstRGB, in unsigned long srcAlpha, in unsigned long dstAlpha);
+ [StrictTypeChecking] void bufferData(in unsigned long target, in ArrayBuffer data, in unsigned long usage) raises (DOMException);
+ [StrictTypeChecking] void bufferData(in unsigned long target, in ArrayBufferView data, in unsigned long usage) raises (DOMException);
+ [StrictTypeChecking] void bufferData(in unsigned long target, in long size, in unsigned long usage) raises (DOMException);
+ [StrictTypeChecking] void bufferSubData(in unsigned long target, in long offset, in ArrayBuffer data) raises (DOMException);
+ [StrictTypeChecking] void bufferSubData(in unsigned long target, in long offset, in ArrayBufferView data) raises (DOMException);
+
+ [StrictTypeChecking] unsigned long checkFramebufferStatus(in unsigned long target);
+ [StrictTypeChecking] void clear(in unsigned long mask);
+ [StrictTypeChecking] void clearColor(in double red, in double green, in double blue, in double alpha);
+ [StrictTypeChecking] void clearDepth(in double depth);
+ [StrictTypeChecking] void clearStencil(in long s);
+ [StrictTypeChecking] void colorMask(in boolean red, in boolean green, in boolean blue, in boolean alpha);
+ [StrictTypeChecking] void compileShader(in WebGLShader shader) raises(DOMException);
//void compressedTexImage2D(in unsigned long target, in long level, in unsigned long internalformat, in unsigned long width, in unsigned long height, in long border, in unsigned long imageSize, const void* data);
//void compressedTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset, in unsigned long width, in unsigned long height, in unsigned long format, in unsigned long imageSize, const void* data);
- void copyTexImage2D(in unsigned long target, in long level, in unsigned long internalformat, in long x, in long y, in unsigned long width, in unsigned long height, in long border);
- void copyTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset, in long x, in long y, in unsigned long width, in unsigned long height);
-
- WebGLBuffer createBuffer();
- WebGLFramebuffer createFramebuffer();
- WebGLProgram createProgram();
- WebGLRenderbuffer createRenderbuffer();
- WebGLShader createShader(in unsigned long type) raises(DOMException);
- WebGLTexture createTexture();
-
- void cullFace(in unsigned long mode);
-
- void deleteBuffer(in WebGLBuffer buffer);
- void deleteFramebuffer(in WebGLFramebuffer framebuffer);
- void deleteProgram(in WebGLProgram program);
- void deleteRenderbuffer(in WebGLRenderbuffer renderbuffer);
- void deleteShader(in WebGLShader shader);
- void deleteTexture(in WebGLTexture texture);
-
- void depthFunc(in unsigned long func);
- void depthMask(in boolean flag);
+ [StrictTypeChecking] void copyTexImage2D(in unsigned long target, in long level, in unsigned long internalformat, in long x, in long y, in unsigned long width, in unsigned long height, in long border);
+ [StrictTypeChecking] void copyTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset, in long x, in long y, in unsigned long width, in unsigned long height);
+
+ [StrictTypeChecking] WebGLBuffer createBuffer();
+ [StrictTypeChecking] WebGLFramebuffer createFramebuffer();
+ [StrictTypeChecking] WebGLProgram createProgram();
+ [StrictTypeChecking] WebGLRenderbuffer createRenderbuffer();
+ [StrictTypeChecking] WebGLShader createShader(in unsigned long type) raises(DOMException);
+ [StrictTypeChecking] WebGLTexture createTexture();
+
+ [StrictTypeChecking] void cullFace(in unsigned long mode);
+
+ [StrictTypeChecking] void deleteBuffer(in WebGLBuffer buffer);
+ [StrictTypeChecking] void deleteFramebuffer(in WebGLFramebuffer framebuffer);
+ [StrictTypeChecking] void deleteProgram(in WebGLProgram program);
+ [StrictTypeChecking] void deleteRenderbuffer(in WebGLRenderbuffer renderbuffer);
+ [StrictTypeChecking] void deleteShader(in WebGLShader shader);
+ [StrictTypeChecking] void deleteTexture(in WebGLTexture texture);
+
+ [StrictTypeChecking] void depthFunc(in unsigned long func);
+ [StrictTypeChecking] void depthMask(in boolean flag);
// FIXME: this differs from the current WebGL spec (depthRangef)
- void depthRange(in double zNear, in double zFar);
- void detachShader(in WebGLProgram program, in WebGLShader shader) raises(DOMException);
- void disable(in unsigned long cap);
- void disableVertexAttribArray(in unsigned long index) raises(DOMException);
- void drawArrays(in unsigned long mode, in long first, in long count) raises(DOMException);
- void drawElements(in unsigned long mode, in long count, in unsigned long type, in long offset) raises(DOMException);
-
- void enable(in unsigned long cap);
- void enableVertexAttribArray(in unsigned long index) raises(DOMException);
- void finish();
- void flush();
- void framebufferRenderbuffer(in unsigned long target, in unsigned long attachment, in unsigned long renderbuffertarget, in WebGLRenderbuffer renderbuffer) raises(DOMException);
- void framebufferTexture2D(in unsigned long target, in unsigned long attachment, in unsigned long textarget, in WebGLTexture texture, in long level) raises(DOMException);
- void frontFace(in unsigned long mode);
- void generateMipmap(in unsigned long target);
+ [StrictTypeChecking] void depthRange(in double zNear, in double zFar);
+ [StrictTypeChecking] void detachShader(in WebGLProgram program, in WebGLShader shader) raises(DOMException);
+ [StrictTypeChecking] void disable(in unsigned long cap);
+ [StrictTypeChecking] void disableVertexAttribArray(in unsigned long index) raises(DOMException);
+ [StrictTypeChecking] void drawArrays(in unsigned long mode, in long first, in long count) raises(DOMException);
+ [StrictTypeChecking] void drawElements(in unsigned long mode, in long count, in unsigned long type, in long offset) raises(DOMException);
+
+ [StrictTypeChecking] void enable(in unsigned long cap);
+ [StrictTypeChecking] void enableVertexAttribArray(in unsigned long index) raises(DOMException);
+ [StrictTypeChecking] void finish();
+ [StrictTypeChecking] void flush();
+ [StrictTypeChecking] void framebufferRenderbuffer(in unsigned long target, in unsigned long attachment, in unsigned long renderbuffertarget, in WebGLRenderbuffer renderbuffer) raises(DOMException);
+ [StrictTypeChecking] void framebufferTexture2D(in unsigned long target, in unsigned long attachment, in unsigned long textarget, in WebGLTexture texture, in long level) raises(DOMException);
+ [StrictTypeChecking] void frontFace(in unsigned long mode);
+ [StrictTypeChecking] void generateMipmap(in unsigned long target);
- WebGLActiveInfo getActiveAttrib(in WebGLProgram program, in unsigned long index)
- raises (DOMException);
- WebGLActiveInfo getActiveUniform(in WebGLProgram program, in unsigned long index)
- raises (DOMException);
+ [StrictTypeChecking] WebGLActiveInfo getActiveAttrib(in WebGLProgram program, in unsigned long index) raises (DOMException);
+ [StrictTypeChecking] WebGLActiveInfo getActiveUniform(in WebGLProgram program, in unsigned long index) raises (DOMException);
- [Custom] void getAttachedShaders(in WebGLProgram program)
- raises (DOMException);
+ [StrictTypeChecking, Custom] void getAttachedShaders(in WebGLProgram program) raises (DOMException);
- int getAttribLocation(in WebGLProgram program, in DOMString name);
+ [StrictTypeChecking] int getAttribLocation(in WebGLProgram program, in DOMString name);
// any getBufferParameter(in unsigned long target, in unsigned long pname) raises(DOMException);
- [Custom] void getBufferParameter();
+ [StrictTypeChecking, Custom] void getBufferParameter();
- WebGLContextAttributes getContextAttributes();
+ [StrictTypeChecking] WebGLContextAttributes getContextAttributes();
- unsigned long getError();
+ [StrictTypeChecking] unsigned long getError();
// any getFramebufferAttachmentParameter(in unsigned long target, in unsigned long attachment, in unsigned long pname) raises(DOMException);
- [Custom] void getFramebufferAttachmentParameter();
+ [StrictTypeChecking, Custom] void getFramebufferAttachmentParameter();
// any getParameter(in unsigned long pname) raises(DOMException);
- [Custom] void getParameter();
+ [StrictTypeChecking, Custom] void getParameter();
// any getProgramParameter(in WebGLProgram program, in unsigned long pname) raises(DOMException);
- [Custom] void getProgramParameter();
- DOMString getProgramInfoLog(in WebGLProgram program) raises(DOMException);
+ [StrictTypeChecking, Custom] void getProgramParameter();
+ [StrictTypeChecking] DOMString getProgramInfoLog(in WebGLProgram program) raises(DOMException);
// any getRenderbufferParameter(in unsigned long target, in unsigned long pname) raises(DOMException);
- [Custom] void getRenderbufferParameter();
+ [StrictTypeChecking, Custom] void getRenderbufferParameter();
// any getShaderParameter(in WebGLShader shader, in unsigned long pname) raises(DOMException);
- [Custom] void getShaderParameter() raises(DOMException);
+ [StrictTypeChecking, Custom] void getShaderParameter() raises(DOMException);
- DOMString getShaderInfoLog(in WebGLShader shader) raises(DOMException);
+ [StrictTypeChecking] DOMString getShaderInfoLog(in WebGLShader shader) raises(DOMException);
// TBD
// void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
- DOMString getShaderSource(in WebGLShader shader) raises(DOMException);
- DOMString getString(in unsigned long name);
+ [StrictTypeChecking] DOMString getShaderSource(in WebGLShader shader) raises(DOMException);
+ [StrictTypeChecking] DOMString getString(in unsigned long name);
// any getTexParameter(in unsigned long target, in unsigned long pname) raises(DOMException);
- [Custom] void getTexParameter();
+ [StrictTypeChecking, Custom] void getTexParameter();
// any getUniform(in WebGLProgram program, in WebGLUniformLocation location) raises(DOMException);
- [Custom] void getUniform();
+ [StrictTypeChecking, Custom] void getUniform();
- WebGLUniformLocation getUniformLocation(in WebGLProgram program, in DOMString name) raises(DOMException);
+ [StrictTypeChecking] WebGLUniformLocation getUniformLocation(in WebGLProgram program, in DOMString name) raises(DOMException);
// any getVertexAttrib(in unsigned long index, in unsigned long pname) raises(DOMException);
- [Custom] void getVertexAttrib();
-
- long getVertexAttribOffset(in unsigned long index, in unsigned long pname);
-
- void hint(in unsigned long target, in unsigned long mode);
- boolean isBuffer(in WebGLBuffer buffer);
- boolean isEnabled(in unsigned long cap);
- boolean isFramebuffer(in WebGLFramebuffer framebuffer);
- boolean isProgram(in WebGLProgram program);
- boolean isRenderbuffer(in WebGLRenderbuffer renderbuffer);
- boolean isShader(in WebGLShader shader);
- boolean isTexture(in WebGLTexture texture);
- void lineWidth(in double width);
- void linkProgram(in WebGLProgram program) raises(DOMException);
- void pixelStorei(in unsigned long pname, in long param);
- void polygonOffset(in double factor, in double units);
-
- void readPixels(in long x, in long y, in long width, in long height, in unsigned long format, in unsigned long type, in ArrayBufferView pixels);
+ [StrictTypeChecking, Custom] void getVertexAttrib();
+
+ [StrictTypeChecking] long getVertexAttribOffset(in unsigned long index, in unsigned long pname);
+
+ [StrictTypeChecking] void hint(in unsigned long target, in unsigned long mode);
+ [StrictTypeChecking] boolean isBuffer(in WebGLBuffer buffer);
+ [StrictTypeChecking] boolean isEnabled(in unsigned long cap);
+ [StrictTypeChecking] boolean isFramebuffer(in WebGLFramebuffer framebuffer);
+ [StrictTypeChecking] boolean isProgram(in WebGLProgram program);
+ [StrictTypeChecking] boolean isRenderbuffer(in WebGLRenderbuffer renderbuffer);
+ [StrictTypeChecking] boolean isShader(in WebGLShader shader);
+ [StrictTypeChecking] boolean isTexture(in WebGLTexture texture);
+ [StrictTypeChecking] void lineWidth(in double width);
+ [StrictTypeChecking] void linkProgram(in WebGLProgram program) raises(DOMException);
+ [StrictTypeChecking] void pixelStorei(in unsigned long pname, in long param);
+ [StrictTypeChecking] void polygonOffset(in double factor, in double units);
+
+ [StrictTypeChecking] void readPixels(in long x, in long y, in long width, in long height, in unsigned long format, in unsigned long type, in ArrayBufferView pixels);
- void releaseShaderCompiler();
- void renderbufferStorage(in unsigned long target, in unsigned long internalformat, in unsigned long width, in unsigned long height);
- void sampleCoverage(in double value, in boolean invert);
- void scissor(in long x, in long y, in unsigned long width, in unsigned long height);
- void shaderSource(in WebGLShader shader, in DOMString string) raises(DOMException);
- void stencilFunc(in unsigned long func, in long ref, in unsigned long mask);
- void stencilFuncSeparate(in unsigned long face, in unsigned long func, in long ref, in unsigned long mask);
- void stencilMask(in unsigned long mask);
- void stencilMaskSeparate(in unsigned long face, in unsigned long mask);
- void stencilOp(in unsigned long fail, in unsigned long zfail, in unsigned long zpass);
- void stencilOpSeparate(in unsigned long face, in unsigned long fail, in unsigned long zfail, in unsigned long zpass);
-
- void texParameterf(in unsigned long target, in unsigned long pname, in float param);
- void texParameteri(in unsigned long target, in unsigned long pname, in long param);
+ [StrictTypeChecking] void releaseShaderCompiler();
+ [StrictTypeChecking] void renderbufferStorage(in unsigned long target, in unsigned long internalformat, in unsigned long width, in unsigned long height);
+ [StrictTypeChecking] void sampleCoverage(in double value, in boolean invert);
+ [StrictTypeChecking] void scissor(in long x, in long y, in unsigned long width, in unsigned long height);
+ [StrictTypeChecking] void shaderSource(in WebGLShader shader, in DOMString string) raises(DOMException);
+ [StrictTypeChecking] void stencilFunc(in unsigned long func, in long ref, in unsigned long mask);
+ [StrictTypeChecking] void stencilFuncSeparate(in unsigned long face, in unsigned long func, in long ref, in unsigned long mask);
+ [StrictTypeChecking] void stencilMask(in unsigned long mask);
+ [StrictTypeChecking] void stencilMaskSeparate(in unsigned long face, in unsigned long mask);
+ [StrictTypeChecking] void stencilOp(in unsigned long fail, in unsigned long zfail, in unsigned long zpass);
+ [StrictTypeChecking] void stencilOpSeparate(in unsigned long face, in unsigned long fail, in unsigned long zfail, in unsigned long zpass);
+
+ [StrictTypeChecking] void texParameterf(in unsigned long target, in unsigned long pname, in float param);
+ [StrictTypeChecking] void texParameteri(in unsigned long target, in unsigned long pname, in long param);
// Supported forms:
- void texImage2D(in unsigned long target, in long level, in unsigned long internalformat, in long width, in long height,
- in long border, in unsigned long format, in unsigned long type, in ArrayBufferView pixels) raises (DOMException);
- void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
- in unsigned long format, in unsigned long type, in ImageData pixels) raises (DOMException);
- void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
- in unsigned long format, in unsigned long type, in HTMLImageElement image) raises (DOMException);
- void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
- in unsigned long format, in unsigned long type, in HTMLCanvasElement canvas) raises (DOMException);
- void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
- in unsigned long format, in unsigned long type, in HTMLVideoElement video) raises (DOMException);
-
- void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
- in long width, in long height,
- in unsigned long format, in unsigned long type, in ArrayBufferView pixels) raises (DOMException);
- void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
- in unsigned long format, in unsigned long type, in ImageData pixels) raises (DOMException);
- void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
- in unsigned long format, in unsigned long type, in HTMLImageElement image) raises (DOMException);
- void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
- in unsigned long format, in unsigned long type, in HTMLCanvasElement canvas) raises (DOMException);
- void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
- in unsigned long format, in unsigned long type, in HTMLVideoElement video) raises (DOMException);
-
- void uniform1f(in WebGLUniformLocation location, in float x) raises(DOMException);
- [Custom] void uniform1fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
- void uniform1i(in WebGLUniformLocation location, in long x) raises(DOMException);
- [Custom] void uniform1iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
- void uniform2f(in WebGLUniformLocation location, in float x, in float y) raises(DOMException);
- [Custom] void uniform2fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
- void uniform2i(in WebGLUniformLocation location, in long x, in long y) raises(DOMException);
- [Custom] void uniform2iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
- void uniform3f(in WebGLUniformLocation location, in float x, in float y, in float z) raises(DOMException);
- [Custom] void uniform3fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
- void uniform3i(in WebGLUniformLocation location, in long x, in long y, in long z) raises(DOMException);
- [Custom] void uniform3iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
- void uniform4f(in WebGLUniformLocation location, in float x, in float y, in float z, in float w) raises(DOMException);
- [Custom] void uniform4fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
- void uniform4i(in WebGLUniformLocation location, in long x, in long y, in long z, in long w) raises(DOMException);
- [Custom] void uniform4iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
-
- [Custom] void uniformMatrix2fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);
- [Custom] void uniformMatrix3fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);
- [Custom] void uniformMatrix4fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);
-
- void useProgram(in WebGLProgram program) raises(DOMException);
- void validateProgram(in WebGLProgram program) raises(DOMException);
-
- void vertexAttrib1f(in unsigned long indx, in float x);
- [Custom] void vertexAttrib1fv(in unsigned long indx, in Float32Array values);
- void vertexAttrib2f(in unsigned long indx, in float x, in float y);
- [Custom] void vertexAttrib2fv(in unsigned long indx, in Float32Array values);
- void vertexAttrib3f(in unsigned long indx, in float x, in float y, in float z);
- [Custom] void vertexAttrib3fv(in unsigned long indx, in Float32Array values);
- void vertexAttrib4f(in unsigned long indx, in float x, in float y, in float z, in float w);
- [Custom] void vertexAttrib4fv(in unsigned long indx, in Float32Array values);
- void vertexAttribPointer(in unsigned long indx, in long size, in unsigned long type, in boolean normalized,
- in long stride, in unsigned long offset) raises(DOMException);
-
- void viewport(in long x, in long y, in unsigned long width, in unsigned long height);
+ [StrictTypeChecking] void texImage2D(in unsigned long target, in long level, in unsigned long internalformat, in long width, in long height,
+ in long border, in unsigned long format, in unsigned long type, in ArrayBufferView pixels) raises (DOMException);
+ [StrictTypeChecking] void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
+ in unsigned long format, in unsigned long type, in ImageData pixels) raises (DOMException);
+ [StrictTypeChecking] void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
+ in unsigned long format, in unsigned long type, in HTMLImageElement image) raises (DOMException);
+ [StrictTypeChecking] void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
+ in unsigned long format, in unsigned long type, in HTMLCanvasElement canvas) raises (DOMException);
+ [StrictTypeChecking] void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
+ in unsigned long format, in unsigned long type, in HTMLVideoElement video) raises (DOMException);
+
+ [StrictTypeChecking] void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
+ in long width, in long height,
+ in unsigned long format, in unsigned long type, in ArrayBufferView pixels) raises (DOMException);
+ [StrictTypeChecking] void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
+ in unsigned long format, in unsigned long type, in ImageData pixels) raises (DOMException);
+ [StrictTypeChecking] void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
+ in unsigned long format, in unsigned long type, in HTMLImageElement image) raises (DOMException);
+ [StrictTypeChecking] void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
+ in unsigned long format, in unsigned long type, in HTMLCanvasElement canvas) raises (DOMException);
+ [StrictTypeChecking] void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
+ in unsigned long format, in unsigned long type, in HTMLVideoElement video) raises (DOMException);
+
+ [StrictTypeChecking] void uniform1f(in WebGLUniformLocation location, in float x) raises(DOMException);
+ [StrictTypeChecking, Custom] void uniform1fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
+ [StrictTypeChecking] void uniform1i(in WebGLUniformLocation location, in long x) raises(DOMException);
+ [StrictTypeChecking, Custom] void uniform1iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
+ [StrictTypeChecking] void uniform2f(in WebGLUniformLocation location, in float x, in float y) raises(DOMException);
+ [StrictTypeChecking, Custom] void uniform2fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
+ [StrictTypeChecking] void uniform2i(in WebGLUniformLocation location, in long x, in long y) raises(DOMException);
+ [StrictTypeChecking, Custom] void uniform2iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
+ [StrictTypeChecking] void uniform3f(in WebGLUniformLocation location, in float x, in float y, in float z) raises(DOMException);
+ [StrictTypeChecking, Custom] void uniform3fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
+ [StrictTypeChecking] void uniform3i(in WebGLUniformLocation location, in long x, in long y, in long z) raises(DOMException);
+ [StrictTypeChecking, Custom] void uniform3iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
+ [StrictTypeChecking] void uniform4f(in WebGLUniformLocation location, in float x, in float y, in float z, in float w) raises(DOMException);
+ [StrictTypeChecking, Custom] void uniform4fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
+ [StrictTypeChecking] void uniform4i(in WebGLUniformLocation location, in long x, in long y, in long z, in long w) raises(DOMException);
+ [StrictTypeChecking, Custom] void uniform4iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
+
+ [StrictTypeChecking, Custom] void uniformMatrix2fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);
+ [StrictTypeChecking, Custom] void uniformMatrix3fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);
+ [StrictTypeChecking, Custom] void uniformMatrix4fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);
+
+ [StrictTypeChecking] void useProgram(in WebGLProgram program) raises(DOMException);
+ [StrictTypeChecking] void validateProgram(in WebGLProgram program) raises(DOMException);
+
+ [StrictTypeChecking] void vertexAttrib1f(in unsigned long indx, in float x);
+ [StrictTypeChecking, Custom] void vertexAttrib1fv(in unsigned long indx, in Float32Array values);
+ [StrictTypeChecking] void vertexAttrib2f(in unsigned long indx, in float x, in float y);
+ [StrictTypeChecking, Custom] void vertexAttrib2fv(in unsigned long indx, in Float32Array values);
+ [StrictTypeChecking] void vertexAttrib3f(in unsigned long indx, in float x, in float y, in float z);
+ [StrictTypeChecking, Custom] void vertexAttrib3fv(in unsigned long indx, in Float32Array values);
+ [StrictTypeChecking] void vertexAttrib4f(in unsigned long indx, in float x, in float y, in float z, in float w);
+ [StrictTypeChecking, Custom] void vertexAttrib4fv(in unsigned long indx, in Float32Array values);
+ [StrictTypeChecking] void vertexAttribPointer(in unsigned long indx, in long size, in unsigned long type, in boolean normalized,
+ in long stride, in unsigned long offset) raises(DOMException);
+
+ [StrictTypeChecking] void viewport(in long x, in long y, in unsigned long width, in unsigned long height);
};
}
diff --git a/WebCore/html/canvas/WebGLTexture.cpp b/WebCore/html/canvas/WebGLTexture.cpp
index e6dfd0a..7b2869f 100644
--- a/WebCore/html/canvas/WebGLTexture.cpp
+++ b/WebCore/html/canvas/WebGLTexture.cpp
@@ -169,11 +169,12 @@ void WebGLTexture::generateMipmapLevelInfo()
m_needToUseBlackTexture = false;
}
-unsigned long WebGLTexture::getInternalFormat() const
+unsigned long WebGLTexture::getInternalFormat(int level) const
{
if (!object() || !m_target)
return 0;
- return m_info[0][0].internalFormat;
+ // We assume level has been validated already.
+ return m_info[0][level].internalFormat;
}
bool WebGLTexture::isNPOT(unsigned width, unsigned height)
diff --git a/WebCore/html/canvas/WebGLTexture.h b/WebCore/html/canvas/WebGLTexture.h
index 64bd6e0..a1ce348 100644
--- a/WebCore/html/canvas/WebGLTexture.h
+++ b/WebCore/html/canvas/WebGLTexture.h
@@ -60,7 +60,7 @@ public:
// Generate all level information.
void generateMipmapLevelInfo();
- unsigned long getInternalFormat() const;
+ unsigned long getInternalFormat(int level) const;
// Whether width/height is NotPowerOfTwo.
static bool isNPOT(unsigned, unsigned);