OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ight reserved. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ight reserved. |
4 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
5 * Copyright (C) 2013 Adobe Systems Incorporated. | 5 * Copyright (C) 2013 Adobe Systems Incorporated. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 14 matching lines...) Expand all Loading... |
25 #define BreakingContextInlineHeaders_h | 25 #define BreakingContextInlineHeaders_h |
26 | 26 |
27 #include "core/rendering/InlineIterator.h" | 27 #include "core/rendering/InlineIterator.h" |
28 #include "core/rendering/InlineTextBox.h" | 28 #include "core/rendering/InlineTextBox.h" |
29 #include "core/rendering/RenderCombineText.h" | 29 #include "core/rendering/RenderCombineText.h" |
30 #include "core/rendering/RenderInline.h" | 30 #include "core/rendering/RenderInline.h" |
31 #include "core/rendering/RenderLayer.h" | 31 #include "core/rendering/RenderLayer.h" |
32 #include "core/rendering/RenderListMarker.h" | 32 #include "core/rendering/RenderListMarker.h" |
33 #include "core/rendering/RenderObjectInlines.h" | 33 #include "core/rendering/RenderObjectInlines.h" |
34 #include "core/rendering/RenderRubyRun.h" | 34 #include "core/rendering/RenderRubyRun.h" |
| 35 #include "core/rendering/TextRunConstructor.h" |
35 #include "core/rendering/break_lines.h" | 36 #include "core/rendering/break_lines.h" |
36 #include "core/rendering/line/LineBreaker.h" | 37 #include "core/rendering/line/LineBreaker.h" |
37 #include "core/rendering/line/LineInfo.h" | 38 #include "core/rendering/line/LineInfo.h" |
38 #include "core/rendering/line/LineWidth.h" | 39 #include "core/rendering/line/LineWidth.h" |
39 #include "core/rendering/line/RenderTextInfo.h" | 40 #include "core/rendering/line/RenderTextInfo.h" |
40 #include "core/rendering/line/TrailingObjects.h" | 41 #include "core/rendering/line/TrailingObjects.h" |
41 #include "core/rendering/line/WordMeasurement.h" | 42 #include "core/rendering/line/WordMeasurement.h" |
42 #include "core/rendering/svg/RenderSVGInlineText.h" | 43 #include "core/rendering/svg/RenderSVGInlineText.h" |
43 | 44 |
44 namespace WebCore { | 45 namespace WebCore { |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 for (size_t i = 0; i < wordMeasurements.size(); ++i) { | 491 for (size_t i = 0; i < wordMeasurements.size(); ++i) { |
491 if (wordMeasurements[i].width > 0) | 492 if (wordMeasurements[i].width > 0) |
492 return wordMeasurements[i].width; | 493 return wordMeasurements[i].width; |
493 } | 494 } |
494 return 0; | 495 return 0; |
495 } | 496 } |
496 | 497 |
497 inline float measureHyphenWidth(RenderText* renderer, const Font& font, TextDire
ction textDirection) | 498 inline float measureHyphenWidth(RenderText* renderer, const Font& font, TextDire
ction textDirection) |
498 { | 499 { |
499 RenderStyle* style = renderer->style(); | 500 RenderStyle* style = renderer->style(); |
500 return font.width(RenderBlockFlow::constructTextRun(renderer, font, | 501 return font.width(constructTextRun(renderer, font, |
501 style->hyphenString().string(), style, style->direction())); | 502 style->hyphenString().string(), style, style->direction())); |
502 } | 503 } |
503 | 504 |
504 ALWAYS_INLINE TextDirection textDirectionFromUnicode(WTF::Unicode::Direction dir
ection) | 505 ALWAYS_INLINE TextDirection textDirectionFromUnicode(WTF::Unicode::Direction dir
ection) |
505 { | 506 { |
506 return direction == WTF::Unicode::RightToLeft | 507 return direction == WTF::Unicode::RightToLeft |
507 || direction == WTF::Unicode::RightToLeftArabic ? RTL : LTR; | 508 || direction == WTF::Unicode::RightToLeftArabic ? RTL : LTR; |
508 } | 509 } |
509 | 510 |
510 ALWAYS_INLINE float textWidth(RenderText* text, unsigned from, unsigned len, con
st Font& font, float xPos, bool isFixedPitch, bool collapseWhiteSpace, HashSet<c
onst SimpleFontData*>* fallbackFonts = 0) | 511 ALWAYS_INLINE float textWidth(RenderText* text, unsigned from, unsigned len, con
st Font& font, float xPos, bool isFixedPitch, bool collapseWhiteSpace, HashSet<c
onst SimpleFontData*>* fallbackFonts = 0) |
511 { | 512 { |
512 GlyphOverflow glyphOverflow; | 513 GlyphOverflow glyphOverflow; |
513 if (isFixedPitch || (!from && len == text->textLength()) || text->style()->h
asTextCombine()) | 514 if (isFixedPitch || (!from && len == text->textLength()) || text->style()->h
asTextCombine()) |
514 return text->width(from, len, font, xPos, text->style()->direction(), fa
llbackFonts, &glyphOverflow); | 515 return text->width(from, len, font, xPos, text->style()->direction(), fa
llbackFonts, &glyphOverflow); |
515 | 516 |
516 TextRun run = RenderBlockFlow::constructTextRun(text, font, text, from, len,
text->style()); | 517 TextRun run = constructTextRun(text, font, text, from, len, text->style()); |
517 run.setCharacterScanForCodePath(!text->canUseSimpleFontCodePath()); | 518 run.setCharacterScanForCodePath(!text->canUseSimpleFontCodePath()); |
518 run.setTabSize(!collapseWhiteSpace, text->style()->tabSize()); | 519 run.setTabSize(!collapseWhiteSpace, text->style()->tabSize()); |
519 run.setXPos(xPos); | 520 run.setXPos(xPos); |
520 return font.width(run, fallbackFonts, &glyphOverflow); | 521 return font.width(run, fallbackFonts, &glyphOverflow); |
521 } | 522 } |
522 | 523 |
523 inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool
& hyphenated) | 524 inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool
& hyphenated) |
524 { | 525 { |
525 if (!m_current.offset()) | 526 if (!m_current.offset()) |
526 m_appliedStartWidth = false; | 527 m_appliedStartWidth = false; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 m_renderTextInfo.m_text = renderText; | 581 m_renderTextInfo.m_text = renderText; |
581 m_renderTextInfo.m_font = &font; | 582 m_renderTextInfo.m_font = &font; |
582 m_renderTextInfo.m_lineBreakIterator.resetStringAndReleaseIterator(rende
rText->text(), style->locale()); | 583 m_renderTextInfo.m_lineBreakIterator.resetStringAndReleaseIterator(rende
rText->text(), style->locale()); |
583 } else if (m_renderTextInfo.m_font != &font) { | 584 } else if (m_renderTextInfo.m_font != &font) { |
584 m_renderTextInfo.m_font = &font; | 585 m_renderTextInfo.m_font = &font; |
585 } | 586 } |
586 | 587 |
587 // Non-zero only when kerning is enabled, in which case we measure | 588 // Non-zero only when kerning is enabled, in which case we measure |
588 // words with their trailing space, then subtract its width. | 589 // words with their trailing space, then subtract its width. |
589 float wordTrailingSpaceWidth = (font.fontDescription().typesettingFeatures()
& Kerning) ? | 590 float wordTrailingSpaceWidth = (font.fontDescription().typesettingFeatures()
& Kerning) ? |
590 font.width(RenderBlockFlow::constructTextRun( | 591 font.width(constructTextRun(renderText, font, &space, 1, style, style->d
irection())) + wordSpacing |
591 renderText, font, &space, 1, style, | |
592 style->direction())) + wordSpacing | |
593 : 0; | 592 : 0; |
594 | 593 |
595 UChar lastCharacter = m_renderTextInfo.m_lineBreakIterator.lastCharacter(); | 594 UChar lastCharacter = m_renderTextInfo.m_lineBreakIterator.lastCharacter(); |
596 UChar secondToLastCharacter = m_renderTextInfo.m_lineBreakIterator.secondToL
astCharacter(); | 595 UChar secondToLastCharacter = m_renderTextInfo.m_lineBreakIterator.secondToL
astCharacter(); |
597 for (; m_current.offset() < renderText->textLength(); m_current.fastIncremen
tInTextNode()) { | 596 for (; m_current.offset() < renderText->textLength(); m_current.fastIncremen
tInTextNode()) { |
598 bool previousCharacterIsSpace = m_currentCharacterIsSpace; | 597 bool previousCharacterIsSpace = m_currentCharacterIsSpace; |
599 bool previousCharacterShouldCollapseIfPreWap = m_currentCharacterShouldC
ollapseIfPreWap; | 598 bool previousCharacterShouldCollapseIfPreWap = m_currentCharacterShouldC
ollapseIfPreWap; |
600 UChar c = m_current.current(); | 599 UChar c = m_current.current(); |
601 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = c
== ' ' || c == '\t' || (!m_preservesNewline && (c == '\n')); | 600 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = c
== ' ' || c == '\t' || (!m_preservesNewline && (c == '\n')); |
602 | 601 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 | 902 |
904 if (style->textIndentType() == TextIndentHanging) | 903 if (style->textIndentType() == TextIndentHanging) |
905 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In
dentText; | 904 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In
dentText; |
906 | 905 |
907 return shouldIndentText; | 906 return shouldIndentText; |
908 } | 907 } |
909 | 908 |
910 } | 909 } |
911 | 910 |
912 #endif // BreakingContextInlineHeaders_h | 911 #endif // BreakingContextInlineHeaders_h |
OLD | NEW |