| Differences between
and this patch
- WebCore/ChangeLog +63 lines
Lines 1-3 WebCore/ChangeLog_sec1
1
2007-01-05  Rob Buis  <buis@kde.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        http://bugs.webkit.org/show_bug.cgi?id=10362
6
        SVG needs to support SVGError events and some form of "error state"
7
8
        Report SVG warnings and errors on (JS) console.
9
        Expose line and column number getters in Tokenizer in
10
        order to display them with the error message.
11
12
        * dom/Tokenizer.h: Added.
13
        (WebCore::Tokenizer::Tokenizer):
14
        (WebCore::Tokenizer::~Tokenizer):
15
        (WebCore::Tokenizer::stopParsing):
16
        (WebCore::Tokenizer::processingData):
17
        (WebCore::Tokenizer::executingScript):
18
        (WebCore::Tokenizer::wantsRawData):
19
        (WebCore::Tokenizer::writeRawData):
20
        (WebCore::Tokenizer::inViewSourceMode):
21
        (WebCore::Tokenizer::setInViewSourceMode):
22
        (WebCore::Tokenizer::wellFormed):
23
        (WebCore::Tokenizer::lineNumber):
24
        (WebCore::Tokenizer::columnNumber):
25
        * dom/XMLTokenizer.cpp:
26
        * dom/XMLTokenizer.h:
27
        * html/HTMLTokenizer.h:
28
        (WebCore::HTMLTokenizer::lineNumber):
29
        (WebCore::HTMLTokenizer::columnNumber):
30
        * ksvg2/misc/SVGDocumentExtensions.cpp:
31
        (WebCore::SVGDocumentExtensions::reportWarning):
32
        (WebCore::SVGDocumentExtensions::reportError):
33
        * ksvg2/misc/SVGDocumentExtensions.h:
34
        * ksvg2/svg/SVGCircleElement.cpp:
35
        (WebCore::SVGCircleElement::parseMappedAttribute):
36
        * ksvg2/svg/SVGElement.h:
37
        * ksvg2/svg/SVGEllipseElement.cpp:
38
        (WebCore::SVGEllipseElement::parseMappedAttribute):
39
        * ksvg2/svg/SVGFitToViewBox.cpp:
40
        (WebCore::SVGFitToViewBox::parseViewBox):
41
        * ksvg2/svg/SVGFitToViewBox.h:
42
        * ksvg2/svg/SVGImageElement.cpp:
43
        (WebCore::SVGImageElement::parseMappedAttribute):
44
        * ksvg2/svg/SVGParserUtilities.cpp:
45
        (WebCore::SVGPolyParser::parsePoints):
46
        * ksvg2/svg/SVGParserUtilities.h:
47
        * ksvg2/svg/SVGPathElement.cpp:
48
        (WebCore::SVGPathElement::parseMappedAttribute):
49
        * ksvg2/svg/SVGPatternElement.cpp:
50
        (WebCore::SVGPatternElement::parseMappedAttribute):
51
        * ksvg2/svg/SVGPolyElement.cpp:
52
        (WebCore::SVGPolyElement::parseMappedAttribute):
53
        * ksvg2/svg/SVGRadialGradientElement.cpp:
54
        (WebCore::SVGRadialGradientElement::parseMappedAttribute):
55
        * ksvg2/svg/SVGRectElement.cpp:
56
        (WebCore::SVGRectElement::parseMappedAttribute):
57
        * ksvg2/svg/SVGSVGElement.cpp:
58
        (WebCore::SVGSVGElement::parseMappedAttribute):
59
        * ksvg2/svg/SVGTextContentElement.cpp:
60
        (WebCore::SVGTextContentElement::parseMappedAttribute):
61
        * ksvg2/svg/SVGUseElement.cpp:
62
        (WebCore::SVGUseElement::parseMappedAttribute):
63
1
2007-01-05  Anders Carlsson  <acarlsson@apple.com>
64
2007-01-05  Anders Carlsson  <acarlsson@apple.com>
2
65
3
        Reviewed by Maciej.
66
        Reviewed by Maciej.
- WebCore/dom/Tokenizer.h +74 lines
Line 0 WebCore/dom/Tokenizer.h_sec1
1
/*
2
 * This file is part of the DOM implementation for KDE.
3
 *
4
 * Copyright (C) 2000 Peter Kelly (pmk@post.com)
5
 * Copyright (C) 2005, 2006 Apple Computer, Inc.
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Library General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2 of the License, or (at your option) any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Library General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Library General Public License
18
 * along with this library; see the file COPYING.LIB.  If not, write to
19
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
 * Boston, MA 02111-1307, USA.
21
 *
22
 */
