Commit b11a768c authored by ddkilzer@apple.com's avatar ddkilzer@apple.com

Provide a mechanism to create a quirks delegate for HTMLParser

        Reviewed by David Hyatt.

WebCore:

        No tests since there is no change in behavior.

        HTMLParserQuirks.h defines an abstract base class that may be
        extended as needed.  The ChromeClient::createHTMLParserQuirks()
        factory method should be used to return an HTMLParserQuirks
        subclassed object when needed.

        * WebCore.xcodeproj/project.pbxproj: Added HTMLParserQuirks.h.
        * html/HTMLParser.cpp:
        (WebCore::HTMLParser::HTMLParser): Initialize m_parserQuirks
        using ChromeClient::createHTMLParserQuirks().
        (WebCore::HTMLParser::~HTMLParser): Delete m_parserQuirks if
        set.
        (WebCore::HTMLParser::reset): Call HTMLParserQuirks::reset() if
        m_parserQuirks is set.
        (WebCore::HTMLParser::insertNode): Call
        HTMLParserQuirks::shouldInsertNode() if m_parserQuirks is set,
        and return early if it returns false.
        (WebCore::HTMLParser::popBlock): Call
        HTMLParserQuirks::shouldPopBlock() if m_parserQuirks is set, and
        return early if it returns false.
        * html/HTMLParser.h: Added m_parserQuirks.
        * html/HTMLParserQuirks.h: Added.
        (WebCore::HTMLParserQuirks::HTMLParserQuirks):
        (WebCore::HTMLParserQuirks::~HTMLParserQuirks):
        * loader/EmptyClients.h:
        (WebCore::EmptyChromeClient::createHTMLParserQuirks): Added.
        * page/ChromeClient.h:
        (WebCore::ChromeClient::createHTMLParserQuirks): Added.

WebKit/gtk:

        * WebCoreSupport/ChromeClientGtk.h:
        (WebKit::ChromeClient::createHTMLParserQuirks): Added.  The
        default implementation of this factory method returns 0.

WebKit/mac:

        * WebCoreSupport/WebChromeClient.h:
        (WebChromeClient::createHTMLParserQuirks): Added.  The default
        implementation of this factory method returns 0.

WebKit/qt:

        * WebCoreSupport/ChromeClientQt.h:
        (WebCore::ChromeClientQt::createHTMLParserQuirks): Added.  The
        default implementation of this factory method returns 0.

WebKit/win:

        * WebCoreSupport/WebChromeClient.h:
        (WebChromeClient::createHTMLParserQuirks): Added.  The default
        implementation of this factory method returns 0.

WebKit/wx:

        * WebKitSupport/ChromeClientWx.h:
        (WebCore::ChromeClientWx::createHTMLParserQuirks): Added.  The
        default implementation of this factory method returns 0.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@43092 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 45c1fab5
