| Differences between
and this patch
- WebCore/ChangeLog +62 lines
Lines 1-3 WebCore/ChangeLog_sec1
1
2008-04-06  Vincent Ricard  <magic@magicninja.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Bug 6503: content property doesn't support quotes
6
7
        Tests: fast/css-generated-content/css-quotes-1.html
8
               fast/css-generated-content/css-quotes-2.html
9
               fast/css-generated-content/css-quotes-3.html
10
               fast/css-generated-content/css-quotes-4.html
11
               fast/css-generated-content/css-quotes-5.html
12
13
        * WebCore.pro:
14
        * css/CSSParser.cpp:
15
        (WebCore::CSSParser::parseValue):
16
        (WebCore::CSSParser::parseContent):
17
        (WebCore::CSSParser::parseQuotes):
18
        * css/CSSParser.h:
19
        * css/CSSStyleSelector.cpp:
20
        (WebCore::CSSStyleSelector::applyProperty):
21
        * css/QuotesValue.cpp: Added.
22
        (WebCore::QuotesValue::QuotesValue):
23
        (WebCore::quoteString):
24
        (WebCore::QuotesValue::cssText):
25
        * css/QuotesValue.h: Added.
26
        * css/html4.css:
27
        * rendering/RenderContainer.cpp:
28
        (WebCore::RenderContainer::updateBeforeAfterContentForContainer):
29
        * rendering/RenderObject.h:
30
        (WebCore::RenderObject::isQuote):
31
        * rendering/RenderQuote.cpp: Added.
32
        (WebCore::RenderQuote::RenderQuote):
33
        (WebCore::RenderQuote::renderName):
34
        (WebCore::RenderQuote::isQuote):
35
        (WebCore::RenderQuote::computeLevel):
36
        (WebCore::RenderQuote::originalText):
37
        (WebCore::RenderQuote::dirtyLineBoxes):
38
        (WebCore::RenderQuote::calcPrefWidths):
39
        * rendering/RenderQuote.h: Added.
40
        (WebCore::RenderQuote::isVisible):
41
        * rendering/RenderStyle.cpp:
42
        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
43
        (WebCore::StyleRareInheritedData::~StyleRareInheritedData):
44
        (WebCore::StyleRareInheritedData::operator==):
45
        (WebCore::StyleRareInheritedData::quotesDataEquivalent):
46
        (WebCore::RenderStyle::contentDataEquivalent):
47
        (WebCore::RenderStyle::setContent):
48
        (WebCore::ContentData::clear):
49
        (WebCore::QuotesData::addLevel):
50
        (WebCore::QuotesData::openQuote):
51
        (WebCore::QuotesData::closeQuote):
52
        (WebCore::QuotesData::operator==):
53
        * rendering/RenderStyle.h:
54
        (WebCore::):
55
        (WebCore::ContentData::):
56
        (WebCore::QuotesData::QuotesData):
57
        (WebCore::QuotesData::operator!=):
58
        (WebCore::RenderStyle::quotes):
59
        (WebCore::RenderStyle::setQuotes):
60
        (WebCore::RenderStyle::quotesData):
61
        (WebCore::RenderStyle::initialQuotes):
62
1
2008-04-05  Kevin Ollivier  <kevino@theolliviers.com>
63
2008-04-05  Kevin Ollivier  <kevino@theolliviers.com>
2
64
3
        Reviewed by Mark Rowe.
65
        Reviewed by Mark Rowe.
- WebCore/WebCore.pro +2 lines
Lines 507-512 SOURCES += \ WebCore/WebCore.pro_sec1
507
    css/MediaQuery.cpp \
507
    css/MediaQuery.cpp \
508
    css/MediaQueryEvaluator.cpp \
508
    css/MediaQueryEvaluator.cpp \
509
    css/MediaQueryExp.cpp \
509
    css/MediaQueryExp.cpp \
510
    css/QuotesValue.cpp \
510
    css/ShadowValue.cpp \
511
    css/ShadowValue.cpp \
511
    css/StyleBase.cpp \
512
    css/StyleBase.cpp \
512
    css/StyleList.cpp \
513
    css/StyleList.cpp \
Lines 875-880 SOURCES += \ WebCore/WebCore.pro_sec2
875
    rendering/RenderObject.cpp \
876
    rendering/RenderObject.cpp \
876
    rendering/RenderPart.cpp \
877
    rendering/RenderPart.cpp \
877
    rendering/RenderPartObject.cpp \
878
    rendering/RenderPartObject.cpp \
879
    rendering/RenderQuote.cpp \
878
    rendering/RenderReplaced.cpp \
880
    rendering/RenderReplaced.cpp \
879
    rendering/RenderSlider.cpp \
881
    rendering/RenderSlider.cpp \
880
    rendering/RenderStyle.cpp \
882
    rendering/RenderStyle.cpp \
- WebCore/css/CSSParser.cpp -6 / +42 lines
Lines 58-63 WebCore/css/CSSParser.cpp_sec1
58
#include "MediaList.h"
58
#include "MediaList.h"
59
#include "MediaQueryExp.h"
59
#include "MediaQueryExp.h"
60
#include "Pair.h"
60
#include "Pair.h"
61
#include "QuotesValue.h"
61
#include "ShadowValue.h"
62
#include "ShadowValue.h"
62
#include <kjs/dtoa.h>
63
#include <kjs/dtoa.h>
63
64
Lines 566-572 bool CSSParser::parseValue(int propId, b WebCore/css/CSSParser.cpp_sec2
566
         */
567
         */
567
568
568
    case CSSPropertySize:                 // <length>{1,2} | auto | portrait | landscape | inherit
569
    case CSSPropertySize:                 // <length>{1,2} | auto | portrait | landscape | inherit
569
    case CSSPropertyQuotes:               // [<string> <string>]+ | none | inherit
570
        if (id)
570
        if (id)
571
            valid_primitive = true;
571
            valid_primitive = true;
572
        break;
572
        break;
Lines 1035-1040 bool CSSParser::parseValue(int propId, b WebCore/css/CSSParser.cpp_sec3
1035
            return parseCounter(propId, 0, important);
1035
            return parseCounter(propId, 0, important);
1036
        valid_primitive = true;
1036
        valid_primitive = true;
1037
        break;
1037
        break;
1038
    case CSSPropertyQuotes:               // [<string> <string>]+ | none | inherit
1039
        if (id != CSSValueNone)
1040
            return parseQuotes(propId, important);
1041
        valid_primitive = true;
1042
        break;
1038
    case CSSPropertyFontFamily:
1043
    case CSSPropertyFontFamily:
1039
        // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit
1044
        // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit
1040
    {
1045
    {
Lines 1880-1890 bool CSSParser::parseContent(int propId, WebCore/css/CSSParser.cpp_sec4
1880
            } else
1885
            } else
1881
                return false;
1886
                return false;
1882
        } else if (val->unit == CSSPrimitiveValue::CSS_IDENT) {
1887
        } else if (val->unit == CSSPrimitiveValue::CSS_IDENT) {
1883
            // open-quote
1888
            // open-quote | close-quote | no-open-quote | no-close-quote
1884
            // close-quote
1889
            if (val->id == CSSValueOpenQuote || val->id == CSSValueCloseQuote ||
1885
            // no-open-quote
1890
                val->id == CSSValueNoOpenQuote || val->id == CSSValueNoCloseQuote) {
1886
            // no-close-quote
1891
                parsedValue = new CSSPrimitiveValue(val->id);
1887
            // FIXME: These are not yet implemented (http://bugs.webkit.org/show_bug.cgi?id=6503).
1892
            }
1888
        } else if (val->unit == CSSPrimitiveValue::CSS_STRING) {
1893
        } else if (val->unit == CSSPrimitiveValue::CSS_STRING) {
1889
            parsedValue = new CSSPrimitiveValue(val->string, CSSPrimitiveValue::CSS_STRING);
1894
            parsedValue = new CSSPrimitiveValue(val->string, CSSPrimitiveValue::CSS_STRING);
1890
        }
1895
        }
Lines 1903-1908 bool CSSParser::parseContent(int propId, WebCore/css/CSSParser.cpp_sec5
1903
    return false;
1908
    return false;
1904
}
1909
}
1905
1910
1911
// [<string> <string>]+ | inherit
1912
bool CSSParser::parseQuotes(int propId, bool important)
1913
{
1914
    RefPtr<CSSValueList> values = new CSSValueList(true);
1915
1916
    Value* value1 = 0;
1917
    Value* value2 = 0;
1918
    while (value1 = valueList->current()) {
1919
        if (value1->unit == CSSPrimitiveValue::CSS_STRING) {
1920
            value2 = valueList->next();
1921
            if (value2 && value2->unit == CSSPrimitiveValue::CSS_STRING) {
1922
                values->append(new QuotesValue(value1->string, value2->string));
1923
            } else
1924
                break;
1925
        } else
1926
            break;
1927
1928
        value2 = 0;
1929
        valueList->next();
1930
    }
1931
1932
    if (values->length()) {
1933
        addProperty(propId, values.release(), important);
1934
        if (value2)
1935
            valueList->next();
1936
        return true;
1937
    }
1938
1939
    return false;
1940
}
1941
1906
PassRefPtr<CSSValue> CSSParser::parseBackgroundColor()
1942
PassRefPtr<CSSValue> CSSParser::parseBackgroundColor()
1907
{
1943
{
1908
    int id = valueList->current()->id;
1944
    int id = valueList->current()->id;
- WebCore/css/CSSParser.h +2 lines
Lines 154-159 namespace WebCore { WebCore/css/CSSParser.h_sec1
154
        bool parseCounter(int propId, int defaultValue, bool important);
154
        bool parseCounter(int propId, int defaultValue, bool important);
155
        PassRefPtr<CSSValue> parseCounterContent(ValueList* args, bool counters);
155
        PassRefPtr<CSSValue> parseCounterContent(ValueList* args, bool counters);
156
156
157
        bool parseQuotes(int propId, bool important);
158
157
        bool parseColorParameters(Value*, int* colorValues, bool parseAlpha);
159
        bool parseColorParameters(Value*, int* colorValues, bool parseAlpha);
158
        bool parseHSLParameters(Value*, double* colorValues, bool parseAlpha);
160
        bool parseHSLParameters(Value*, double* colorValues, bool parseAlpha);
159
        PassRefPtr<CSSPrimitiveValue> parseColor(Value* = 0);
161
        PassRefPtr<CSSPrimitiveValue> parseColor(Value* = 0);
- WebCore/css/CSSStyleSelector.cpp -1 / +42 lines
Lines 58-63 WebCore/css/CSSStyleSelector.cpp_sec1
58
#include "Page.h"
58
#include "Page.h"
59
#include "PageGroup.h"
59
#include "PageGroup.h"
60
#include "Pair.h"
60
#include "Pair.h"
61
#include "QuotesValue.h"
61
#include "Rect.h"
62
#include "Rect.h"
62
#include "RenderTheme.h"
63
#include "RenderTheme.h"
63
#include "SelectionController.h"
64
#include "SelectionController.h"
Lines 3407-3412 void CSSStyleSelector::applyProperty(int WebCore/css/CSSStyleSelector.cpp_sec2
3407
                        (EListStyleType)counterValue->listStyleNumber(), counterValue->separator());
3408
                        (EListStyleType)counterValue->listStyleNumber(), counterValue->separator());
3408
                    m_style->setContent(counter, didSet);
3409
                    m_style->setContent(counter, didSet);
3409
                    didSet = true;
3410
                    didSet = true;
3411
                    break;
3412
                }
3413
                case CSSPrimitiveValue::CSS_IDENT: {
3414
                    switch (val->getIdent()) {
3415
                        case CSSValueOpenQuote:
3416
                            m_style->setContent(OPEN_QUOTE, didSet);
3417
                            break;
3418
                        case CSSValueCloseQuote:
3419
                            m_style->setContent(CLOSE_QUOTE, didSet);
3420
                            break;
3421
                        case CSSValueNoOpenQuote:
3422
                            m_style->setContent(NO_OPEN_QUOTE, didSet);
3423
                            break;
3424
                        case CSSValueNoCloseQuote:
3425
                            m_style->setContent(NO_CLOSE_QUOTE, didSet);
3426
                            break;
3427
                        default:
3428
                            ASSERT_NOT_REACHED();
3429
                    }
3430
                    didSet = true;
3431
                    break;
3410
                }
3432
                }
3411
            }
3433
            }
3412
        }
3434
        }
Lines 3422-3427 void CSSStyleSelector::applyProperty(int WebCore/css/CSSStyleSelector.cpp_sec3
3422
        applyCounterList(m_style, value->isValueList() ? static_cast<CSSValueList*>(value) : 0, true);
3444
        applyCounterList(m_style, value->isValueList() ? static_cast<CSSValueList*>(value) : 0, true);
3423
        return;
3445
        return;
3424
3446
3447
    case CSSPropertyQuotes:
3448
        HANDLE_INHERIT_AND_INITIAL(quotes, Quotes);
3449
        if (primitiveValue && primitiveValue->getIdent() == CSSValueNone) {
3450
            m_style->setQuotes(0);
3451
        } else {
3452
            if (!value->isValueList())
3453
                return;
3454
3455
            CSSValueList *list = static_cast<CSSValueList*>(value);
3456
            int len = list->length();
3457
            QuotesData *quotes = new QuotesData;
3458
            for (int i = 0; i < len; i++) {
3459
                CSSValue *item = list->item(i);
3460
                QuotesValue *val = static_cast<QuotesValue*>(item);
3461
                quotes->addLevel(val->m_openQuote, val->m_closeQuote);
3462
            }
3463
            m_style->setQuotes(quotes);
3464
        }
3465
        return;
3466
3425
    case CSSPropertyFontFamily: {
3467
    case CSSPropertyFontFamily: {
3426
        // list of strings and ids
3468
        // list of strings and ids
3427
        if (isInherit) {
3469
        if (isInherit) {
Lines 4538-4544 void CSSStyleSelector::applyProperty(int WebCore/css/CSSStyleSelector.cpp_sec4
4538
        return;
4580
        return;
4539
    case CSSPropertyFontStretch:
4581
    case CSSPropertyFontStretch:
4540
    case CSSPropertyPage:
4582
    case CSSPropertyPage:
4541
    case CSSPropertyQuotes:
4542
    case CSSPropertyScrollbar3dlightColor:
4583
    case CSSPropertyScrollbar3dlightColor:
4543
    case CSSPropertyScrollbarArrowColor:
4584
    case CSSPropertyScrollbarArrowColor:
4544
    case CSSPropertyScrollbarDarkshadowColor:
4585
    case CSSPropertyScrollbarDarkshadowColor:
- WebCore/css/QuotesValue.cpp +56 lines
Line 0 WebCore/css/QuotesValue.cpp_sec1
1
/*
2
 * Copyright (C) 2008 Vincent Ricard (magic@magicninja.org)
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 *
19
 */
20
21
#include "config.h"
22
#include "QuotesValue.h"
23
24
#include "CSSPrimitiveValue.h"
25
#include "PlatformString.h"
26
27
namespace WebCore {
28
29
QuotesValue::QuotesValue(const String& openQuote,
30
    const String& closeQuote)
31
    : m_openQuote(openQuote)
32
    , m_closeQuote(closeQuote)
33
{
34
}
35
36
// FIXME: we should use the version present in with CSSPrimitiveValue.cpp
37
static String quoteString(const String& string)
38
{
39
    String quotedString = string;
40
    quotedString.replace('\\', "\\\\");
41
    quotedString.replace('\'', "\\'");
42
    return "'" + quotedString + "'";
43
}
44
45
String QuotesValue::cssText() const
46
{
47
    String result("");
48
49
    result += quoteString(m_openQuote);
50
    result += " ";
51
    result += quoteString(m_closeQuote);
52
53
    return result;
54
}
55
56
}
- WebCore/css/QuotesValue.h +44 lines
Line 0 WebCore/css/QuotesValue.h_sec1
1
/*
2
 * Copyright (C) 2008 Vincent Ricard (magic@magicninja.org)
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 *
19
 */
20
21
#ifndef QuotesValue_h
22
#define QuotesValue_h
23
24
#include "CSSValue.h"
25
#include "PlatformString.h"
26
27
namespace WebCore {
28
29
class String;
30
31
class QuotesValue : public CSSValue
32
{
33
public:
34
    QuotesValue(const String& openQuote, const String& closeQuote);
35
36
    virtual String cssText() const;
37
38
    String m_openQuote;
39
    String m_closeQuote;
40
};
41
42
} // namespace
43
44
#endif
- WebCore/css/html4.css -5 / +4 lines
Lines 87-103 blockquote { WebCore/css/html4.css_sec1
87
}
87
}
88
88
89
q {
89
q {
90
    display: inline
90
    display: inline;
91
    quotes: '\201C' '\201D' '\2018' '\2019'
91
}
92
}
92
93
93
q:before {
94
q:before {
94
    content: '"'
95
    content: open-quote
95
    /* FIXME: content: open-quote; */
96
}
96
}
97
97
98
q:after {
98
q:after {
99
    content: '"'
99
    content: close-quote
100
    /* FIXME: content: close-quote; */
101
}
100
}
102
101
103
center {
102
center {
- WebCore/rendering/RenderContainer.cpp +5 lines
Lines 32-37 WebCore/rendering/RenderContainer.cpp_sec1
32
#include "RenderImage.h"
32
#include "RenderImage.h"
33
#include "RenderLayer.h"
33
#include "RenderLayer.h"
34
#include "RenderListItem.h"
34
#include "RenderListItem.h"
35
#include "RenderQuote.h"
35
#include "RenderTable.h"
36
#include "RenderTable.h"
36
#include "RenderTextFragment.h"
37
#include "RenderTextFragment.h"
37
#include "RenderView.h"
38
#include "RenderView.h"
Lines 352-357 void RenderContainer::updateBeforeAfterC WebCore/rendering/RenderContainer.cpp_sec2
352
                renderer = new (renderArena()) RenderCounter(document(), *content->m_content.m_counter);
353
                renderer = new (renderArena()) RenderCounter(document(), *content->m_content.m_counter);
353
                renderer->setStyle(pseudoElementStyle);
354
                renderer->setStyle(pseudoElementStyle);
354
                break;
355
                break;
356
            case CONTENT_QUOTE:
357
                renderer = new (renderArena()) RenderQuote(document(), content->m_content.m_quote);
358
                renderer->setStyle(pseudoElementStyle);
359
                break;
355
        }
360
        }
356
361
357
        if (renderer) {
362
        if (renderer) {
- WebCore/rendering/RenderObject.h +1 lines
Lines 266-271 public: WebCore/rendering/RenderObject.h_sec1
266
    virtual bool isListItem() const { return false; }
266
    virtual bool isListItem() const { return false; }
267
    virtual bool isListMarker() const { return false; }
267
    virtual bool isListMarker() const { return false; }
268
    virtual bool isCounter() const { return false; }
268
    virtual bool isCounter() const { return false; }
269
    virtual bool isQuote() const { return false; }
269
    virtual bool isRenderView() const { return false; }
270
    virtual bool isRenderView() const { return false; }
270
    virtual bool isBR() const { return false; }
271
    virtual bool isBR() const { return false; }
271
    virtual bool isTableCell() const { return false; }
272
    virtual bool isTableCell() const { return false; }
- WebCore/rendering/RenderQuote.cpp +117 lines
Line 0 WebCore/rendering/RenderQuote.cpp_sec1
1
/*
2
 * Copyright (C) 2008 Vincent Ricard (magic@magicninja.org)
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 *
19
 */
20
21
#include "config.h"
22
#include "RenderQuote.h"
23
24
namespace WebCore {
25
26
RenderQuote::RenderQuote(Document* node, QuoteContent quote)
27
    : RenderText(node, StringImpl::empty())
28
    , m_quote(quote)
29
    , m_needsComputeLevel(true)
30
    , m_level(0)
31
{
32
}
33
34
const char* RenderQuote::renderName() const
35
{
36
    return "RenderQuote";
37
}
38
39
bool RenderQuote::isQuote() const
40
{
41
    return true;
42
}
43
44
void RenderQuote::computeLevel() const
45
{
46
    int level = 0;
47
48
    const RenderObject* previousObject = this;
49
    while ((previousObject = previousObject->previousInPreOrder())) {
50
        if (previousObject->isQuote()) {
51
            const RenderQuote* previousQuote = static_cast<const RenderQuote*>(previousObject);
52
            switch (previousQuote->m_quote) {
53
            case OPEN_QUOTE:
54
            case NO_OPEN_QUOTE:
55
                ++level;
56
                break;
57
            case CLOSE_QUOTE:
58
            case NO_CLOSE_QUOTE:
59
                --level;
60
                break;
61
            }
62
        }
63
    }
64
65
    // If we are a 'close-quote', we have to decrement the level
66
    if (m_quote == CLOSE_QUOTE || m_quote == NO_CLOSE_QUOTE) {
67
        --level;
68
    }
69
70
    m_level = level;
71
    m_needsComputeLevel = false;
72
}
73
74
PassRefPtr<StringImpl> RenderQuote::originalText() const
75
{
76
    String quote("");
77
78
    if (!parent())
79
        return quote.impl();
80
81
    if (!m_quote)
82
        return quote.impl();
83
84
    // Compute level
85
    if (m_needsComputeLevel)
86
        computeLevel();
87
88
    // We need the level to check the visibility of the quote
89
    if (!isVisible())
90
        return quote.impl();
91
92
    QuotesData *quotes = style()->quotes();
93
    if (quotes) {
94
        if (m_quote == OPEN_QUOTE)
95
            quote += quotes->openQuote(m_level);
96
        else
97
            quote += quotes->closeQuote(m_level);
98
    }
99
    // else we have "quotes: none;", so we MUST NOT produce quotation mark
100
101
    return quote.impl();
102
}
103
104
void RenderQuote::dirtyLineBoxes(bool fullLayout, bool dummy)
105
{
106
    if (prefWidthsDirty())
107
        calcPrefWidths(0);
108
    RenderText::dirtyLineBoxes(fullLayout, dummy);
109
}
110
111
void RenderQuote::calcPrefWidths(int lead)
112
{
113
    setTextInternal(originalText());
114
    RenderText::calcPrefWidths(lead);
115
}
116
117
} // namespace WebCore
- WebCore/rendering/RenderQuote.h +50 lines
Line 0 WebCore/rendering/RenderQuote.h_sec1
1
/*
2
 * Copyright (C) 2008 Vincent Ricard (magic@magicninja.org)
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public License
15
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 * Boston, MA 02110-1301, USA.
18
 *
19
 */
20
21
#ifndef RenderQuote_h
22
#define RenderQuote_h
23
24
#include "RenderText.h"
25
26
namespace WebCore {
27
28
class RenderQuote : public RenderText {
29
public:
30
    RenderQuote(Document*, QuoteContent);
31
32
    virtual const char* renderName() const;
33
    virtual bool isQuote() const;
34
    virtual PassRefPtr<StringImpl> originalText() const;
35
36
    virtual void dirtyLineBoxes(bool, bool);
37
    virtual void calcPrefWidths(int leadWidth);
38
39
private:
40
    bool isVisible() const { return (m_quote == OPEN_QUOTE || m_quote == CLOSE_QUOTE) && 0 <= m_level; }
41
    void computeLevel() const;
42
43
    QuoteContent m_quote;
44
    mutable bool m_needsComputeLevel;
45
    mutable int m_level;
46
};
47
48
} // namespace WebCore
49
50
#endif // RenderQuote_h
- WebCore/rendering/RenderStyle.cpp -1 / +81 lines
Lines 779-784 StyleRareInheritedData::StyleRareInherit WebCore/rendering/RenderStyle.cpp_sec1
779
    , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
779
    , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
780
    , resize(RenderStyle::initialResize())
780
    , resize(RenderStyle::initialResize())
781
    , userSelect(RenderStyle::initialUserSelect())
781
    , userSelect(RenderStyle::initialUserSelect())
782
    , m_quotes(RenderStyle::initialQuotes())
782
{
783
{
783
}
784
}
784
785
Lines 798-809 StyleRareInheritedData::StyleRareInherit WebCore/rendering/RenderStyle.cpp_sec2
798
    , textSizeAdjust(o.textSizeAdjust)
799
    , textSizeAdjust(o.textSizeAdjust)
799
    , resize(o.resize)
800
    , resize(o.resize)
800
    , userSelect(o.userSelect)
801
    , userSelect(o.userSelect)
802
    , m_quotes(o.m_quotes ? new QuotesData(*o.m_quotes) : RenderStyle::initialQuotes())
801
{
803
{
802
}
804
}
803
805
804
StyleRareInheritedData::~StyleRareInheritedData()
806
StyleRareInheritedData::~StyleRareInheritedData()
805
{
807
{
806
    delete textShadow;
808
    delete textShadow;
809
    delete m_quotes;
807
}
810
}
808
811
809
bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
812
bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
Lines 820-826 bool StyleRareInheritedData::operator==( WebCore/rendering/RenderStyle.cpp_sec3
820
        && nbspMode == o.nbspMode
823
        && nbspMode == o.nbspMode
821
        && khtmlLineBreak == o.khtmlLineBreak
824
        && khtmlLineBreak == o.khtmlLineBreak
822
        && textSizeAdjust == o.textSizeAdjust
825
        && textSizeAdjust == o.textSizeAdjust
823
        && userSelect == o.userSelect;
826
        && userSelect == o.userSelect
827
        && quotesDataEquivalent(o);
824
}
828
}
825
829
826
bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
830
bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
Lines 832-837 bool StyleRareInheritedData::shadowDataE WebCore/rendering/RenderStyle.cpp_sec4
832
    return true;
836
    return true;
833
}
837
}
834
838
839
bool StyleRareInheritedData::quotesDataEquivalent(const StyleRareInheritedData& o) const
840
{
841
    if (!m_quotes && o.m_quotes || m_quotes && !o.m_quotes)
842
        return false;
843
    if (m_quotes && o.m_quotes && (*m_quotes != *o.m_quotes))
844
        return false;
845
    return true;
846
}
847
835
StyleInheritedData::StyleInheritedData()
848
StyleInheritedData::StyleInheritedData()
836
    : indent(RenderStyle::initialTextIndent())
849
    : indent(RenderStyle::initialTextIndent())
837
    , line_height(RenderStyle::initialLineHeight())
850
    , line_height(RenderStyle::initialLineHeight())
Lines 1394-1399 bool RenderStyle::contentDataEquivalent( WebCore/rendering/RenderStyle.cpp_sec5
1394
                if (*c1->m_content.m_counter != *c2->m_content.m_counter)
1407
                if (*c1->m_content.m_counter != *c2->m_content.m_counter)
1395
                    return false;
1408
                    return false;
1396
                break;
1409
                break;
1410
            case CONTENT_QUOTE:
1411
                if (c1->m_content.m_quote != c2->m_content.m_quote)
1412
                    return false;
1413
                break;
1397
        }
1414
        }
1398
1415
1399
        c1 = c1->m_next;
1416
        c1 = c1->m_next;
Lines 1504-1509 void RenderStyle::setContent(CounterCont WebCore/rendering/RenderStyle.cpp_sec6
1504
    newContentData->m_type = CONTENT_COUNTER;
1521
    newContentData->m_type = CONTENT_COUNTER;
1505
}
1522
}
1506
1523
1524
void RenderStyle::setContent(QuoteContent q, bool add)
1525
{
1526
    if (!q)
1527
        return;
1528
1529
    ContentData*& content = rareNonInheritedData.access()->m_content;
1530
    ContentData* lastContent = content;
1531
    while (lastContent && lastContent->m_next)
1532
        lastContent = lastContent->m_next;
1533
1534
    bool reuseContent = !add;
1535
    ContentData* newContentData = 0;
1536
    if (reuseContent && content) {
1537
        content->clear();
1538
        newContentData = content;
1539
    } else
1540
        newContentData = new ContentData;
1541
1542
    if (lastContent && !reuseContent)
1543
        lastContent->m_next = newContentData;
1544
    else
1545
        content = newContentData;
1546
1547
    newContentData->m_content.m_quote = q;
1548
    newContentData->m_type = CONTENT_QUOTE;
1549
}
1550
1507
void ContentData::clear()
1551
void ContentData::clear()
1508
{
1552
{
1509
    switch (m_type) {
1553
    switch (m_type) {
Lines 1516-1521 void ContentData::clear() WebCore/rendering/RenderStyle.cpp_sec7
1516
        case CONTENT_COUNTER:
1560
        case CONTENT_COUNTER:
1517
            delete m_content.m_counter;
1561
            delete m_content.m_counter;
1518
            break;
1562
            break;
1563
        case CONTENT_QUOTE:
1564
            m_content.m_quote = QUOTE_NONE;
1565
            break;
1519
    }
1566
    }
1520
1567
1521
    ContentData* n = m_next;
1568
    ContentData* n = m_next;
Lines 1682-1687 CounterDirectiveMap& RenderStyle::access WebCore/rendering/RenderStyle.cpp_sec8
1682
    return *map;
1729
    return *map;
1683
}
1730
}
1684
1731
1732
void QuotesData::addLevel(const AtomicString &open, const AtomicString &close)
1733
{
1734
    m_openQuotes.append(open);
1735
    m_closeQuotes.append(close);
1736
}
1737
1738
const AtomicString QuotesData::openQuote(int level) const
1739
{
1740
    if (m_openQuotes.isEmpty())
1741
        return "";
1742
1743
    if (m_openQuotes.size() <= level)
1744
        level = m_openQuotes.size() - 1;
1745
1746
    return m_openQuotes.at(level);
1747
}
1748
1749
const AtomicString QuotesData::closeQuote(int level) const
1750
{
1751
    if (m_closeQuotes.isEmpty())
1752
        return "";
1753
1754
    if (m_closeQuotes.size() <= level)
1755
        level = m_closeQuotes.size() - 1;
1756
1757
    return m_closeQuotes.at(level);
1758
}
1759
1760
bool QuotesData::operator==(const QuotesData& o) const
1761
{
1762
    return m_openQuotes == o.m_openQuotes && m_closeQuotes == o.m_closeQuotes;
1763
}
1764
1685
const Vector<StyleDashboardRegion>& RenderStyle::initialDashboardRegions()
1765
const Vector<StyleDashboardRegion>& RenderStyle::initialDashboardRegions()
1686
{ 
1766
{ 
1687
    static Vector<StyleDashboardRegion> emptyList;
1767
    static Vector<StyleDashboardRegion> emptyList;
- WebCore/rendering/RenderStyle.h -3 / +36 lines
Lines 1039-1045 private: WebCore/rendering/RenderStyle.h_sec1
1039
};
1039
};
1040
1040
1041
enum ContentType {
1041
enum ContentType {
1042
    CONTENT_NONE, CONTENT_OBJECT, CONTENT_TEXT, CONTENT_COUNTER
1042
    CONTENT_NONE, CONTENT_OBJECT, CONTENT_TEXT, CONTENT_COUNTER, CONTENT_QUOTE
1043
};
1044
1045
enum QuoteContent {
1046
    QUOTE_NONE, OPEN_QUOTE, CLOSE_QUOTE, NO_OPEN_QUOTE, NO_CLOSE_QUOTE
1043
};
1047
};
1044
1048
1045
struct ContentData : Noncopyable {
1049
struct ContentData : Noncopyable {
Lines 1053-1062 struct ContentData : Noncopyable { WebCore/rendering/RenderStyle.h_sec2
1053
        CachedResource* m_object;
1057
        CachedResource* m_object;
1054
        StringImpl* m_text;
1058
        StringImpl* m_text;
1055
        CounterContent* m_counter;
1059
        CounterContent* m_counter;
1060
        QuoteContent m_quote;
1056
    } m_content;
1061
    } m_content;
1057
    ContentData* m_next;
1062
    ContentData* m_next;
1058
};
1063
};
1059
1064
1065
class QuotesData {
1066
public:
1067
    QuotesData() { }
1068
    QuotesData(const QuotesData& o)
1069
        : m_openQuotes(o.m_openQuotes), m_closeQuotes(o.m_closeQuotes) { }
1070
1071
    void addLevel(const AtomicString &open, const AtomicString &close);
1072
    const AtomicString openQuote(int level) const;
1073
    const AtomicString closeQuote(int level) const;
1074
1075
    bool operator==(const QuotesData& o) const;
1076
    bool operator!=(const QuotesData& o) const {
1077
        return !(*this == o);
1078
    }
1079
1080
private:
1081
    Vector<AtomicString> m_openQuotes;
1082
    Vector<AtomicString> m_closeQuotes;
1083
};
1084
1060
enum EBorderFit { BorderFitBorder, BorderFitLines };
1085
enum EBorderFit { BorderFitBorder, BorderFitLines };
1061
1086
1062
enum ETimingFunctionType { LinearTimingFunction, CubicBezierTimingFunction };
1087
enum ETimingFunctionType { LinearTimingFunction, CubicBezierTimingFunction };
Lines 1217-1222 public: WebCore/rendering/RenderStyle.h_sec3
1217
        return !(*this == o);
1242
        return !(*this == o);
1218
    }
1243
    }
1219
    bool shadowDataEquivalent(const StyleRareInheritedData&) const;
1244
    bool shadowDataEquivalent(const StyleRareInheritedData&) const;
1245
    bool quotesDataEquivalent(const StyleRareInheritedData&) const;
1220
1246
1221
    Color textStrokeColor;
1247
    Color textStrokeColor;
1222
    float textStrokeWidth;
1248
    float textStrokeWidth;
Lines 1233-1239 public: WebCore/rendering/RenderStyle.h_sec4
1233
    bool textSizeAdjust : 1; // An Apple extension.
1259
    bool textSizeAdjust : 1; // An Apple extension.
1234
    unsigned resize : 2; // EResize
1260
    unsigned resize : 2; // EResize
1235
    unsigned userSelect : 1;  // EUserSelect
1261
    unsigned userSelect : 1;  // EUserSelect
1236
    
1262
 
1263
    QuotesData* m_quotes; // The quotes list used by 'content: *-quote'
1264
1237
private:
1265
private:
1238
    StyleRareInheritedData();
1266
    StyleRareInheritedData();
1239
    StyleRareInheritedData(const StyleRareInheritedData&);
1267
    StyleRareInheritedData(const StyleRareInheritedData&);
Lines 1778-1783 public: WebCore/rendering/RenderStyle.h_sec5
1778
    EEmptyCell emptyCells() const { return static_cast<EEmptyCell>(inherited_flags._empty_cells); }
