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

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

Issue 1277803004: Revert of Elements whose contents start with an astral Unicode symbol disappear when CSS `::first-letter` is … (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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"
34 #include "wtf/TemporaryChange.h" 33 #include "wtf/TemporaryChange.h"
35 #include "wtf/text/WTFString.h" 34 #include "wtf/text/WTFString.h"
36 #include "wtf/text/icu/UnicodeIcu.h" 35 #include "wtf/text/icu/UnicodeIcu.h"
37 36
38 namespace blink { 37 namespace blink {
39 38
40 using namespace WTF; 39 using namespace WTF;
41 using namespace Unicode; 40 using namespace Unicode;
42 41
43 // CSS 2.1 http://www.w3.org/TR/CSS21/selector.html#first-letter 42 // CSS 2.1 http://www.w3.org/TR/CSS21/selector.html#first-letter
(...skipping 27 matching lines...) Expand all
71 length++; 70 length++;
72 // Now account for leading punctuation. 71 // Now account for leading punctuation.
73 while (length < textLength && isPunctuationForFirstLetter(text[length])) 72 while (length < textLength && isPunctuationForFirstLetter(text[length]))
74 length++; 73 length++;
75 74
76 // Bail if we didn't find a letter before the end of the text or before a sp ace. 75 // Bail if we didn't find a letter before the end of the text or before a sp ace.
77 if (isSpaceForFirstLetter(text[length]) || length == textLength) 76 if (isSpaceForFirstLetter(text[length]) || length == textLength)
78 return 0; 77 return 0;
79 78
80 // Account the next character for first letter. 79 // Account the next character for first letter.
81 const String substring = text.substring(length); 80 length++;
82 const unsigned substringLength = substring.length();
83 const UChar* normalizedBuffer = substring.is8Bit() ? String::make16BitFrom8B itSource(substring.characters8(), substringLength).characters16() : substring.ch aracters16();
84 length += countCharactersAndGraphemesInCluster(normalizedBuffer, substringLe ngth, 0, 1).characters;
85 81
86 // Keep looking for allowed punctuation for the :first-letter. 82 // Keep looking for allowed punctuation for the :first-letter.
87 for (; length < textLength; ++length) { 83 for (; length < textLength; ++length) {
88 UChar c = text[length]; 84 UChar c = text[length];
89 if (!isPunctuationForFirstLetter(c)) 85 if (!isPunctuationForFirstLetter(c))
90 break; 86 break;
91 } 87 }
92 return length; 88 return length;
93 } 89 }
94 90
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 311
316 // We only manage the style for the generated content items. 312 // We only manage the style for the generated content items.
317 if (!child->isText() && !child->isQuote() && !child->isImage()) 313 if (!child->isText() && !child->isQuote() && !child->isImage())
318 continue; 314 continue;
319 315
320 child->setPseudoStyle(layoutObject->mutableStyle()); 316 child->setPseudoStyle(layoutObject->mutableStyle());
321 } 317 }
322 } 318 }
323 319
324 } // namespace blink 320 } // 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