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

Side by Side Diff: third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp

Issue 2007103003: Expand WTF::StringView's API to be more like StringPiece. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove bad assert. Created 4 years, 6 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, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 546
547 widths.resize(ranges.size()); 547 widths.resize(ranges.size());
548 for (unsigned i = 0; i < ranges.size(); i++) 548 for (unsigned i = 0; i < ranges.size(); i++)
549 widths[i] = ranges[i].width(); 549 widths[i] = ranges[i].width();
550 } 550 }
551 551
552 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font& font, StringBuilder* charactersWithHyphen) const 552 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font& font, StringBuilder* charactersWithHyphen) const
553 { 553 {
554 ASSERT(getLineLayoutItem().text()); 554 ASSERT(getLineLayoutItem().text());
555 555
556 StringView string = getLineLayoutItem().text().createView(); 556 String string = getLineLayoutItem().text();
557 unsigned startPos = start(); 557 unsigned startPos = start();
558 unsigned length = len(); 558 unsigned length = len();
559 559 return constructTextRun(style, font, StringView(string, startPos, length), g etLineLayoutItem().textLength() - startPos, charactersWithHyphen);
560 if (string.length() != length || startPos)
561 string.narrow(startPos, length);
562
563 return constructTextRun(style, font, string, getLineLayoutItem().textLength( ) - startPos, charactersWithHyphen);
564 } 560 }
565 561
566 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font& font, StringView string, int maximumLength, StringBuilder* charactersWithHyphen) const 562 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font& font, StringView string, int maximumLength, StringBuilder* charactersWithHyphen) const
567 { 563 {
568 if (charactersWithHyphen) { 564 if (charactersWithHyphen) {
569 const AtomicString& hyphenString = style.hyphenString(); 565 const AtomicString& hyphenString = style.hyphenString();
570 charactersWithHyphen->reserveCapacity(string.length() + hyphenString.len gth()); 566 charactersWithHyphen->reserveCapacity(string.length() + hyphenString.len gth());
571 charactersWithHyphen->append(string); 567 charactersWithHyphen->append(string);
572 charactersWithHyphen->append(hyphenString); 568 charactersWithHyphen->append(hyphenString);
573 string = charactersWithHyphen->toString().createView(); 569 string = charactersWithHyphen->toString();
574 maximumLength = string.length(); 570 maximumLength = string.length();
575 } 571 }
576 572
577 ASSERT(maximumLength >= static_cast<int>(string.length())); 573 ASSERT(maximumLength >= static_cast<int>(string.length()));
578 574
579 TextRun run(string, textPos().toFloat(), expansion(), expansionBehavior(), d irection(), dirOverride() || style.rtlOrdering() == VisualOrder); 575 TextRun run(string, textPos().toFloat(), expansion(), expansionBehavior(), d irection(), dirOverride() || style.rtlOrdering() == VisualOrder);
580 run.setTabSize(!style.collapseWhiteSpace(), style.getTabSize()); 576 run.setTabSize(!style.collapseWhiteSpace(), style.getTabSize());
581 run.setTextJustify(style.getTextJustify()); 577 run.setTextJustify(style.getTextJustify());
582 578
583 // Propagate the maximum length of the characters buffer to the TextRun, eve n when we're only processing a substring. 579 // Propagate the maximum length of the characters buffer to the TextRun, eve n when we're only processing a substring.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer( )); 616 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer( ));
621 const int layoutObjectCharacterOffset = 75; 617 const int layoutObjectCharacterOffset = 75;
622 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) 618 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++)
623 fputc(' ', stderr); 619 fputc(' ', stderr);
624 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); 620 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata());
625 } 621 }
626 622
627 #endif 623 #endif
628 624
629 } // namespace blink 625 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698