Commit 683713ff authored by eric@webkit.org's avatar eric@webkit.org

Reviewed by Antti Koivisto and Sam Weinig.

        Clean up HTMLTokenizer a litle
        https://bugs.webkit.org/show_bug.cgi?id=22188

        Rename pendingScripts to m_pendingScripts
        Rename scriptNode to m_scriptNode make the type specific
        Rename pendingSrc to m_pendingSrc
        Rename currentPrependingSrc to m_currentPrependingSrc
        Rename noMoreData to m_noMoreData and cBuffer to m_cBuffer
        Remove long-since-dead kdDebug and qDebug calls
        Rename brokenComments to m_brokenComments
        Remove HTMLTokenizer includes and document the rest
        Rename src to m_src
        Rename parser to m_parser and make it an OwnPtr
        Rename inWrite to m_inWrite and jsProxy to scriptController
        Rename brokenServer to m_brokenServer
        Rename buffer to m_buffer and dest to m_dest
        Rename size to m_bufferSize
        Rename attrName to m_attrName
        Rename searchStopper to m_searchStopper and searchStopperLen to m_searchStopperLen
        Rename scriptCode* to m_scriptCode* and change scriptCodeMax to m_scriptCodeCapacity
        Rename scriptStartLineno to m_currentScriptTagStartLineNumber and tagStartLineno to m_currentTagStartLineNumber
        Rename scriptSrc to m_scriptTagSrcAttrValue and scriptSrcCharset to m_scriptTagCharsetAttrValue -- a bit unwieldy, but more precise
        Rename flat to selfClosingTag
        Rename currToken to m_currentToken

        * css/CSSParser.cpp:
        * dom/XMLTokenizer.cpp:
        * dom/XMLTokenizerLibxml2.cpp:
        * html/HTMLDocument.cpp:
        * html/HTMLElement.cpp:
        * html/HTMLFormControlElement.cpp:
        * html/HTMLParser.h:
        * html/HTMLTokenizer.cpp:
        (WebCore::Token::addAttribute):
        (WebCore::HTMLTokenizer::HTMLTokenizer):
        (WebCore::HTMLTokenizer::reset):
        (WebCore::HTMLTokenizer::begin):
        (WebCore::HTMLTokenizer::processListing):
        (WebCore::HTMLTokenizer::parseSpecial):
        (WebCore::HTMLTokenizer::scriptHandler):
        (WebCore::HTMLTokenizer::scriptExecution):
        (WebCore::HTMLTokenizer::parseComment):
        (WebCore::HTMLTokenizer::parseServer):
        (WebCore::HTMLTokenizer::parseProcessingInstruction):
        (WebCore::HTMLTokenizer::parseText):
        (WebCore::HTMLTokenizer::parseEntity):
        (WebCore::HTMLTokenizer::parseTag):
        (WebCore::HTMLTokenizer::write):
        (WebCore::HTMLTokenizer::processingData):
        (WebCore::HTMLTokenizer::end):
        (WebCore::HTMLTokenizer::finish):
        (WebCore::HTMLTokenizer::processToken):
        (WebCore::HTMLTokenizer::processDoctypeToken):
        (WebCore::HTMLTokenizer::~HTMLTokenizer):
        (WebCore::HTMLTokenizer::enlargeBuffer):
        (WebCore::HTMLTokenizer::enlargeScriptBuffer):
        (WebCore::HTMLTokenizer::notifyFinished):
        (WebCore::HTMLTokenizer::setSrc):
        * html/HTMLTokenizer.h:
        (WebCore::Token::Token):
        (WebCore::Token::reset):
        (WebCore::HTMLTokenizer::processingContentWrittenByScript):
        (WebCore::HTMLTokenizer::htmlParser):
        (WebCore::HTMLTokenizer::checkBuffer):
        (WebCore::HTMLTokenizer::checkScriptBuffer):
        * html/HTMLViewSourceDocument.h:
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::leftRelOffset):
        (WebCore::RenderBlock::rightRelOffset):
        (WebCore::RenderBlock::lineWidth):
        * xml/XSLTProcessor.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@38327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9ba2d612