2009-04-30 David Kilzer <ddkilzer@apple.com>
Provide a mechanism to create a quirks delegate for HTMLParser
Reviewed by David Hyatt.
No tests since there is no change in behavior.
HTMLParserQuirks.h defines an abstract base class that may be
extended as needed. The ChromeClient::createHTMLParserQuirks()
factory method should be used to return an HTMLParserQuirks
subclassed object when needed.
* WebCore.xcodeproj/project.pbxproj: Added HTMLParserQuirks.h.
* html/HTMLParser.cpp:
(WebCore::HTMLParser::HTMLParser): Initialize m_parserQuirks
using ChromeClient::createHTMLParserQuirks().
(WebCore::HTMLParser::~HTMLParser): Delete m_parserQuirks if
set.
(WebCore::HTMLParser::reset): Call HTMLParserQuirks::reset() if
m_parserQuirks is set.
(WebCore::HTMLParser::insertNode): Call
HTMLParserQuirks::shouldInsertNode() if m_parserQuirks is set,
and return early if it returns false.
(WebCore::HTMLParser::popBlock): Call
HTMLParserQuirks::shouldPopBlock() if m_parserQuirks is set, and
return early if it returns false.
* html/HTMLParser.h: Added m_parserQuirks.
* html/HTMLParserQuirks.h: Added.
(WebCore::HTMLParserQuirks::HTMLParserQuirks):
(WebCore::HTMLParserQuirks::~HTMLParserQuirks):
* loader/EmptyClients.h:
(WebCore::EmptyChromeClient::createHTMLParserQuirks): Added.
* page/ChromeClient.h:
(WebCore::ChromeClient::createHTMLParserQuirks): Added.
2009-04-30 Dimitri Glazkov <dglazkov@chromium.org>
Reviewed by Eric Seidel.
......@@ -659,6 +659,7 @@
448A29BF0A46D9CB0030759F /* JSHTMLOptionsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 448A29BD0A46D9CB0030759F /* JSHTMLOptionsCollection.h */; };
448A29C00A46D9CB0030759F /* JSHTMLOptionsCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 448A29BE0A46D9CB0030759F /* JSHTMLOptionsCollection.cpp */; };
448AD27C0A48137A0023D179 /* JSHTMLOptionsCollectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 448AD27A0A4813790023D179 /* JSHTMLOptionsCollectionCustom.cpp */; };
449B19F50FA72ECE0015CA4A /* HTMLParserQuirks.h in Headers */ = {isa = PBXBuildFile; fileRef = 449B19F30FA72ECE0015CA4A /* HTMLParserQuirks.h */; settings = {ATTRIBUTES = (Private, ); }; };
4614A1FE0B23A8D600446E1C /* copyCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 4614A1FD0B23A8D600446E1C /* copyCursor.png */; };
464EA2730B8A350B00A8E6E3 /* crossHairCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 464EA2710B8A350B00A8E6E3 /* crossHairCursor.png */; };
464EA2740B8A350B00A8E6E3 /* notAllowedCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 464EA2720B8A350B00A8E6E3 /* notAllowedCursor.png */; };
......@@ -5581,6 +5582,7 @@
448A29BE0A46D9CB0030759F /* JSHTMLOptionsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLOptionsCollection.cpp; sourceTree = "<group>"; };
448AD27A0A4813790023D179 /* JSHTMLOptionsCollectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLOptionsCollectionCustom.cpp; sourceTree = "<group>"; };
449098B10F8F82520076A327 /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
449B19F30FA72ECE0015CA4A /* HTMLParserQuirks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLParserQuirks.h; sourceTree = "<group>"; };
4614A1FD0B23A8D600446E1C /* copyCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = copyCursor.png; sourceTree = "<group>"; };
464EA2710B8A350B00A8E6E3 /* crossHairCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = crossHairCursor.png; sourceTree = "<group>"; };
464EA2720B8A350B00A8E6E3 /* notAllowedCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = notAllowedCursor.png; sourceTree = "<group>"; };
......@@ -11732,6 +11734,7 @@
F523D25102DE4396018635CA /* HTMLParser.h */,
BC588B4A0BFA723C00EE679E /* HTMLParserErrorCodes.cpp */,
BC588AEF0BFA6CF900EE679E /* HTMLParserErrorCodes.h */,
449B19F30FA72ECE0015CA4A /* HTMLParserQuirks.h */,
A871D44D0A127CBC00B12A68 /* HTMLPlugInElement.cpp */,
A871D44C0A127CBC00B12A68 /* HTMLPlugInElement.h */,
4415292D0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.cpp */,
......@@ -15697,6 +15700,7 @@
A871D4580A127CBC00B12A68 /* HTMLParamElement.h in Headers */,
93F198EF08245E59001E9ABC /* HTMLParser.h in Headers */,
BC588AF00BFA6CF900EE679E /* HTMLParserErrorCodes.h in Headers */,
449B19F50FA72ECE0015CA4A /* HTMLParserQuirks.h in Headers */,
A871D4560A127CBC00B12A68 /* HTMLPlugInElement.h in Headers */,
4415292E0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h in Headers */,
A8EA7CB00A192B9C00A8EF5F /* HTMLPreElement.h in Headers */,
......@@ -3,7 +3,7 @@
(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 Apple Inc. All rights reserved.
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
......@@ -27,6 +27,7 @@
#include "CharacterNames.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
#include "ChromeClient.h"
#include "Comment.h"
#include "Console.h"
#include "DOMWindow.h"
......@@ -45,15 +46,17 @@
#include "HTMLIsIndexElement.h"
#include "HTMLMapElement.h"
#include "HTMLNames.h"
#include "HTMLParserQuirks.h"
#include "HTMLTableCellElement.h"
#include "HTMLTableRowElement.h"
#include "HTMLTableSectionElement.h"
#include "HTMLTokenizer.h"
#include "LocalizedStrings.h"
#include "Page.h"
#include "Settings.h"
#include "Text.h"
#include <wtf/StdLibExtras.h>
namespace WebCore {
using namespace HTMLNames;
......@@ -133,6 +136,7 @@ HTMLParser::HTMLParser(HTMLDocument* doc, bool reportErrors)
, m_reportErrors(reportErrors)
, m_handlingResidualStyleAcrossBlocks(false)
, m_inStrayTableContent(0)
, m_parserQuirks(m_document->page() ? m_document->page()->chrome()->client()->createHTMLParserQuirks() : 0)
{
}
......@@ -150,6 +154,7 @@ HTMLParser::HTMLParser(DocumentFragment* frag)
, m_reportErrors(false)
, m_handlingResidualStyleAcrossBlocks(false)
, m_inStrayTableContent(0)
, m_parserQuirks(m_document->page() ? m_document->page()->chrome()->client()->createHTMLParserQuirks() : 0)
{
if (frag)
frag->ref();
......@@ -159,7 +164,9 @@ HTMLParser::~HTMLParser()
{
freeBlock();
if (m_didRefCurrent)
m_current->deref();
m_current->deref();
if (m_parserQuirks)
delete m_parserQuirks;
}
void HTMLParser::reset()
......@@ -181,6 +188,9 @@ void HTMLParser::reset()
m_isindexElement = 0;
m_skipModeTag = nullAtom;
if (m_parserQuirks)
m_parserQuirks->reset();
}
void HTMLParser::setCurrent(Node* newCurrent)
......@@ -332,6 +342,9 @@ bool HTMLParser::insertNode(Node* n, bool flat)
popBlock(m_blockStack->tagName);
}
if (m_parserQuirks && !m_parserQuirks->shouldInsertNode(m_current, n))
return false;
// let's be stupid and just try to insert it.
// this should work if the document is well-formed
Node* newNode = m_current->addChild(n);
......@@ -1334,7 +1347,10 @@ void HTMLParser::pushBlock(const AtomicString& tagName, int level)
void HTMLParser::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)) {
......
......@@ -3,7 +3,7 @@
(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 Apple Inc. All rights reserved.
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
......@@ -38,6 +38,7 @@ class HTMLDocument;
class HTMLFormElement;
class HTMLHeadElement;
class HTMLMapElement;
class HTMLParserQuirks;
class Node;
struct HTMLStackElem;
......@@ -182,6 +183,8 @@ private:
bool m_reportErrors;
bool m_handlingResidualStyleAcrossBlocks;
int m_inStrayTableContent;
HTMLParserQuirks* m_parserQuirks;
};
}
......
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef HTMLParserQuirks_h
#define HTMLParserQuirks_h
#include <wtf/Noncopyable.h>
namespace WebCore {
class AtomicString;
class Node;
class HTMLParserQuirks : Noncopyable {
public:
HTMLParserQuirks() { }
virtual ~HTMLParserQuirks() { }
virtual void reset() = 0;
virtual bool shouldInsertNode(Node* parent, Node* newNode) = 0;
virtual bool shouldPopBlock(const AtomicString& tagNameOnStack, const AtomicString& tagNameToPop) = 0;
};
} // namespace WebCore
#endif // HTMLParserQuirks_h
/*
* Copyright (C) 2006 Eric Seidel (eric@webkit.org)
* Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -133,6 +134,8 @@ public:
virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) { }
virtual void formStateDidChange(const Node*) { }
virtual HTMLParserQuirks* createHTMLParserQuirks() { return 0; }
};
class EmptyFrameLoaderClient : public FrameLoaderClient {
......
......@@ -22,10 +22,10 @@
#include "Console.h"
#include "Cursor.h"
#include "GraphicsContext.h"
#include "FocusDirection.h"
#include "ScrollTypes.h"
#include "GraphicsContext.h"
#include "HostWindow.h"
#include "ScrollTypes.h"
#include <wtf/Forward.h>
#include <wtf/Vector.h>
......@@ -45,6 +45,7 @@ namespace WebCore {
class FloatRect;
class Frame;
class Geolocation;
class HTMLParserQuirks;
class HitTestResult;
class IntRect;
class Node;
......@@ -164,6 +165,8 @@ namespace WebCore {
// will be called frequently, so handling should be very fast.
virtual void formStateDidChange(const Node*) = 0;
virtual HTMLParserQuirks* createHTMLParserQuirks() = 0;
#if USE(ACCELERATED_COMPOSITING)
// Pass 0 as the GraphicsLayer to detatch the root layer.
virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) { }
......
2009-04-30 David Kilzer <ddkilzer@apple.com>
Provide a mechanism to create a quirks delegate for HTMLParser
Reviewed by David Hyatt.
* WebCoreSupport/ChromeClientGtk.h:
(WebKit::ChromeClient::createHTMLParserQuirks): Added. The
default implementation of this factory method returns 0.
2009-04-30 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Dimitri Glazkov.
......
......@@ -104,6 +104,8 @@ namespace WebKit {
virtual void formStateDidChange(const WebCore::Node*) { }
virtual WebCore::HTMLParserQuirks* createHTMLParserQuirks() { return 0; }
private:
WebKitWebView* m_webView;
WebCore::KURL m_hoveredLinkURL;
......
2009-04-30 David Kilzer <ddkilzer@apple.com>
Provide a mechanism to create a quirks delegate for HTMLParser
Reviewed by David Hyatt.
* WebCoreSupport/WebChromeClient.h:
(WebChromeClient::createHTMLParserQuirks): Added. The default
implementation of this factory method returns 0.
2009-04-30 Dimitri Glazkov <dglazkov@chromium.org>
Reviewed by Timothy Hatcher.
......
......@@ -133,6 +133,8 @@ public:
virtual void formStateDidChange(const WebCore::Node*) { }
virtual WebCore::HTMLParserQuirks* createHTMLParserQuirks() { return 0; }
#if USE(ACCELERATED_COMPOSITING)
virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
virtual void setNeedsOneShotDrawingSynchronization();
......
2009-04-30 David Kilzer <ddkilzer@apple.com>
Provide a mechanism to create a quirks delegate for HTMLParser
Reviewed by David Hyatt.
* WebCoreSupport/ChromeClientQt.h:
(WebCore::ChromeClientQt::createHTMLParserQuirks): Added. The
default implementation of this factory method returns 0.
2009-04-30 Ariya Hidayat <ariya.hidayat@nokia.com>
Unreviewed build fix after r43072.
......
......@@ -120,6 +120,8 @@ namespace WebCore {
virtual void formStateDidChange(const Node*) { }
virtual HTMLParserQuirks* createHTMLParserQuirks() { return 0; }
QWebPage* m_webPage;
WebCore::KURL lastHoverURL;
WebCore::String lastHoverTitle;
......
2009-04-30 David Kilzer <ddkilzer@apple.com>
Provide a mechanism to create a quirks delegate for HTMLParser
Reviewed by David Hyatt.
* WebCoreSupport/WebChromeClient.h:
(WebChromeClient::createHTMLParserQuirks): Added. The default
implementation of this factory method returns 0.
2009-04-30 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Dimitri Glazkov.
......
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -122,6 +122,8 @@ public:
virtual void formStateDidChange(const WebCore::Node*) { }
virtual WebCore::HTMLParserQuirks* createHTMLParserQuirks() { return 0; }
private:
COMPtr<IWebUIDelegate> uiDelegate();
COMPtr<IWebUIDelegate2> uiDelegate2();
......
2009-04-30 David Kilzer <ddkilzer@apple.com>
Provide a mechanism to create a quirks delegate for HTMLParser
Reviewed by David Hyatt.
* WebKitSupport/ChromeClientWx.h:
(WebCore::ChromeClientWx::createHTMLParserQuirks): Added. The
default implementation of this factory method returns 0.
2009-04-30 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Dimitri Glazkov.
......
......@@ -118,6 +118,8 @@ public:
virtual void formStateDidChange(const Node*) { }
virtual HTMLParserQuirks* createHTMLParserQuirks() { return 0; }
private:
wxWebView* m_webView;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment