Make QuotesData use a Vector of pairs
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jul 2012 02:56:09 +0000 (02:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jul 2012 02:56:09 +0000 (02:56 +0000)
commit87ca7783c50e74998d5803311a252c2ce444f96a
tree13ec15e109d965dd6e8daa2bad91edb2cb3fb0ba
parent093ea81d98496773d08504d72dc3d1ea6ef61f5a
Make QuotesData use a Vector of pairs
https://bugs.webkit.org/show_bug.cgi?id=92448

Patch by Elliott Sprehn <esprehn@gmail.com> on 2012-07-30
Reviewed by Julien Chaffraix.

Source/WebCore:

QuotesData::create returned an array of memory that contained in place instantiations
of a QuotesData and then String instances. This changes the code to use a Vector of
pairs making it safer and ensuring that quotes are always balanced. This also uses a
HashMap directly in the QuoteRenderer instead of building it on first access reducing
the amount of code needed for picking quotes by language.

Test: fast/css-generated-content/close-quote-negative-depth.html

* css/StyleResolver.cpp:
(WebCore::StyleResolver::collectMatchingRulesForList): Create pairs and use the new QuotesData API.
* rendering/RenderQuote.cpp:
(WebCore):
(WebCore::quotesDataLanguageMap): New function that returns the HashMap of languages.
(WebCore::basicQuotesData): Returns the simple form of quotes, " and '.
(WebCore::defaultQuotes): Changed to use the new map.
(WebCore::RenderQuote::styleDidChange):
(WebCore::RenderQuote::originalText): Changed to use the new getOpenQuote and getCloseQuote which ensure bounds checks.
* rendering/style/QuotesData.cpp:
(WebCore::QuotesData::create): Now returns a plain instance of QuotesData without the in place allocation.
(WebCore):
(WebCore::QuotesData::addPair): Adds an std::pair of strings ensuring quotes are always balanced.
(WebCore::QuotesData::getOpenQuote):
(WebCore::QuotesData::getCloseQuote):
(WebCore::QuotesData::equals): Renamed equals (added the s).
* rendering/style/QuotesData.h:
(WebCore::QuotesData::create):
(QuotesData):
(WebCore::QuotesData::QuotesData):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::setQuotes):
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::operator==):

LayoutTests:

Test that when quote depths go negative we do not output quotes. The expected result
is wrong right now because we output quotes in this case when we should not.

* fast/css-generated-content/close-quote-negative-depth-expected.html: Added.
* fast/css-generated-content/close-quote-negative-depth.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124157 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/css-generated-content/close-quote-negative-depth-expected.html [new file with mode: 0644]
LayoutTests/fast/css-generated-content/close-quote-negative-depth.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/rendering/RenderQuote.cpp
Source/WebCore/rendering/style/QuotesData.cpp
Source/WebCore/rendering/style/QuotesData.h
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/StyleRareInheritedData.cpp