1806
    EEmptyCell emptyCells() const { return static_cast<EEmptyCell>(inherited_flags._empty_cells); }
1779
    ECaptionSide captionSide() const { return static_cast<ECaptionSide>(inherited_flags._caption_side); }
1807
    ECaptionSide captionSide() const { return static_cast<ECaptionSide>(inherited_flags._caption_side); }
1780
1808
1809
    QuotesData* quotes() const { return rareInheritedData->m_quotes; }
1781
    short counterIncrement() const { return visual->counterIncrement; }
1810
    short counterIncrement() const { return visual->counterIncrement; }
1782
    short counterReset() const { return visual->counterReset; }
1811
    short counterReset() const { return visual->counterReset; }
1783
1812
Lines 2010-2015 public: WebCore/rendering/RenderStyle.h_sec6
2010
    void setEmptyCells(EEmptyCell v) { inherited_flags._empty_cells = v; }
2039
    void setEmptyCells(EEmptyCell v) { inherited_flags._empty_cells = v; }
2011
    void setCaptionSide(ECaptionSide v) { inherited_flags._caption_side = v; }
2040
    void setCaptionSide(ECaptionSide v) { inherited_flags._caption_side = v; }
2012
2041
2042
    void setQuotes(QuotesData* v) { SET_VAR(rareInheritedData, m_quotes, v); }
