Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: Source/core/dom/FirstLetterPseudoElement.cpp

Issue 1133853006: Elements whose contents start with an astral Unicode symbol disappear when CSS `::first-letter` is … Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed UAF failures for ASan Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 12 matching lines...) Expand all
23 23
24 #include "config.h" 24 #include "config.h"
25 #include "core/dom/FirstLetterPseudoElement.h" 25 #include "core/dom/FirstLetterPseudoElement.h"
26 26
27 #include "core/dom/Element.h" 27 #include "core/dom/Element.h"
28 #include "core/layout/GeneratedChildren.h" 28 #include "core/layout/GeneratedChildren.h"
29 #include "core/layout/LayoutObject.h" 29 #include "core/layout/LayoutObject.h"
30 #include "core/layout/LayoutObjectInlines.h" 30 #include "core/layout/LayoutObjectInlines.h"
31 #include "core/layout/LayoutText.h" 31 #include "core/layout/LayoutText.h"
32 #include "core/layout/LayoutTextFragment.h" 32 #include "core/layout/LayoutTextFragment.h"
33 #include "platform/text/TextBreakIterator.h"
33 #include "wtf/TemporaryChange.h" 34 #include "wtf/TemporaryChange.h"
34 #include "wtf/text/WTFString.h" 35 #include "wtf/text/WTFString.h"
35 #include "wtf/text/icu/UnicodeIcu.h" 36 #include "wtf/text/icu/UnicodeIcu.h"
36 37
37 namespace blink { 38 namespace blink {
38 39
39 using namespace WTF; 40 using namespace WTF;
40 using namespace Unicode; 41 using namespace Unicode;
41 42
42 // CSS 2.1 http://www.w3.org/TR/CSS21/selector.html#first-letter 43 // CSS 2.1 http://www.w3.org/TR/CSS21/selector.html#first-letter
(...skipping 27 matching lines...) Expand all
70 length++; 71 length++;
71 // Now account for leading punctuation. 72 // Now account for leading punctuation.
72 while (length < textLength && isPunctuationForFirstLetter(text[length])) 73 while (length < textLength && isPunctuationForFirstLetter(text[length]))
73 length++; 74 length++;
74 75
75 // Bail if we didn't find a letter before the end of the text or before a sp ace. 76 // Bail if we didn't find a letter before the end of the text or before a sp ace.
76 if (isSpaceForFirstLetter(text[length]) || length == textLength) 77 if (isSpaceForFirstLetter(text[length]) || length == textLength)
77 return 0; 78 return 0;
78 79
79 // Account the next character for first letter. 80 // Account the next character for first letter.
80 length++; 81 const String substring = text.is8Bit() ? String::make16BitFrom8BitSource(tex t.substring(length).characters8(), textLength - length) : text.substring(length) ;
82 length += countCharactersAndGraphemesInCluster(substring.characters16(), sub string.length(), 0, 1).characters;
81 83
82 // Keep looking for allowed punctuation for the :first-letter. 84 // Keep looking for allowed punctuation for the :first-letter.
83 for (; length < textLength; ++length) { 85 for (; length < textLength; ++length) {
84 UChar c = text[length]; 86 UChar c = text[length];
85 if (!isPunctuationForFirstLetter(c)) 87 if (!isPunctuationForFirstLetter(c))
86 break; 88 break;
87 } 89 }
88 return length; 90 return length;
89 } 91 }
90 92
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 313
312 // We only manage the style for the generated content items. 314 // We only manage the style for the generated content items.
313 if (!child->isText() && !child->isQuote() && !child->isImage()) 315 if (!child->isText() && !child->isQuote() && !child->isImage())
314 continue; 316 continue;
315 317
316 child->setPseudoStyle(layoutObject->mutableStyle()); 318 child->setPseudoStyle(layoutObject->mutableStyle());
317 } 319 }
318 } 320 }
319 321
320 } // namespace blink 322 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/css1/pseudo/firstletter-surrogate-expected.html ('k') | Source/platform/fonts/shaping/HarfBuzzShaper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698