23
24
#ifndef Tokenizer_h_
25
#define Tokenizer_h_
26
27
namespace WebCore {
28
29
class SegmentedString;
30
31
class Tokenizer
32
{
33
public:
34
    Tokenizer(bool viewSourceMode = false) 
35
    : m_parserStopped(false)
36
    , m_inViewSourceMode(viewSourceMode)
37
    {}
38
    
39
    virtual ~Tokenizer() {}
40
41
    // Script output must be prepended, while new data
42
    // received during executing a script must be appended, hence the
43
    // extra bool to be able to distinguish between both cases.
44
    // document.write() always uses false, while the loader uses true.
45
    virtual bool write(const SegmentedString&, bool appendData) = 0;
46
    virtual void finish() = 0;
47
    virtual bool isWaitingForScripts() const = 0;
48
    virtual void stopParsing() { m_parserStopped = true; }
49
    virtual bool processingData() const { return false; }
50
    virtual int executingScript() const { return 0; }
51
52
    virtual bool wantsRawData() const { return false; }
53
    virtual bool writeRawData(const char* data, int len) { return false; }
54
    
55
    bool inViewSourceMode() const { return m_inViewSourceMode; }
56
    void setInViewSourceMode(bool mode) { m_inViewSourceMode = mode; }
57
58
    virtual bool wellFormed() const { return true; }
59
60
    virtual int lineNumber() const { return -1; }
61
    virtual int columnNumber() const { return -1; }
62
63
protected:
64
    // The tokenizer has buffers, so parsing may continue even after
65
    // it stops receiving data. We use m_parserStopped to stop the tokenizer
66
    // even when it has buffered data.
67
    bool m_parserStopped;
68
    
69
    bool m_inViewSourceMode;
70
};
71
72
}
73
74
#endif
- WebCore/dom/XMLTokenizer.cpp -3 / +4 lines
Lines 46-51 WebCore/dom/XMLTokenizer.cpp_sec1
46
#include "ResourceHandle.h"
46
#include "ResourceHandle.h"
47
#include "ResourceRequest.h"
47
#include "ResourceRequest.h"
48
#include "ResourceResponse.h"
48
#include "ResourceResponse.h"
49
#include "Tokenizer.h"
49
#include <libxml/parser.h>
50
#include <libxml/parser.h>
50
#include <libxml/parserInternals.h>
51
#include <libxml/parserInternals.h>
51
#include <wtf/Platform.h>
52
#include <wtf/Platform.h>
Lines 113-125 public: WebCore/dom/XMLTokenizer.cpp_sec2
113
114
114
    virtual bool wellFormed() const { return !m_sawError; }
115
    virtual bool wellFormed() const { return !m_sawError; }
115
116
117
    virtual int lineNumber() const;
118
    virtual int columnNumber() const;
119
116
private:
120
private:
117
    void initializeParserContext();
121
    void initializeParserContext();
118
    void setCurrentNode(Node*);
122
    void setCurrentNode(Node*);
119
123
120
    int lineNumber() const;
121
    int columnNumber() const;
122
123
    void insertErrorMessageBlock();
124
    void insertErrorMessageBlock();
124
125
125
    bool enterText();
126
    bool enterText();
- WebCore/dom/XMLTokenizer.h -38 / +2 lines
Lines 24-29 WebCore/dom/XMLTokenizer.h_sec1
24
#ifndef XML_Tokenizer_h_
24
#ifndef XML_Tokenizer_h_
25
#define XML_Tokenizer_h_
25
#define XML_Tokenizer_h_
26
26
27
#include "Tokenizer.h"
27
#include "StringHash.h"
28
#include "StringHash.h"
28
#include <wtf/HashMap.h>
29
#include <wtf/HashMap.h>
29
30
Lines 34-78 class DocumentFragment; WebCore/dom/XMLTokenizer.h_sec2
34
class Document;
35
class Document;
35
class Element;
36
class Element;
36
class FrameView;
37
class FrameView;
37
class SegmentedString;
38
38
39
class Tokenizer
39
class Tokenizer;
40
{
41
public:
42
    Tokenizer(bool viewSourceMode = false) 
43
    : m_parserStopped(false)
44
    , m_inViewSourceMode(viewSourceMode)
45
    {}
46
    
47
    virtual ~Tokenizer() {}
48
49
    // Script output must be prepended, while new data
50
    // received during executing a script must be appended, hence the
51
    // extra bool to be able to distinguish between both cases.
52
    // document.write() always uses false, while the loader uses true.
53
    virtual bool write(const SegmentedString&, bool appendData) = 0;
54
    virtual void finish() = 0;
55
    virtual bool isWaitingForScripts() const = 0;
56
    virtual void stopParsing() { m_parserStopped = true; }
57
    virtual bool processingData() const { return false; }
58
    virtual int executingScript() const { return 0; }
59
60
    virtual bool wantsRawData() const { return false; }
61
    virtual bool writeRawData(const char* data, int len) { return false; }
62
    
63
    bool inViewSourceMode() const { return m_inViewSourceMode; }
64
    void setInViewSourceMode(bool mode) { m_inViewSourceMode = mode; }
65
66
    virtual bool wellFormed() const { return true; }
67
68
protected:
69
    // The tokenizer has buffers, so parsing may continue even after
70
    // it stops receiving data. We use m_parserStopped to stop the tokenizer
71
    // even when it has buffered data.
72
    bool m_parserStopped;
73
    
74
    bool m_inViewSourceMode;
75
};
76
40
77
Tokenizer* newXMLTokenizer(Document*, FrameView* = 0);
41
Tokenizer* newXMLTokenizer(Document*, FrameView* = 0);
78
#if XSLT_SUPPORT
42
#if XSLT_SUPPORT
- WebCore/html/HTMLTokenizer.h +3 lines
Lines 94-99 public: WebCore/html/HTMLTokenizer.h_sec1
94
    virtual bool processingData() const;