2013
2043
2014
    void setCounterIncrement(short v) {  SET_VAR(visual,counterIncrement,v) }
2044
    void setCounterIncrement(short v) {  SET_VAR(visual,counterIncrement,v) }
2015
    void setCounterReset(short v) {  SET_VAR(visual,counterReset,v) }
2045
    void setCounterReset(short v) {  SET_VAR(visual,counterReset,v) }
Lines 2130-2141 public: WebCore/rendering/RenderStyle.h_sec7
2130
    SVGRenderStyle* accessSVGStyle() { return m_svgStyle.access(); }
2160
    SVGRenderStyle* accessSVGStyle() { return m_svgStyle.access(); }
2131
#endif
2161
#endif
2132
2162
2163
    const QuotesData* quotesData() const { return rareInheritedData->m_quotes; }
2133
    const ContentData* contentData() const { return rareNonInheritedData->m_content; }
2164
    const ContentData* contentData() const { return rareNonInheritedData->m_content; }
2134
    bool contentDataEquivalent(const RenderStyle* otherStyle) const;
2165
    bool contentDataEquivalent(const RenderStyle* otherStyle) const;
2135
    void clearContent();
2166
    void clearContent();
2136
    void setContent(StringImpl*, bool add = false);
2167
    void setContent(StringImpl*, bool add = false);