2008-11-11 Eric Seidel <eric@webkit.org>
Reviewed by Antti Koivisto and Sam Weinig.
Clean up HTMLTokenizer a litle
https://bugs.webkit.org/show_bug.cgi?id=22188
Rename pendingScripts to m_pendingScripts
Rename scriptNode to m_scriptNode make the type specific
Rename pendingSrc to m_pendingSrc
Rename currentPrependingSrc to m_currentPrependingSrc
Rename noMoreData to m_noMoreData and cBuffer to m_cBuffer
Remove long-since-dead kdDebug and qDebug calls
Rename brokenComments to m_brokenComments
Remove HTMLTokenizer includes and document the rest
Rename src to m_src
Rename parser to m_parser and make it an OwnPtr
Rename inWrite to m_inWrite and jsProxy to scriptController
Rename brokenServer to m_brokenServer
Rename buffer to m_buffer and dest to m_dest
Rename size to m_bufferSize
Rename attrName to m_attrName
Rename searchStopper to m_searchStopper and searchStopperLen to m_searchStopperLen
Rename scriptCode* to m_scriptCode* and change scriptCodeMax to m_scriptCodeCapacity
Rename scriptStartLineno to m_currentScriptTagStartLineNumber and tagStartLineno to m_currentTagStartLineNumber
Rename scriptSrc to m_scriptTagSrcAttrValue and scriptSrcCharset to m_scriptTagCharsetAttrValue -- a bit unwieldy, but more precise
Rename flat to selfClosingTag
Rename currToken to m_currentToken
* css/CSSParser.cpp:
* dom/XMLTokenizer.cpp:
* dom/XMLTokenizerLibxml2.cpp:
* html/HTMLDocument.cpp:
* html/HTMLElement.cpp:
* html/HTMLFormControlElement.cpp:
* html/HTMLParser.h:
* html/HTMLTokenizer.cpp:
(WebCore::Token::addAttribute):
(WebCore::HTMLTokenizer::HTMLTokenizer):
(WebCore::HTMLTokenizer::reset):
(WebCore::HTMLTokenizer::begin):
(WebCore::HTMLTokenizer::processListing):
(WebCore::HTMLTokenizer::parseSpecial):
(WebCore::HTMLTokenizer::scriptHandler):
(WebCore::HTMLTokenizer::scriptExecution):
(WebCore::HTMLTokenizer::parseComment):
(WebCore::HTMLTokenizer::parseServer):
(WebCore::HTMLTokenizer::parseProcessingInstruction):
(WebCore::HTMLTokenizer::parseText):
(WebCore::HTMLTokenizer::parseEntity):
(WebCore::HTMLTokenizer::parseTag):
(WebCore::HTMLTokenizer::write):
(WebCore::HTMLTokenizer::processingData):
(WebCore::HTMLTokenizer::end):
(WebCore::HTMLTokenizer::finish):
(WebCore::HTMLTokenizer::processToken):
(WebCore::HTMLTokenizer::processDoctypeToken):
(WebCore::HTMLTokenizer::~HTMLTokenizer):
(WebCore::HTMLTokenizer::enlargeBuffer):
(WebCore::HTMLTokenizer::enlargeScriptBuffer):
(WebCore::HTMLTokenizer::notifyFinished):
(WebCore::HTMLTokenizer::setSrc):
* html/HTMLTokenizer.h:
(WebCore::Token::Token):
(WebCore::Token::reset):
(WebCore::HTMLTokenizer::processingContentWrittenByScript):
(WebCore::HTMLTokenizer::htmlParser):
(WebCore::HTMLTokenizer::checkBuffer):
(WebCore::HTMLTokenizer::checkScriptBuffer):
* html/HTMLViewSourceDocument.h:
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::leftRelOffset):
(WebCore::RenderBlock::rightRelOffset):
(WebCore::RenderBlock::lineWidth):
* xml/XSLTProcessor.cpp:
2008-11-11 Sam Weinig <sam@webkit.org>
Reviewed by Dan Bernstein.
......@@ -4138,20 +4138,8 @@ bool CSSParser::parseTransformOrigin(int propId, int& propId1, int& propId2, Ref
return value;
}
#ifdef CSS_DEBUG
static inline int yyerror(const char *str)
{
kdDebug(6080) << "CSS parse error " << str << endl;
return 1;
}
#else
static inline int yyerror(const char*) { return 1; }
#endif
#define END_TOKEN 0
#include "CSSGrammar.h"
......
......@@ -40,7 +40,6 @@
#include "HTMLNames.h"
#include "HTMLScriptElement.h"
#include "HTMLStyleElement.h"
#include "HTMLTokenizer.h"
#include "ScriptController.h"
#include "ProcessingInstruction.h"
#include "ResourceError.h"
......
......@@ -38,7 +38,7 @@
#include "FrameView.h"
#include "HTMLLinkElement.h"
#include "HTMLStyleElement.h"
#include "HTMLTokenizer.h"
#include "HTMLTokenizer.h" // for decodeNamedEntity
#include "ScriptController.h"
#include "ProcessingInstruction.h"
#include "ResourceError.h"
......
......@@ -66,7 +66,6 @@
#include "FrameTree.h"
#include "FrameView.h"
#include "HTMLBodyElement.h"
#include "HTMLElement.h"
#include "HTMLElementFactory.h"
#include "HTMLNames.h"
#include "HTMLTokenizer.h"
......
......@@ -36,7 +36,7 @@
#include "HTMLElementFactory.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
#include "HTMLTokenizer.h"
#include "HTMLTokenizer.h" // parseHTMLDocumentFragment
#include "RenderWordBreak.h"
#include "Settings.h"
#include "Text.h"
......
......@@ -35,7 +35,6 @@
#include "HTMLParser.h"
#include "HTMLTokenizer.h"
#include "RenderTheme.h"
#include "Tokenizer.h"
namespace WebCore {
......
......@@ -224,7 +224,7 @@ PassRefPtr<Node> HTMLParser::parseToken(Token* t)
while (charsLeft) {
// split large blocks of text to nodes of manageable size
n = Text::createWithLengthLimit(document, text, charsLeft);
if (!insertNode(n.get(), t->flat))
if (!insertNode(n.get(), t->selfClosingTag))
return 0;
}
return n;
......@@ -254,7 +254,7 @@ PassRefPtr<Node> HTMLParser::parseToken(Token* t)
}
}
if (!insertNode(n.get(), t->flat)) {
if (!insertNode(n.get(), t->selfClosingTag)) {
// we couldn't insert the node
if (n->isElementNode()) {
......@@ -721,10 +721,10 @@ bool HTMLParser::formCreateErrorCheck(Token* t, RefPtr<Node>& result)
bool HTMLParser::isindexCreateErrorCheck(Token* t, RefPtr<Node>& result)
{
RefPtr<Node> n = handleIsindex(t);
if (!inBody) {
if (!inBody)
m_isindexElement = n.release();
} else {
t->flat = true;
else {
t->selfClosingTag = true;
result = n.release();
}
return false;
......
......@@ -39,9 +39,9 @@ class HTMLFormElement;
class HTMLHeadElement;
class HTMLMapElement;
class Node;
class Token;
struct HTMLStackElem;
struct Token;
/**
* The parser for HTML. It receives a stream of tokens from the HTMLTokenizer, and
......
This diff is collapsed.
......@@ -40,6 +40,7 @@ class CachedScript;
class DocumentFragment;
class Document;
class HTMLDocument;
class HTMLScriptElement;
class HTMLViewSourceDocument;
class FrameView;
class HTMLParser;
......@@ -52,9 +53,13 @@ class PreloadScanner;
* of attributes. Can also represent text. In this case the id = 0 and
* text contains the text.
*/
class Token {
public:
Token() : beginTag(true), flat(false), brokenXMLStyle(false), m_sourceInfo(0) { }
struct Token {
Token()
: beginTag(true)
, selfClosingTag(false)
, brokenXMLStyle(false)
, m_sourceInfo(0)
{ }
~Token() { }
void addAttribute(Document*, AtomicString& attrName, const AtomicString& v, bool viewSourceMode);
......@@ -68,7 +73,7 @@ public:
text = 0;
tagName = nullAtom;
beginTag = true;
flat = false;
selfClosingTag = false;
brokenXMLStyle = false;
if (m_sourceInfo)
m_sourceInfo->clear();
......@@ -80,7 +85,7 @@ public:
RefPtr<StringImpl> text;
AtomicString tagName;
bool beginTag;
bool flat;
bool selfClosingTag;
bool brokenXMLStyle;
OwnPtr<Vector<UChar> > m_sourceInfo;
};
......@@ -143,12 +148,12 @@ public:
virtual int lineNumber() const { return m_lineNumber; }
virtual int columnNumber() const { return 1; }
bool processingContentWrittenByScript() const { return src.excludeLineNumbers(); }
bool processingContentWrittenByScript() const { return m_src.excludeLineNumbers(); }
virtual void executeScriptsWaitingForStylesheets();
virtual bool isHTMLTokenizer() const { return true; }
HTMLParser* htmlParser() const { return parser; }
HTMLParser* htmlParser() const { return m_parser.get(); }
private:
class State;
......@@ -169,7 +174,7 @@ private:
State parseText(SegmentedString&, State);
State parseSpecial(SegmentedString&, State);
State parseTag(SegmentedString&, State);
State parseEntity(SegmentedString&, UChar*& dest, State, unsigned& _cBufferPos, bool start, bool parsingTag);
State parseEntity(SegmentedString&, UChar*& dest, State, unsigned& cBufferPos, bool start, bool parsingTag);
State parseProcessingInstruction(SegmentedString&, State);
State scriptHandler(State);
State scriptExecution(const String& script, State, const String& scriptURL, int baseLine = 1);
......@@ -179,13 +184,13 @@ private:
// if not enlarge it
inline void checkBuffer(int len = 10)
{
if ((dest - buffer) > size - len)
if ((m_dest - m_buffer) > m_bufferSize - len)
enlargeBuffer(len);
}
inline void checkScriptBuffer(int len = 10)
{
if (scriptCodeSize + len >= scriptCodeMaxSize)
if (m_scriptCodeSize + len >= m_scriptCodeCapacity)
enlargeScriptBuffer(len);
}
......@@ -197,17 +202,15 @@ private:
void allDataProcessed();
// from CachedResourceClient
void notifyFinished(CachedResource *finishedObj);
void notifyFinished(CachedResource*);
// Internal buffers
///////////////////
UChar* buffer;
UChar* dest;
Token currToken;
UChar* m_buffer;
int m_bufferSize;
UChar* m_dest;
// the size of buffer
int size;
Token m_currentToken;
// Tokenizer flags
//////////////////
......@@ -334,19 +337,19 @@ private:
int m_doctypeSearchCount;
int m_doctypeSecondarySearchCount;
bool brokenServer;
bool m_brokenServer;
// Name of an attribute that we just scanned.
AtomicString attrName;
AtomicString m_attrName;
// Used to store the code of a scripting sequence
UChar* scriptCode;
UChar* m_scriptCode;
// Size of the script sequenze stored in @ref #scriptCode
int scriptCodeSize;
int m_scriptCodeSize;
// Maximal size that can be stored in @ref #scriptCode
int scriptCodeMaxSize;
int m_scriptCodeCapacity;
// resync point of script code size
int scriptCodeResync;
int m_scriptCodeResync;
// Stores characters if we are scanning for a string like "</script>"
UChar searchBuffer[10];
......@@ -354,40 +357,38 @@ private:
// Counts where we are in the string we are scanning for
int searchCount;
// the stopper string
const char* searchStopper;
// the stopper len
int searchStopperLen;
const char* m_searchStopper;
int m_searchStopperLength;
// if no more data is coming, just parse what we have (including ext scripts that
// may be still downloading) and finish
bool noMoreData;
bool m_noMoreData;
// URL to get source code of script from
String scriptSrc;
String scriptSrcCharset;
String m_scriptTagSrcAttrValue;
String m_scriptTagCharsetAttrValue;
// the HTML code we will parse after the external script we are waiting for has loaded
SegmentedString pendingSrc;
SegmentedString m_pendingSrc;
// the HTML code we will parse after this particular script has
// loaded, but before all pending HTML
SegmentedString *currentPrependingSrc;
SegmentedString* m_currentPrependingSrc;
// true if we are executing a script while parsing a document. This causes the parsing of
// the output of the script to be postponed until after the script has finished executing
int m_executingScript;
Deque<CachedResourceHandle<CachedScript> > pendingScripts;
RefPtr<Node> scriptNode;
Deque<CachedResourceHandle<CachedScript> > m_pendingScripts;
RefPtr<HTMLScriptElement> m_scriptNode;
bool m_requestingScript;
bool m_hasScriptsWaitingForStylesheets;
// if we found one broken comment, there are most likely others as well
// store a flag to get rid of the O(n^2) behaviour in such a case.
bool brokenComments;
bool m_brokenComments;
// current line number
int m_lineNumber;
// line number at which the current <script> started
int scriptStartLineno;
int tagStartLineno;
int m_currentScriptTagStartLineNumber;
int m_currentTagStartLineNumber;
double m_tokenizerTimeDelay;
int m_tokenizerChunkSize;
......@@ -399,13 +400,13 @@ private:
// So any fixed number might be too small, but rather than rewriting all usage of this buffer
// we'll just make it large enough to handle all imaginable cases.
#define CBUFLEN 1024
UChar cBuffer[CBUFLEN + 2];
UChar m_cBuffer[CBUFLEN + 2];
unsigned int m_cBufferPos;
SegmentedString src;
SegmentedString m_src;
Document* m_doc;
HTMLParser* parser;
bool inWrite;
OwnPtr<HTMLParser> m_parser;
bool m_inWrite;
bool m_fragment;
OwnPtr<PreloadScanner> m_preloadScanner;
......
......@@ -30,7 +30,7 @@
namespace WebCore {
class DoctypeToken;
class Token;
struct Token;
class HTMLViewSourceDocument : public HTMLDocument {
public:
......
......@@ -2484,13 +2484,12 @@ RenderBlock::leftRelOffset(int y, int fixedOffset, bool applyTextIndent,
}
if (applyTextIndent && m_firstLine && style()->direction() == LTR) {
int cw=0;
int cw = 0;
if (style()->textIndent().isPercent())
cw = containingBlock()->availableWidth();
left += style()->textIndent().calcMinValue(cw);
}
//kdDebug( 6040 ) << "leftOffset(" << y << ") = " << left << endl;
return left;
}
......@@ -2522,20 +2521,18 @@ RenderBlock::rightRelOffset(int y, int fixedOffset, bool applyTextIndent,
}
if (applyTextIndent && m_firstLine && style()->direction() == RTL) {
int cw=0;
int cw = 0;
if (style()->textIndent().isPercent())
cw = containingBlock()->availableWidth();
right -= style()->textIndent().calcMinValue(cw);
}
//kdDebug( 6040 ) << "rightOffset(" << y << ") = " << right << endl;
return right;
}
int
RenderBlock::lineWidth(int y) const
{
//kdDebug( 6040 ) << "lineWidth(" << y << ")=" << rightOffset(y) - leftOffset(y) << endl;
int result = rightOffset(y) - leftOffset(y);
return (result < 0) ? 0 : result;
}
......
......@@ -36,7 +36,7 @@
#include "FrameLoader.h"
#include "FrameView.h"
#include "HTMLDocument.h"
#include "HTMLTokenizer.h"
#include "HTMLTokenizer.h" // for parseHTMLDocumentFragment
#include "Page.h"
#include "ResourceError.h"
#include "ResourceHandle.h"
......
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