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

Side by Side Diff: Source/core/layout/LayoutText.cpp

Issue 1094863007: Implement "word-break: keep-all" in CSS3 Text (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix layout test failure on mac Created 5 years, 8 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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 bool isSpace = false; 887 bool isSpace = false;
888 bool firstWord = true; 888 bool firstWord = true;
889 bool firstLine = true; 889 bool firstLine = true;
890 int nextBreakable = -1; 890 int nextBreakable = -1;
891 int lastWordBoundary = 0; 891 int lastWordBoundary = 0;
892 float cachedWordTrailingSpaceWidth[2] = { 0, 0 }; // LTR, RTL 892 float cachedWordTrailingSpaceWidth[2] = { 0, 0 }; // LTR, RTL
893 893
894 int firstGlyphLeftOverflow = -1; 894 int firstGlyphLeftOverflow = -1;
895 895
896 bool breakAll = (styleToUse.wordBreak() == BreakAllWordBreak || styleToUse.w ordBreak() == BreakWordBreak) && styleToUse.autoWrap(); 896 bool breakAll = (styleToUse.wordBreak() == BreakAllWordBreak || styleToUse.w ordBreak() == BreakWordBreak) && styleToUse.autoWrap();
897 bool keepAll = styleToUse.wordBreak() == KeepAllWordBreak && styleToUse.auto Wrap();
897 898
898 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver; 899 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
899 BidiCharacterRun* run; 900 BidiCharacterRun* run;
900 TextDirection textDirection = styleToUse.direction(); 901 TextDirection textDirection = styleToUse.direction();
901 if (is8Bit() || isOverride(styleToUse.unicodeBidi())) { 902 if (is8Bit() || isOverride(styleToUse.unicodeBidi())) {
902 run = 0; 903 run = 0;
903 } else { 904 } else {
904 TextRun textRun(text()); 905 TextRun textRun(text());
905 BidiStatus status(textDirection, false); 906 BidiStatus status(textDirection, false);
906 bidiResolver.setStatus(status); 907 bidiResolver.setStatus(status);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 continue; 970 continue;
970 } 971 }
971 if (c == softHyphen) { 972 if (c == softHyphen) {
972 currMaxWidth += widthFromCache(f, lastWordBoundary, i - lastWordBoun dary, leadWidth + currMaxWidth, textDirection, &fallbackFonts, &glyphOverflow); 973 currMaxWidth += widthFromCache(f, lastWordBoundary, i - lastWordBoun dary, leadWidth + currMaxWidth, textDirection, &fallbackFonts, &glyphOverflow);
973 if (firstGlyphLeftOverflow < 0) 974 if (firstGlyphLeftOverflow < 0)
974 firstGlyphLeftOverflow = glyphOverflow.left; 975 firstGlyphLeftOverflow = glyphOverflow.left;
975 lastWordBoundary = i + 1; 976 lastWordBoundary = i + 1;
976 continue; 977 continue;
977 } 978 }
978 979
979 bool hasBreak = breakIterator.isBreakable(i, nextBreakable, breakAll ? L ineBreakType::BreakAll : LineBreakType::Normal); 980 bool hasBreak = breakIterator.isBreakable(i, nextBreakable, breakAll ? L ineBreakType::BreakAll : keepAll ? LineBreakType::KeepAll : LineBreakType::Norma l);
980 bool betweenWords = true; 981 bool betweenWords = true;
981 int j = i; 982 int j = i;
982 while (c != newlineCharacter && c != space && c != characterTabulation & & (c != softHyphen)) { 983 while (c != newlineCharacter && c != space && c != characterTabulation & & (c != softHyphen)) {
983 j++; 984 j++;
984 if (j == len) 985 if (j == len)
985 break; 986 break;
986 c = uncheckedCharacterAt(j); 987 c = uncheckedCharacterAt(j);
987 if (breakIterator.isBreakable(j, nextBreakable) && characterAt(j - 1 ) != softHyphen) 988 if (breakIterator.isBreakable(j, nextBreakable) && characterAt(j - 1 ) != softHyphen)
988 break; 989 break;
989 if (breakAll) { 990 if (breakAll) {
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 } 1855 }
1855 1856
1856 void LayoutText::invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const 1857 void LayoutText::invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const
1857 { 1858 {
1858 LayoutObject::invalidateDisplayItemClients(paintInvalidationContainer); 1859 LayoutObject::invalidateDisplayItemClients(paintInvalidationContainer);
1859 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) 1860 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox())
1860 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); 1861 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box);
1861 } 1862 }
1862 1863
1863 } // namespace blink 1864 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698