Changeset 149700 in webkit
- Timestamp:
- May 7, 2013 4:07:14 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r149698 r149700 1 2013-05-07 Anders Carlsson <andersca@apple.com> 2 3 Begin unraveling the mess that is QuotesData 4 https://bugs.webkit.org/show_bug.cgi?id=115765 5 6 Reviewed by Andreas Kling. 7 8 Change QuotesData to be an immutable object and fix other things that are broken. 9 10 * css/StyleResolver.cpp: 11 (WebCore::StyleResolver::applyProperty): 12 QuotesData::addPair is gone. Instead, create the Vector up front and pass it to QuotesData. 13 14 * rendering/RenderQuote.cpp: 15 (WebCore::RenderQuote::originalText): 16 Update for renames. 17 18 * rendering/style/QuotesData.cpp: 19 (WebCore::QuotesData::create): 20 Remove the create overload that wasn't used. Add a new create overload that takes a Vector. 21 22 (WebCore::QuotesData::openQuote): 23 Rename this from getOpenQuote and clean it up. 24 25 (WebCore::QuotesData::closeQuote): 26 Rename this from getCloseQuote and clean it up. 27 28 (WebCore::operator==): 29 Replace the equals member function with a proper equality operator. 30 31 * rendering/style/RenderStyle.cpp: 32 (WebCore::RenderStyle::diff): 33 Stop calling QuotesData::equals. Use the same idiom as used for other properties. 34 35 (WebCore::RenderStyle::setQuotes): 36 * rendering/style/StyleRareInheritedData.cpp: 37 Use operator==. 38 39 (WebCore::quotesDataEquivalent): 40 Add helper function. 41 42 (WebCore::StyleRareInheritedData::operator==): 43 Call quotesDataEquivalent. 44 1 45 2013-05-06 Enrica Casucci <enrica@apple.com> 2 46 -
trunk/Source/WebCore/css/StyleResolver.cpp
r149665 r149700 2357 2357 if (value->isValueList()) { 2358 2358 CSSValueList* list = static_cast<CSSValueList*>(value); 2359 RefPtr<QuotesData> quotes = QuotesData::create();2359 Vector<std::pair<String, String> > quotes; 2360 2360 for (size_t i = 0; i < list->length(); i += 2) { 2361 2361 CSSValue* first = list->itemWithoutBoundsCheck(i); … … 2368 2368 String startQuote = static_cast<CSSPrimitiveValue*>(first)->getStringValue(); 2369 2369 String endQuote = static_cast<CSSPrimitiveValue*>(second)->getStringValue(); 2370 quotes ->addPair(std::make_pair(startQuote, endQuote));2370 quotes.append(std::make_pair(startQuote, endQuote)); 2371 2371 } 2372 state.style()->setQuotes( quotes);2372 state.style()->setQuotes(QuotesData::create(quotes)); 2373 2373 return; 2374 2374 } 2375 2375 if (primitiveValue) { 2376 2376 if (primitiveValue->getIdent() == CSSValueNone) 2377 state.style()->setQuotes(QuotesData::create( ));2377 state.style()->setQuotes(QuotesData::create(Vector<std::pair<String, String> >())); 2378 2378 } 2379 2379 return; -
trunk/Source/WebCore/rendering/RenderQuote.cpp
r143380 r149700 241 241 return StringImpl::empty(); 242 242 case CLOSE_QUOTE: 243 return quotesData()-> getCloseQuote(m_depth - 1).impl();243 return quotesData()->closeQuote(m_depth - 1).impl(); 244 244 case OPEN_QUOTE: 245 return quotesData()-> getOpenQuote(m_depth).impl();245 return quotesData()->openQuote(m_depth).impl(); 246 246 } 247 247 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/rendering/style/QuotesData.cpp
r149080 r149700 25 25 namespace WebCore { 26 26 27 PassRefPtr<QuotesData> QuotesData::create( String open, String close)27 PassRefPtr<QuotesData> QuotesData::create(const String& open1, const String& close1, const String& open2, const String& close2) 28 28 { 29 RefPtr<QuotesData> data = QuotesData::create(); 30 data->addPair(std::make_pair(open, close)); 31 return data; 29 Vector<std::pair<String, String> > quotes; 30 quotes.reserveInitialCapacity(2); 31 quotes.uncheckedAppend(std::make_pair(open1, close1)); 32 quotes.uncheckedAppend(std::make_pair(open2, close2)); 33 34 return QuotesData::create(quotes); 32 35 } 33 36 34 PassRefPtr<QuotesData> QuotesData::create( String open1, String close1, String open2, String close2)37 PassRefPtr<QuotesData> QuotesData::create(const Vector<std::pair<String, String> >& quotes) 35 38 { 36 RefPtr<QuotesData> data = QuotesData::create();37 data->addPair(std::make_pair(open1, close1));38 data->addPair(std::make_pair(open2, close2)); 39 return data;39 RefPtr<QuotesData> quotesData = adoptRef(new QuotesData); 40 quotesData->m_quotePairs = quotes; 41 42 return quotesData.release(); 40 43 } 41 44 42 void QuotesData::addPair(const std::pair<String, String>& quotePair) 45 const String& QuotesData::openQuote(unsigned index) const 43 46 { 44 m_quotePairs.append(quotePair); 47 if (!m_quotePairs.isEmpty()) 48 return emptyString(); 49 50 if (index >= m_quotePairs.size()) 51 return m_quotePairs.last().first; 52 53 return m_quotePairs[index].first; 45 54 } 46 55 47 const String QuotesData::getOpenQuote(intindex) const56 const String& QuotesData::closeQuote(unsigned index) const 48 57 { 49 ASSERT(index >= 0); 50 if (!m_quotePairs.size() || index < 0) 58 if (m_quotePairs.isEmpty()) 51 59 return emptyString(); 52 if ((size_t)index >= m_quotePairs.size())53 return m_quotePairs.last().first;54 return m_quotePairs.at(index).first;55 }56 60 57 const String QuotesData::getCloseQuote(int index) const 58 { 59 ASSERT(index >= -1); 60 if (!m_quotePairs.size() || index < 0) 61 return emptyString(); 62 if ((size_t)index >= m_quotePairs.size()) 61 if (index >= m_quotePairs.size()) 63 62 return m_quotePairs.last().second; 63 64 64 return m_quotePairs.at(index).second; 65 65 } 66 66 67 bool QuotesData::equals(const QuotesData* a, const QuotesData*b)67 bool operator==(const QuotesData& a, const QuotesData& b) 68 68 { 69 if (a == b) 70 return true; 71 if (!a || !b) 72 return false; 73 return a->m_quotePairs == b->m_quotePairs; 69 return a.m_quotePairs == b.m_quotePairs; 74 70 } 75 71 -
trunk/Source/WebCore/rendering/style/QuotesData.h
r149080 r149700 32 32 class QuotesData : public RefCounted<QuotesData> { 33 33 public: 34 static PassRefPtr<QuotesData> create() { return adoptRef(new QuotesData()); } 35 static PassRefPtr<QuotesData> create(const String open, const String close); 36 static PassRefPtr<QuotesData> create(const String open1, const String close1, const String open2, const String close2); 34 static PassRefPtr<QuotesData> create(const String& open1, const String& close1, const String& open2, const String& close2); 35 static PassRefPtr<QuotesData> create(const Vector<std::pair<String, String> >& quotes); 37 36 38 // FIXME: this should be an operator==. 39 static bool equals(const QuotesData*, const QuotesData*); 37 friend bool operator==(const QuotesData&, const QuotesData&); 40 38 41 void addPair(const std::pair<String, String>& quotePair); 42 const String getOpenQuote(int index) const; 43 const String getCloseQuote(int index) const; 39 const String& openQuote(unsigned index) const; 40 const String& closeQuote(unsigned index) const; 44 41 45 42 private: … … 49 46 }; 50 47 48 inline bool operator!=(const QuotesData& a, const QuotesData& b) 49 { 50 return !(a == b); 51 } 52 51 53 } // namespace WebCore 52 54 -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r148921 r149700 614 614 } 615 615 616 if (!QuotesData::equals(rareInheritedData->quotes.get(), other->rareInheritedData->quotes.get())) 616 const QuotesData* quotesDataA = rareInheritedData->quotes.get(); 617 const QuotesData* quotesDataB = other->rareInheritedData->quotes.get(); 618 if (!(quotesDataA == quotesDataB || (quotesDataA && quotesDataB && *quotesDataA == *quotesDataB))) 617 619 return StyleDifferenceLayout; 618 620 … … 751 753 void RenderStyle::setQuotes(PassRefPtr<QuotesData> q) 752 754 { 753 if (QuotesData::equals(rareInheritedData->quotes.get(), q.get())) 754 return; 755 if (rareInheritedData->quotes == q || (rareInheritedData->quotes && q && *rareInheritedData->quotes == *q)) 756 return; 757 755 758 rareInheritedData.access()->quotes = q; 756 759 } -
trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp
r148921 r149700 218 218 } 219 219 220 static bool quotesDataEquivalent(const QuotesData* q1, const QuotesData* q2) 221 { 222 if (q1 == q2) 223 return true; 224 if ((!q1 && q2) || (q1 && !q2)) 225 return false; 226 return (*q1 == *q2); 227 } 228 220 229 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const 221 230 { … … 268 277 && locale == o.locale 269 278 && textEmphasisCustomMark == o.textEmphasisCustomMark 270 && QuotesData::equals(quotes.get(), o.quotes.get())279 && quotesDataEquivalent(quotes.get(), o.quotes.get()) 271 280 && m_tabSize == o.m_tabSize 272 281 && m_lineGrid == o.m_lineGrid
Note: See TracChangeset
for help on using the changeset viewer.