| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2733 return RenderBlock::logicalRightSelectionOffset(rootBlock, position); | 2733 return RenderBlock::logicalRightSelectionOffset(rootBlock, position); |
| 2734 | 2734 |
| 2735 RenderBlock* cb = this; | 2735 RenderBlock* cb = this; |
| 2736 while (cb != rootBlock) { | 2736 while (cb != rootBlock) { |
| 2737 logicalRight += cb->logicalLeft(); | 2737 logicalRight += cb->logicalLeft(); |
| 2738 cb = cb->containingBlock(); | 2738 cb = cb->containingBlock(); |
| 2739 } | 2739 } |
| 2740 return logicalRight; | 2740 return logicalRight; |
| 2741 } | 2741 } |
| 2742 | 2742 |
| 2743 template <typename CharacterType> | |
| 2744 static inline TextRun constructTextRunInternal(RenderObject* context, const Font
& font, const CharacterType* characters, int length, RenderStyle* style, TextDir
ection direction, TextRun::ExpansionBehavior expansion) | |
| 2745 { | |
| 2746 ASSERT(style); | |
| 2747 | |
| 2748 TextDirection textDirection = direction; | |
| 2749 bool directionalOverride = style->rtlOrdering() == VisualOrder; | |
| 2750 | |
| 2751 TextRun run(characters, length, 0, 0, expansion, textDirection, directionalO
verride); | |
| 2752 if (textRunNeedsRenderingContext(font)) | |
| 2753 run.setRenderingContext(SVGTextRunRenderingContext::create(context)); | |
| 2754 | |
| 2755 return run; | |
| 2756 } | |
| 2757 | |
| 2758 template <typename CharacterType> | |
| 2759 static inline TextRun constructTextRunInternal(RenderObject* context, const Font
& font, const CharacterType* characters, int length, RenderStyle* style, TextDir
ection direction, TextRun::ExpansionBehavior expansion, TextRunFlags flags) | |
| 2760 { | |
| 2761 ASSERT(style); | |
| 2762 | |
| 2763 TextDirection textDirection = direction; | |
| 2764 bool directionalOverride = style->rtlOrdering() == VisualOrder; | |
| 2765 if (flags != DefaultTextRunFlags) { | |
| 2766 if (flags & RespectDirection) | |
| 2767 textDirection = style->direction(); | |
| 2768 if (flags & RespectDirectionOverride) | |
| 2769 directionalOverride |= isOverride(style->unicodeBidi()); | |
| 2770 } | |
| 2771 | |
| 2772 TextRun run(characters, length, 0, 0, expansion, textDirection, directionalO
verride); | |
| 2773 if (textRunNeedsRenderingContext(font)) | |
| 2774 run.setRenderingContext(SVGTextRunRenderingContext::create(context)); | |
| 2775 | |
| 2776 return run; | |
| 2777 } | |
| 2778 | |
| 2779 TextRun RenderBlockFlow::constructTextRun(RenderObject* context, const Font& fon
t, const LChar* characters, int length, RenderStyle* style, TextDirection direct
ion, TextRun::ExpansionBehavior expansion) | |
| 2780 { | |
| 2781 return constructTextRunInternal(context, font, characters, length, style, di
rection, expansion); | |
| 2782 } | |
| 2783 | |
| 2784 TextRun RenderBlockFlow::constructTextRun(RenderObject* context, const Font& fon
t, const UChar* characters, int length, RenderStyle* style, TextDirection direct
ion, TextRun::ExpansionBehavior expansion) | |
| 2785 { | |
| 2786 return constructTextRunInternal(context, font, characters, length, style, di
rection, expansion); | |
| 2787 } | |
| 2788 | |
| 2789 TextRun RenderBlockFlow::constructTextRun(RenderObject* context, const Font& fon
t, const RenderText* text, RenderStyle* style, TextDirection direction, TextRun:
:ExpansionBehavior expansion) | |
| 2790 { | |
| 2791 if (text->is8Bit()) | |
| 2792 return constructTextRunInternal(context, font, text->characters8(), text
->textLength(), style, direction, expansion); | |
| 2793 return constructTextRunInternal(context, font, text->characters16(), text->t
extLength(), style, direction, expansion); | |
| 2794 } | |
| 2795 | |
| 2796 TextRun RenderBlockFlow::constructTextRun(RenderObject* context, const Font& fon
t, const RenderText* text, unsigned offset, unsigned length, RenderStyle* style,
TextDirection direction, TextRun::ExpansionBehavior expansion) | |
| 2797 { | |
| 2798 ASSERT(offset + length <= text->textLength()); | |
| 2799 if (text->is8Bit()) | |
| 2800 return constructTextRunInternal(context, font, text->characters8() + off
set, length, style, direction, expansion); | |
| 2801 return constructTextRunInternal(context, font, text->characters16() + offset
, length, style, direction, expansion); | |
| 2802 } | |
| 2803 | |
| 2804 TextRun RenderBlockFlow::constructTextRun(RenderObject* context, const Font& fon
t, const String& string, RenderStyle* style, TextDirection direction, TextRun::E
xpansionBehavior expansion, TextRunFlags flags) | |
| 2805 { | |
| 2806 unsigned length = string.length(); | |
| 2807 if (!length) | |
| 2808 return constructTextRunInternal(context, font, static_cast<const LChar*>
(0), length, style, direction, expansion, flags); | |
| 2809 if (string.is8Bit()) | |
| 2810 return constructTextRunInternal(context, font, string.characters8(), len
gth, style, direction, expansion, flags); | |
| 2811 return constructTextRunInternal(context, font, string.characters16(), length
, style, direction, expansion, flags); | |
| 2812 } | |
| 2813 | |
| 2814 TextRun RenderBlockFlow::constructTextRun(RenderObject* context, const Font& fon
t, const String& string, RenderStyle* style, TextRun::ExpansionBehavior expansio
n, TextRunFlags flags) | |
| 2815 { | |
| 2816 bool hasStrongDirectionality; | |
| 2817 return constructTextRun(context, font, string, style, | |
| 2818 determineDirectionality(string, hasStrongDirectionality), | |
| 2819 expansion, flags); | |
| 2820 } | |
| 2821 | |
| 2822 TextRun RenderBlockFlow::constructTextRun(RenderObject* context, const Font& fon
t, const RenderText* text, unsigned offset, unsigned length, RenderStyle* style,
TextRun::ExpansionBehavior expansion) | |
| 2823 { | |
| 2824 ASSERT(offset + length <= text->textLength()); | |
| 2825 TextRun run = text->is8Bit() | |
| 2826 ? constructTextRunInternal(context, font, text->characters8() + offset,
length, style, LTR, expansion) | |
| 2827 : constructTextRunInternal(context, font, text->characters16() + offset,
length, style, LTR, expansion); | |
| 2828 bool hasStrongDirectionality; | |
| 2829 run.setDirection(directionForRun(run, hasStrongDirectionality)); | |
| 2830 return run; | |
| 2831 } | |
| 2832 | |
| 2833 RootInlineBox* RenderBlockFlow::createRootInlineBox() | 2743 RootInlineBox* RenderBlockFlow::createRootInlineBox() |
| 2834 { | 2744 { |
| 2835 return new RootInlineBox(*this); | 2745 return new RootInlineBox(*this); |
| 2836 } | 2746 } |
| 2837 | 2747 |
| 2838 bool RenderBlockFlow::isPagedOverflow(const RenderStyle* style) | 2748 bool RenderBlockFlow::isPagedOverflow(const RenderStyle* style) |
| 2839 { | 2749 { |
| 2840 return style->isOverflowPaged() && node() != document().viewportDefiningElem
ent(); | 2750 return style->isOverflowPaged() && node() != document().viewportDefiningElem
ent(); |
| 2841 } | 2751 } |
| 2842 | 2752 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2899 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() | 2809 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() |
| 2900 { | 2810 { |
| 2901 if (m_rareData) | 2811 if (m_rareData) |
| 2902 return *m_rareData; | 2812 return *m_rareData; |
| 2903 | 2813 |
| 2904 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); | 2814 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); |
| 2905 return *m_rareData; | 2815 return *m_rareData; |
| 2906 } | 2816 } |
| 2907 | 2817 |
| 2908 } // namespace WebCore | 2818 } // namespace WebCore |
| OLD | NEW |