94
    virtual bool processingData() const;
95
    virtual int executingScript() const { return m_executingScript; }
95
    virtual int executingScript() const { return m_executingScript; }
96
96
97
    virtual int lineNumber() const { return lineno; }
98
    virtual int columnNumber() const { return 1; }
99
97
private:
100
private:
98
    class State;
101
    class State;
99
102
- WebCore/ksvg2/misc/SVGDocumentExtensions.cpp -2 / +27 lines
Lines 1-6 WebCore/ksvg2/misc/SVGDocumentExtensions.cpp_sec1
1
/*
1
/*
2
    Copyright (C) 2006 Apple Computer, Inc.
2
    Copyright (C) 2006 Apple Computer, Inc.
3
                  2006 Nikolas Zimmermann <zimmermann@kde.org>
3
                  2006 Nikolas Zimmermann <zimmermann@kde.org>
4
                  2007 Rob Buis <buis@kde.org>
4
5
5
    This file is part of the WebKit project
6
    This file is part of the WebKit project
6
7
Lines 25-37 WebCore/ksvg2/misc/SVGDocumentExtensions.cpp_sec2
25
#ifdef SVG_SUPPORT
26
#ifdef SVG_SUPPORT
26
#include "SVGDocumentExtensions.h"
27
#include "SVGDocumentExtensions.h"
27
28
29
#include "AtomicString.h"
30
#include "Chrome.h"
28
#include "Document.h"
31
#include "Document.h"
29
#include "EventListener.h"
32
#include "EventListener.h"
30
#include "Frame.h"
33
#include "Frame.h"
34
#include "FrameLoader.h"
35
#include "Page.h"
36
#include "SVGSVGElement.h"
31
#include "TimeScheduler.h"
37
#include "TimeScheduler.h"
32
#include "AtomicString.h"
38
#include "XMLTokenizer.h"
33
#include "kjs_proxy.h"
39
#include "kjs_proxy.h"
34
#include "SVGSVGElement.h"
35
40
36
namespace WebCore {
41
namespace WebCore {
37
42
Lines 87-92 void SVGDocumentExtensions::unpauseAnima WebCore/ksvg2/misc/SVGDocumentExtensions.cpp_sec3
87
        (*itr)->unpauseAnimations();
92
        (*itr)->unpauseAnimations();
88
}
93
}
89
94
95
void SVGDocumentExtensions::reportWarning(const String& message)
96
{
97
    if (Page* page = m_doc->frame()->page()) {
98
        int lineNumber = 1;
99
        if (m_doc->tokenizer())
100
            lineNumber =  m_doc->tokenizer()->lineNumber();
101
        page->chrome()->addMessageToConsole("Warning: " + message, lineNumber, String());
102
    }
103
}
104
105
void SVGDocumentExtensions::reportError(const String& message)
106
{
107
    if (Page* page = m_doc->frame()->page()) {
108
        int lineNumber = 1;
109
        if (m_doc->tokenizer())
110
            lineNumber =  m_doc->tokenizer()->lineNumber();
111
        page->chrome()->addMessageToConsole("Error: " + message, lineNumber, String());
112
    }
113
}
114
90
void SVGDocumentExtensions::addPendingResource(const AtomicString& id, SVGStyledElement* obj)
115
void SVGDocumentExtensions::addPendingResource(const AtomicString& id, SVGStyledElement* obj)
91
{
116
{
92
    if (m_pendingResources.contains(id))
117
    if (m_pendingResources.contains(id))
- WebCore/ksvg2/misc/SVGDocumentExtensions.h +3 lines
Lines 60-65 public: WebCore/ksvg2/misc/SVGDocumentExtensions.h_sec1
60
    void pauseAnimations();
60
    void pauseAnimations();
61
    void unpauseAnimations();
61
    void unpauseAnimations();
62
62
63
    void reportWarning(const String&);
64
    void reportError(const String&);
65
63
private:
66
private:
64
    Document* m_doc; // weak reference
67
    Document* m_doc; // weak reference
65
    HashSet<SVGSVGElement*> m_timeContainers; // For SVG 1.2 support this will need to be made more general.
68
    HashSet<SVGSVGElement*> m_timeContainers; // For SVG 1.2 support this will need to be made more general.
- WebCore/ksvg2/svg/SVGCircleElement.cpp -2 / +4 lines
Lines 56-64 void SVGCircleElement::parseMappedAttrib WebCore/ksvg2/svg/SVGCircleElement.cpp_sec1
56
        setCxBaseValue(SVGLength(this, LengthModeWidth, value));       
56
        setCxBaseValue(SVGLength(this, LengthModeWidth, value));       
57
    else if (attr->name() == SVGNames::cyAttr)
57
    else if (attr->name() == SVGNames::cyAttr)
58
        setCyBaseValue(SVGLength(this, LengthModeHeight, value));
58
        setCyBaseValue(SVGLength(this, LengthModeHeight, value));
59
    else if (attr->name() == SVGNames::rAttr)
59
    else if (attr->name() == SVGNames::rAttr) {
60
        setRBaseValue(SVGLength(this, LengthModeOther, value));
60
        setRBaseValue(SVGLength(this, LengthModeOther, value));
61
    else {
61
        if (r().value() < 0.0)
62
            document()->accessSVGExtensions()->reportError("A negative value for circle <r> is not allowed");
63
    } else {
62
        if (SVGTests::parseMappedAttribute(attr))
64
        if (SVGTests::parseMappedAttribute(attr))
63
            return;
65
            return;
64
        if (SVGLangSpace::parseMappedAttribute(attr))
66
        if (SVGLangSpace::parseMappedAttribute(attr))
- WebCore/ksvg2/svg/SVGElement.h -1 lines
Lines 173-179 PassRefPtr<ClassName::SVGAnimatedTemplat WebCore/ksvg2/svg/SVGElement.h_sec1
173
}
173
}
174
174
175
namespace WebCore {
175
namespace WebCore {
176
    class DocumentPtr;
177
    class Ecma;
176
    class Ecma;
178
    class SVGPreserveAspectRatio;
177
    class SVGPreserveAspectRatio;
179
    class SVGMatrix;
178
    class SVGMatrix;
- WebCore/ksvg2/svg/SVGEllipseElement.cpp -3 / +7 lines
Lines 59-69 void SVGEllipseElement::parseMappedAttri WebCore/ksvg2/svg/SVGEllipseElement.cpp_sec1
59
        setCxBaseValue(SVGLength(this, LengthModeWidth, value));
59
        setCxBaseValue(SVGLength(this, LengthModeWidth, value));
60
    else if (attr->name() == SVGNames::cyAttr)
60
    else if (attr->name() == SVGNames::cyAttr)
61
        setCyBaseValue(SVGLength(this, LengthModeHeight, value));
61
        setCyBaseValue(SVGLength(this, LengthModeHeight, value));
62
    else if (attr->name() == SVGNames::rxAttr)
62
    else if (attr->name() == SVGNames::rxAttr) {
63
        setRxBaseValue(SVGLength(this, LengthModeWidth, value));
63
        setRxBaseValue(SVGLength(this, LengthModeWidth, value));
64
    else if (attr->name() == SVGNames::ryAttr)
64
        if (rx().value() < 0.0)
65
            document()->accessSVGExtensions()->reportError("A negative value for ellipse <rx> is not allowed");
66
    } else if (attr->name() == SVGNames::ryAttr) {
65
        setRyBaseValue(SVGLength(this, LengthModeHeight, value));
67
        setRyBaseValue(SVGLength(this, LengthModeHeight, value));
66
    else {
68
        if (ry().value() < 0.0)
69
            document()->accessSVGExtensions()->reportError("A negative value for ellipse <ry> is not allowed");
70
    } else {
67
        if (SVGTests::parseMappedAttribute(attr))
71
        if (SVGTests::parseMappedAttribute(attr))
68
            return;
72
            return;
69
        if (SVGLangSpace::parseMappedAttribute(attr))
73
        if (SVGLangSpace::parseMappedAttribute(attr))
- WebCore/ksvg2/svg/SVGFitToViewBox.cpp -22 / +19 lines
Lines 24-34 WebCore/ksvg2/svg/SVGFitToViewBox.cpp_sec1
24
#ifdef SVG_SUPPORT
24
#ifdef SVG_SUPPORT
25
#include "SVGFitToViewBox.h"
25
#include "SVGFitToViewBox.h"
26
26
27
#include "AffineTransform.h"
27
#include "FloatRect.h"
28
#include "FloatRect.h"
29
#include "SVGDocumentExtensions.h"
28
#include "SVGNames.h"
30
#include "SVGNames.h"
29
#include "SVGParserUtilities.h"
31
#include "SVGParserUtilities.h"
30
#include "SVGPreserveAspectRatio.h"
32
#include "SVGPreserveAspectRatio.h"
31
#include "SVGSVGElement.h"
32
#include "StringImpl.h"
33
#include "StringImpl.h"
33
34
34
namespace WebCore {
35
namespace WebCore {
Lines 51-81 void SVGFitToViewBox::parseViewBox(const WebCore/ksvg2/svg/SVGFitToViewBox.cpp_sec2
51
    double x = 0, y = 0, w = 0, h = 0;
52
    double x = 0, y = 0, w = 0, h = 0;
52
    const UChar* c = str.characters();
53
    const UChar* c = str.characters();
53
    const UChar* end = c + str.length();
54
    const UChar* end = c + str.length();
55
    Document* doc = contextElement()->document();
54
56
55
    skipOptionalSpaces(c, end);
57
    skipOptionalSpaces(c, end);
56
58
57
    if (!parseNumber(c, end, x))
59
    if (!(parseNumber(c, end, x) && parseNumber(c, end, y) &&
58
        goto bail_out;
60
          parseNumber(c, end, w) && parseNumber(c, end, h, false))) {
59
61
        doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\"");
60
    if (!parseNumber(c, end, y))
62
        return;
61
        goto bail_out;
63
    }
62
63
    if (!parseNumber(c, end, w) || w < 0.0) // check that width is positive
64
        goto bail_out;
65
66
    if (!parseNumber(c, end, h, false) || h < 0.0) // check that height is positive
67
        goto bail_out;
68
69
    skipOptionalSpaces(c, end);
70
71
    if (c < end) // nothing should come after the last, fourth number
72
        goto bail_out;
73
74
    setViewBoxBaseValue(FloatRect(x, y, w, h));
75
    return;
76
64
77
bail_out:;
65
    if (w < 0.0) // check that width is positive
78
    // FIXME: Per the spec we are supposed to set the document into an "error state" here.
66
        doc->accessSVGExtensions()->reportError("A negative value for ViewBox width is not allowed");
67
    else if (h < 0.0) // check that height is positive
68
        doc->accessSVGExtensions()->reportError("A negative value for ViewBox height is not allowed");
69
    else {
70
        skipOptionalSpaces(c, end);
71
        if (c < end) // nothing should come after the last, fourth number
72
            doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\"");
73
        else
74
            setViewBoxBaseValue(FloatRect(x, y, w, h));
75
    }
79
}
76
}
80
77
81
AffineTransform SVGFitToViewBox::viewBoxToViewTransform(float viewWidth, float viewHeight) const
78
AffineTransform SVGFitToViewBox::viewBoxToViewTransform(float viewWidth, float viewHeight) const
- WebCore/ksvg2/svg/SVGFitToViewBox.h -3 / +3 lines
Lines 20-27 WebCore/ksvg2/svg/SVGFitToViewBox.h_sec1
20
    Boston, MA 02111-1307, USA.
20
    Boston, MA 02111-1307, USA.
21
*/
21
*/
22
22
23
#ifndef KSVG_SVGFitToViewBoxImpl_H
23
#ifndef SVGFitToViewBox_H
24
#define KSVG_SVGFitToViewBoxImpl_H
24
#define SVGFitToViewBox_H
25
#ifdef SVG_SUPPORT
25
#ifdef SVG_SUPPORT
26
26
27
#include "SVGElement.h"
27
#include "SVGElement.h"
Lines 54-59 namespace WebCore { WebCore/ksvg2/svg/SVGFitToViewBox.h_sec2
54
} // namespace WebCore
54
} // namespace WebCore
55
55
56
#endif // SVG_SUPPORT
56
#endif // SVG_SUPPORT
57
#endif // KSVG_SVGFitToViewBoxImpl_H
57
#endif // SVGFitToViewBox_H
58
58
59
// vim:ts=4:noet
59
// vim:ts=4:noet
- WebCore/ksvg2/svg/SVGImageElement.cpp +4 lines
Lines 75-83 void SVGImageElement::parseMappedAttribu WebCore/ksvg2/svg/SVGImageElement.cpp_sec1
75
    else if (attr->name() == SVGNames::widthAttr) {
75
    else if (attr->name() == SVGNames::widthAttr) {
76
        setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
76
        setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
77
        addCSSProperty(attr, CSS_PROP_WIDTH, value);
77
        addCSSProperty(attr, CSS_PROP_WIDTH, value);
78
        if (width().value() < 0.0)
79
            document()->accessSVGExtensions()->reportError("A negative value for image attribute <width> is not allowed");
78
    } else if (attr->name() == SVGNames::heightAttr) {
80
    } else if (attr->name() == SVGNames::heightAttr) {
79
        setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
81
        setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
80
        addCSSProperty(attr, CSS_PROP_HEIGHT, value);
82
        addCSSProperty(attr, CSS_PROP_HEIGHT, value);
83
        if (height().value() < 0.0)
84
            document()->accessSVGExtensions()->reportError("A negative value for image attribute <height> is not allowed");
81
    } else {
85
    } else {
82
        if (SVGTests::parseMappedAttribute(attr))
86
        if (SVGTests::parseMappedAttribute(attr))
83
            return;
87
            return;
- WebCore/ksvg2/svg/SVGParserUtilities.cpp -4 / +4 lines
Lines 109-118 bool parseNumberOptionalNumber(const Str WebCore/ksvg2/svg/SVGParserUtilities.cpp_sec1
109
    return cur == end;
109
    return cur == end;
110
}
110
}
111
111
112
void SVGPolyParser::parsePoints(const String& s) const
112
bool SVGPolyParser::parsePoints(const String& s) const
113
{
113
{
114
    if (s.isEmpty())
114
    if (s.isEmpty())
115
        return;
115
        return true;
116
    const UChar* cur = s.characters();
116
    const UChar* cur = s.characters();
117
    const UChar* end = cur + s.length();
117
    const UChar* end = cur + s.length();
118
118
Lines 122-132 void SVGPolyParser::parsePoints(const St WebCore/ksvg2/svg/SVGParserUtilities.cpp_sec2
122
    while (1) {
122
    while (1) {
123
        double xPos = 0;
123
        double xPos = 0;
124
        if (!parseNumber(cur, end, xPos))
124
        if (!parseNumber(cur, end, xPos))
125
            break;
125
           return false;
126
126
127
        double yPos = 0;
127
        double yPos = 0;
128
        if (!parseNumber(cur, end, yPos))
128
        if (!parseNumber(cur, end, yPos))
129
            break;
129
            return false;
130
130
131
        svgPolyTo(xPos, yPos, segmentNum++);
131
        svgPolyTo(xPos, yPos, segmentNum++);
132
    }
132
    }
- WebCore/ksvg2/svg/SVGParserUtilities.h -1 / +1 lines
Lines 69-75 namespace WebCore WebCore/ksvg2/svg/SVGParserUtilities.h_sec1
69
    {
69
    {
70
    public:
70
    public:
71
        virtual ~SVGPolyParser() { }
71
        virtual ~SVGPolyParser() { }
72
        void parsePoints(const String &points) const;
72
        bool parsePoints(const String &points) const;
73
73
74
    protected:
74
    protected:
75
        virtual void svgPolyTo(double x1, double y1, int nr) const = 0;
75
        virtual void svgPolyTo(double x1, double y1, int nr) const = 0;
- WebCore/ksvg2/svg/SVGPathElement.cpp -2 / +7 lines
Lines 268-278 void SVGPathElement::svgClosePath() WebCore/ksvg2/svg/SVGPathElement.cpp_sec1
268
268
269
void SVGPathElement::parseMappedAttribute(MappedAttribute* attr)
269
void SVGPathElement::parseMappedAttribute(MappedAttribute* attr)
270
{
270
{
271
    const AtomicString& value = attr->value();
271
    if (attr->name() == SVGNames::dAttr) {
272
    if (attr->name() == SVGNames::dAttr) {
272
        ExceptionCode ec;
273
        ExceptionCode ec;
273
        pathSegList()->clear(ec);
274
        pathSegList()->clear(ec);
274
        if (!parseSVG(attr->value(), true))
275
        if (!parseSVG(value, true))
275
            pathSegList()->clear(ec);
276
            document()->accessSVGExtensions()->reportError("Problem parsing d=\"" + value + "\"");
277
    } else if (attr->name() == SVGNames::pathLengthAttr) {
278
        m_pathLength = value.toDouble();
279
        if (m_pathLength < 0.0)
280
            document()->accessSVGExtensions()->reportError("A negative value for path attribute <pathLength> is not allowed");
276
    } else {
281
    } else {
277
        if (SVGTests::parseMappedAttribute(attr))
282
        if (SVGTests::parseMappedAttribute(attr))
278
            return;
283
            return;
- WebCore/ksvg2/svg/SVGPatternElement.cpp -3 / +7 lines
Lines 96-106 void SVGPatternElement::parseMappedAttri WebCore/ksvg2/svg/SVGPatternElement.cpp_sec1
96
        setXBaseValue(SVGLength(this, LengthModeWidth, value));
96
        setXBaseValue(SVGLength(this, LengthModeWidth, value));
97
    else if (attr->name() == SVGNames::yAttr)
97
    else if (attr->name() == SVGNames::yAttr)
98
        setYBaseValue(SVGLength(this, LengthModeHeight, value));
98
        setYBaseValue(SVGLength(this, LengthModeHeight, value));
99
    else if (attr->name() == SVGNames::widthAttr)
99
    else if (attr->name() == SVGNames::widthAttr) {
100
        setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
100
        setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
101
    else if (attr->name() == SVGNames::heightAttr)
101
        if (width().value() < 0.0)
102
            document()->accessSVGExtensions()->reportError("A negative value for pattern attribute <width> is not allowed");
103
    } else if (attr->name() == SVGNames::heightAttr) {
102
        setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
104
        setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
103
    else {
105
        if (width().value() < 0.0)
106
            document()->accessSVGExtensions()->reportError("A negative value for pattern attribute <height> is not allowed");
107
    } else {
104
        if (SVGURIReference::parseMappedAttribute(attr))
108
        if (SVGURIReference::parseMappedAttribute(attr))
105
            return;
109
            return;
106
        if (SVGTests::parseMappedAttribute(attr))
110
        if (SVGTests::parseMappedAttribute(attr))
- WebCore/ksvg2/svg/SVGPolyElement.cpp -2 / +4 lines
Lines 1-6 WebCore/ksvg2/svg/SVGPolyElement.cpp_sec1
1
/*
1
/*
2
    Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2
    Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
3
                  2004, 2005, 2006 Rob Buis <buis@kde.org>
3
                  2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4
4
5
    This file is part of the KDE project
5
    This file is part of the KDE project
6
6
Lines 62-71 SVGPointList* SVGPolyElement::animatedPo WebCore/ksvg2/svg/SVGPolyElement.cpp_sec2
62
62
63
void SVGPolyElement::parseMappedAttribute(MappedAttribute* attr)
63
void SVGPolyElement::parseMappedAttribute(MappedAttribute* attr)
64
{
64
{
65
    const AtomicString& value = attr->value();
65
    if (attr->name() == SVGNames::pointsAttr) {
66
    if (attr->name() == SVGNames::pointsAttr) {
66
        ExceptionCode ec = 0;
67
        ExceptionCode ec = 0;
67
        points()->clear(ec);
68
        points()->clear(ec);
68
        parsePoints(attr->value());
69
        if (!parsePoints(value) && !m_ignoreAttributeChanges)
70
            document()->accessSVGExtensions()->reportError("Problem parsing points=\"" + value + "\"");
69
    } else {
71
    } else {
70
        if (SVGTests::parseMappedAttribute(attr))
72
        if (SVGTests::parseMappedAttribute(attr))
71
            return;
73
            return;
- WebCore/ksvg2/svg/SVGRadialGradientElement.cpp -2 / +4 lines
Lines 67-75 void SVGRadialGradientElement::parseMapp WebCore/ksvg2/svg/SVGRadialGradientElement.cpp_sec1
67
        setCxBaseValue(SVGLength(this, LengthModeWidth, value));
67
        setCxBaseValue(SVGLength(this, LengthModeWidth, value));
68
    else if (attr->name() == SVGNames::cyAttr)
68
    else if (attr->name() == SVGNames::cyAttr)
69
        setCyBaseValue(SVGLength(this, LengthModeHeight, value));
69
        setCyBaseValue(SVGLength(this, LengthModeHeight, value));
70
    else if (attr->name() == SVGNames::rAttr)
70
    else if (attr->name() == SVGNames::rAttr) {
71
        setRBaseValue(SVGLength(this, LengthModeOther, value));
71
        setRBaseValue(SVGLength(this, LengthModeOther, value));
72
    else if (attr->name() == SVGNames::fxAttr)
72
        if (r().value() < 0.0)
73
            document()->accessSVGExtensions()->reportError("A negative value for radial gradient radius <r> is not allowed");
74
    } else if (attr->name() == SVGNames::fxAttr)
73
        setFxBaseValue(SVGLength(this, LengthModeWidth, value));
75
        setFxBaseValue(SVGLength(this, LengthModeWidth, value));
74
    else if (attr->name() == SVGNames::fyAttr)
76
    else if (attr->name() == SVGNames::fyAttr)
75
        setFyBaseValue(SVGLength(this, LengthModeHeight, value));
77
        setFyBaseValue(SVGLength(this, LengthModeHeight, value));
- WebCore/ksvg2/svg/SVGRectElement.cpp -7 / +14 lines
Lines 61-75 void SVGRectElement::parseMappedAttribut WebCore/ksvg2/svg/SVGRectElement.cpp_sec1
61
        setXBaseValue(SVGLength(this, LengthModeWidth, value));
61
        setXBaseValue(SVGLength(this, LengthModeWidth, value));
62
    else if (attr->name() == SVGNames::yAttr)
62
    else if (attr->name() == SVGNames::yAttr)
63
        setYBaseValue(SVGLength(this, LengthModeHeight, value));
63
        setYBaseValue(SVGLength(this, LengthModeHeight, value));
64
    else if (attr->name() == SVGNames::rxAttr)
64
    else if (attr->name() == SVGNames::rxAttr) {
65
         setRxBaseValue(SVGLength(this, LengthModeWidth, value));
65
        setRxBaseValue(SVGLength(this, LengthModeWidth, value));
66
    else if (attr->name() == SVGNames::ryAttr)
66
            document()->accessSVGExtensions()->reportError("A negative value for rect <rx> is not allowed");
67
         setRyBaseValue(SVGLength(this, LengthModeHeight, value));
67
    } else if (attr->name() == SVGNames::ryAttr) {
68
    else if (attr->name() == SVGNames::widthAttr)
68
        setRyBaseValue(SVGLength(this, LengthModeHeight, value));
69
        if (ry().value() < 0.0)
70
            document()->accessSVGExtensions()->reportError("A negative value for rect <ry> is not allowed");
71
    } else if (attr->name() == SVGNames::widthAttr) {
69
        setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
72
        setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
70
    else if (attr->name() == SVGNames::heightAttr)
73
        if (width().value() < 0.0)
74
            document()->accessSVGExtensions()->reportError("A negative value for rect <width> is not allowed");
75
    } else if (attr->name() == SVGNames::heightAttr) {
71
        setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
76
        setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
72
    else {
77
        if (height().value() < 0.0)
78
            document()->accessSVGExtensions()->reportError("A negative value for rect <height> is not allowed");
79
    } else {
73
        if (SVGTests::parseMappedAttribute(attr))
80
        if (SVGTests::parseMappedAttribute(attr))
74
            return;
81
            return;
75
        if (SVGLangSpace::parseMappedAttribute(attr))
82
        if (SVGLangSpace::parseMappedAttribute(attr))
- WebCore/ksvg2/svg/SVGSVGElement.cpp +4 lines
Lines 196-204 void SVGSVGElement::parseMappedAttribute WebCore/ksvg2/svg/SVGSVGElement.cpp_sec1
196
    else if (attr->name() == SVGNames::widthAttr) {
196
    else if (attr->name() == SVGNames::widthAttr) {
197
        setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
197
        setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
198
        addCSSProperty(attr, CSS_PROP_WIDTH, value);
198
        addCSSProperty(attr, CSS_PROP_WIDTH, value);
199
        if (width().value() < 0.0)
200
            document()->accessSVGExtensions()->reportError("A negative value for svg attribute <width> is not allowed");
199
    } else if (attr->name() == SVGNames::heightAttr) {
201
    } else if (attr->name() == SVGNames::heightAttr) {
200
        setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
202
        setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
201
        addCSSProperty(attr, CSS_PROP_HEIGHT, value);
203
        addCSSProperty(attr, CSS_PROP_HEIGHT, value);
204
        if (height().value() < 0.0)
205
            document()->accessSVGExtensions()->reportError("A negative value for svg attribute <height> is not allowed");
202
    } else {
206
    } else {
203
        if (SVGTests::parseMappedAttribute(attr))
207
        if (SVGTests::parseMappedAttribute(attr))
204
            return;
208
            return;
- WebCore/ksvg2/svg/SVGTextContentElement.cpp -1 / +6 lines
Lines 94-103 void SVGTextContentElement::selectSubStr WebCore/ksvg2/svg/SVGTextContentElement.cpp_sec1
94
94
95
void SVGTextContentElement::parseMappedAttribute(MappedAttribute* attr)
95
void SVGTextContentElement::parseMappedAttribute(MappedAttribute* attr)
96
{
96
{
97
    const AtomicString& value = attr->value();
97
    //if (attr->name() == SVGNames::lengthAdjustAttr)
98
    //if (attr->name() == SVGNames::lengthAdjustAttr)
98
    //    setXBaseValue(SVGLength(this, LengthModeWidth, value));
99
    //    setXBaseValue(SVGLength(this, LengthModeWidth, value));
99
    //else
100
    //else
100
    {
101
    if (attr->name() == SVGNames::textLengthAttr) {
102
        setTextLengthBaseValue(SVGLength(this, LengthModeOther, value));
103
        if (textLength().value() < 0.0)
104
            document()->accessSVGExtensions()->reportError("A negative value for text attribute <textLength> is not allowed");
105
    } else {
101
        if (SVGTests::parseMappedAttribute(attr))
106
        if (SVGTests::parseMappedAttribute(attr))
102
            return;
107
            return;
103
        if (SVGLangSpace::parseMappedAttribute(attr))
108
        if (SVGLangSpace::parseMappedAttribute(attr))
- WebCore/ksvg2/svg/SVGUseElement.cpp -3 / +7 lines
Lines 66-76 void SVGUseElement::parseMappedAttribute WebCore/ksvg2/svg/SVGUseElement.cpp_sec1
66
        setXBaseValue(SVGLength(this, LengthModeWidth, value));
66
        setXBaseValue(SVGLength(this, LengthModeWidth, value));
67
    else if (attr->name() == SVGNames::yAttr)
67
    else if (attr->name() == SVGNames::yAttr)
68
        setYBaseValue(SVGLength(this, LengthModeHeight, value));
68
        setYBaseValue(SVGLength(this, LengthModeHeight, value));
69
    else if (attr->name() == SVGNames::widthAttr)
69
    else if (attr->name() == SVGNames::widthAttr) {
70
        setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
70
        setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
71
    else if (attr->name() == SVGNames::heightAttr)
71
        if (width().value() < 0.0)
72
            document()->accessSVGExtensions()->reportError("A negative value for use attribute <width> is not allowed");
73
    } else if (attr->name() == SVGNames::heightAttr) {
72
        setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
74
        setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
73
    else {
75
        if (height().value() < 0.0)
76
            document()->accessSVGExtensions()->reportError("A negative value for use attribute <height> is not allowed");
77
    } else {
74
        if (SVGTests::parseMappedAttribute(attr))
78
        if (SVGTests::parseMappedAttribute(attr))
75
            return;
79
            return;
76
        if (SVGLangSpace::parseMappedAttribute(attr))
80
        if (SVGLangSpace::parseMappedAttribute(attr))

Return to Bug 10362