2137
    void setContent(CachedResource*, bool add = false);
2168
    void setContent(CachedResource*, bool add = false);
2138
    void setContent(CounterContent*, bool add = false);
2169
    void setContent(CounterContent*, bool add = false);
2170
    void setContent(QuoteContent, bool add = false);
2139
2171
2140
    const CounterDirectiveMap* counterDirectives() const;
2172
    const CounterDirectiveMap* counterDirectives() const;
2141
    CounterDirectiveMap& accessCounterDirectives();
2173
    CounterDirectiveMap& accessCounterDirectives();
Lines 2283-2289 public: WebCore/rendering/RenderStyle.h_sec8
2283
    static const TransformOperations& initialTransform() { static TransformOperations ops; return ops; }
2315
    static const TransformOperations& initialTransform() { static TransformOperations ops; return ops; }
2284
    static Length initialTransformOriginX() { return Length(50.0, Percent); }
2316
    static Length initialTransformOriginX() { return Length(50.0, Percent); }
2285
    static Length initialTransformOriginY() { return Length(50.0, Percent); }
2317
    static Length initialTransformOriginY() { return Length(50.0, Percent); }
2286
    
2318
    static QuotesData* initialQuotes() { return 0; }
2319
2287
    // Keep these at the end.
2320
    // Keep these at the end.
2288
    static int initialTransitionDuration() { return 0; }
2321
    static int initialTransitionDuration() { return 0; }
2289
    static int initialTransitionRepeatCount() { return 1; }
2322
    static int initialTransitionRepeatCount() { return 1; }
- LayoutTests/ChangeLog +13 lines
Lines 1-3 LayoutTests/ChangeLog_sec1
1
2008-04-06  Vincent Ricard  <magic@magicninja.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Testcases for
6
        Bug 6503: content property doesn't support quotes
7
8
        * fast/css-generated-content/css-quotes-1.html: Added.
9
        * fast/css-generated-content/css-quotes-2.html: Added.
10
        * fast/css-generated-content/css-quotes-3.html: Added.
11
        * fast/css-generated-content/css-quotes-4.html: Added.
12
        * fast/css-generated-content/css-quotes-5.html: Added.
13
1
2008-04-05  Rob Buis  <buis@kde.org>
14
2008-04-05  Rob Buis  <buis@kde.org>
2
15
3
        Reviewed by Eric.
16
        Reviewed by Eric.
- LayoutTests/fast/css-generated-content/css-quotes-1.html +26 lines
Line 0 LayoutTests/fast/css-generated-content/css-quotes-1.html_sec1
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
2
<html>
3
<head>
4
<title>Nested quotes</title>
5
<style type="text/css">
6
.test q {quotes: "[[[" "]]]" "((" "))" "*-" "-*";}
7
q:before {content: open-quote;}
8
q:after  {content: close-quote;}
9
span.cite:before {content: open-quote;}
10
span.cite:after  {content: close-quote;}
11
.reference {color: green;}
12
</style>
13
</head>
14
15
<body>
16
<p>Test<br>
17
<span class="test">
18
This 'p' element contains a set of nested quotes which are: <q>When I asked him about it, he said, <span class="cite">I don't remember anyone saying, <q>I need some help,</q> or else I would have helped.</span> I didn't really believe him, but what could I do?</q>
19
</span></p>
20
<p class="reference">Reference<br>
21
<span>
22
This 'p' element contains a set of nested quotes which are: [[[When I asked him about it, he said, ((I don't remember anyone saying, *-I need some help,-* or else I would have helped.)) I didn't really believe him, but what could I do?]]]
23
</span>
24
<p>
25
</body>
26
</html>
- LayoutTests/fast/css-generated-content/css-quotes-2.html +27 lines
Line 0 LayoutTests/fast/css-generated-content/css-quotes-2.html_sec1
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
2
<html>
3
<head>
4
<title>Quotes per lang</title>
5
<style type="text/css">
6
/* Specify pairs of quotes for two levels in two languages */
7
q:lang(en) { quotes: '"' '"' "'" "'" }
8
q:lang(no) { quotes: "«" "»" "<" ">" }
9
10
q:before { content: open-quote }
11
q:after  { content: close-quote }
12
13
.reference {color: green;}
14
</style>
15
</head>
16
17
<body>
18
<p>Test<br>
19
<q lang="no">Trøndere gråter når <q>Vinsjan på kaia</q> blir deklamert.</q><br>
20
<q lang="en">Quote <q>me</q>!</q>
21
</p>
22
<p class="reference">Reference<br>
23
<span>«Trøndere gråter når &lt;Vinsjan på kaia&gt; blir deklamert.»</span><br>
24
<span>"Quote 'me'!"</span>
25
<p>
26
</body>
27
</html>
- LayoutTests/fast/css-generated-content/css-quotes-3.html +24 lines
Line 0 LayoutTests/fast/css-generated-content/css-quotes-3.html_sec1
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
2
<html>
3
<head>
4
<title>More close-quote than open-quote</title>
5
<style type="text/css">
6
q { quotes: '"' '"' "'" "'" }
7
8
q:before { content: open-quote }
9
q:after  { content: close-quote }
10
span.close:after  { content: close-quote }
11
12
.reference {color: green;}
13
</style>
14
</head>
15
16
<body>
17
<p>Test<br>
18
<q>More <q>level of <span class="close">nesting</span> than defined</q> quotes</q>
19
</p>
20
<p class="reference">Reference<br>
21
<span>"More 'level of 'nesting' than defined" quotes</span>
22
<p>
23
</body>
24
</html>
- LayoutTests/fast/css-generated-content/css-quotes-4.html +31 lines
Line 0 LayoutTests/fast/css-generated-content/css-quotes-4.html_sec1
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
2
<html>
3
<head>
4
<title>no-close-quote</title>
5
<style type="text/css">
6
body { quotes: "'" "'" }
7
8
blockquote.test p:before     { content: open-quote }
9
blockquote.test p:after      { content: no-close-quote }
10
blockquote.test p:last-child:after { content: close-quote }
11
12
.reference {color: green;}
13
</style>
14
</head>
15
16
<body>
17
<p>Test</p>
18
<blockquote class="test">
19
<p>First paragraph</p>
20
<p>Second paragraph</p>
21
<p>Third paragraph</p>
22
</blockquote>
23
24
<p class="reference">Reference</p>
25
<blockquote class="reference">
26
<p>'First paragraph</p>
27
<p>'Second paragraph</p>
28
<p>'Third paragraph'</p>
29
</blockquote>
30
</body>
31
</html>
- LayoutTests/fast/css-generated-content/css-quotes-5.html +24 lines
Line 0 LayoutTests/fast/css-generated-content/css-quotes-5.html_sec1
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
2
<html>
3
<head>
4
<title>More nesting then than defines quotes</title>
5
<style type="text/css">
6
/* Specify only two levels, we'll have 3 levels of nesting */
7
q { quotes: '"' '"' "'" "'" }
8
9
q:before { content: open-quote }
10
q:after  { content: close-quote }
11
12
.reference {color: green;}
13
</style>
14
</head>
15
16
<body>
17
<p>Test<br>
18
<q>More <q>level of <q>nesting</q> than defined</q> quotes</q>
19
</p>
20
<p class="reference">Reference<br>
21
<span>"More 'level of 'nesting' than defined' quotes"</span>
22
<p>
23
</body>
24
</html>

Return to Bug 6503