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 20 matching lines...) Expand all Loading... | |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/rendering/RenderBlockFlow.h" | 32 #include "core/rendering/RenderBlockFlow.h" |
33 | 33 |
34 #include "core/accessibility/AXObjectCache.h" | 34 #include "core/accessibility/AXObjectCache.h" |
35 #include "core/frame/FrameView.h" | 35 #include "core/frame/FrameView.h" |
36 #include "core/rendering/FastTextAutosizer.h" | 36 #include "core/rendering/FastTextAutosizer.h" |
37 #include "core/rendering/HitTestLocation.h" | 37 #include "core/rendering/HitTestLocation.h" |
38 #include "core/rendering/RenderFlowThread.h" | 38 #include "core/rendering/RenderFlowThread.h" |
39 #include "core/rendering/RenderLayer.h" | 39 #include "core/rendering/RenderLayer.h" |
40 #include "core/rendering/RenderMultiColumnFlowThread.h" | 40 #include "core/rendering/RenderMultiColumnFlowThread.h" |
41 #include "core/rendering/RenderPagedFlowThread.h" | |
41 #include "core/rendering/RenderText.h" | 42 #include "core/rendering/RenderText.h" |
42 #include "core/rendering/RenderView.h" | 43 #include "core/rendering/RenderView.h" |
43 #include "core/rendering/line/LineWidth.h" | 44 #include "core/rendering/line/LineWidth.h" |
44 #include "core/rendering/svg/SVGTextRunRenderingContext.h" | 45 #include "core/rendering/svg/SVGTextRunRenderingContext.h" |
45 #include "platform/text/BidiTextRun.h" | 46 #include "platform/text/BidiTextRun.h" |
46 | 47 |
47 namespace WebCore { | 48 namespace WebCore { |
48 | 49 |
49 bool RenderBlockFlow::s_canPropagateFloatIntoSibling = false; | 50 bool RenderBlockFlow::s_canPropagateFloatIntoSibling = false; |
50 | 51 |
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1820 } | 1821 } |
1821 } | 1822 } |
1822 } | 1823 } |
1823 } | 1824 } |
1824 | 1825 |
1825 parentBlockFlow->markAllDescendantsWithFloatsForLayout(); | 1826 parentBlockFlow->markAllDescendantsWithFloatsForLayout(); |
1826 parentBlockFlow->markSiblingsWithFloatsForLayout(); | 1827 parentBlockFlow->markSiblingsWithFloatsForLayout(); |
1827 } | 1828 } |
1828 | 1829 |
1829 if (diff.needsFullLayout() || !oldStyle) | 1830 if (diff.needsFullLayout() || !oldStyle) |
1830 createOrDestroyMultiColumnFlowThreadIfNeeded(); | 1831 createOrDestroyMultiColumnFlowThreadIfNeeded(oldStyle); |
1831 } | 1832 } |
1832 | 1833 |
1833 void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, Layou tUnit logicalTop) | 1834 void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, Layou tUnit logicalTop) |
1834 { | 1835 { |
1835 if (child->style()->isOriginalDisplayInlineType()) | 1836 if (child->style()->isOriginalDisplayInlineType()) |
1836 setStaticInlinePositionForChild(child, logicalTop, startAlignedOffsetFor Line(logicalTop, false)); | 1837 setStaticInlinePositionForChild(child, logicalTop, startAlignedOffsetFor Line(logicalTop, false)); |
1837 else | 1838 else |
1838 setStaticInlinePositionForChild(child, logicalTop, startOffsetForContent ()); | 1839 setStaticInlinePositionForChild(child, logicalTop, startOffsetForContent ()); |
1839 } | 1840 } |
1840 | 1841 |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2727 bool hasStrongDirectionality; | 2728 bool hasStrongDirectionality; |
2728 run.setDirection(directionForRun(run, hasStrongDirectionality)); | 2729 run.setDirection(directionForRun(run, hasStrongDirectionality)); |
2729 return run; | 2730 return run; |
2730 } | 2731 } |
2731 | 2732 |
2732 RootInlineBox* RenderBlockFlow::createRootInlineBox() | 2733 RootInlineBox* RenderBlockFlow::createRootInlineBox() |
2733 { | 2734 { |
2734 return new RootInlineBox(*this); | 2735 return new RootInlineBox(*this); |
2735 } | 2736 } |
2736 | 2737 |
2737 void RenderBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded() | 2738 bool RenderBlockFlow::isPagedOverflow(const RenderStyle* style) |
2739 { | |
2740 return style->isOverflowPaged() && node() != document().viewportDefiningElem ent(); | |
2741 } | |
2742 | |
2743 RenderBlockFlow::FlowThreadType RenderBlockFlow::flowThreadType(const RenderStyl e* style) | |
2744 { | |
2745 if (isPagedOverflow(style)) | |
2746 return PagedFlowThread; | |
2747 if (style->specifiesColumns()) | |
2748 return MultiColumnFlowThread; | |
2749 return NoFlowThread; | |
2750 } | |
2751 | |
2752 RenderMultiColumnFlowThread* RenderBlockFlow::createMultiColumnFlowThread(FlowTh readType type) | |
2753 { | |
2754 switch (type) { | |
2755 case MultiColumnFlowThread: | |
2756 return RenderMultiColumnFlowThread::createAnonymous(document(), style()) ; | |
2757 case PagedFlowThread: | |
2758 // Paged overflow is currently done using the multicol implementation. | |
2759 return RenderPagedFlowThread::createAnonymous(document(), style()); | |
2760 default: | |
2761 ASSERT_NOT_REACHED(); | |
2762 return nullptr; | |
2763 } | |
2764 } | |
2765 | |
2766 void RenderBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded(const RenderS tyle* oldStyle) | |
2738 { | 2767 { |
2739 if (!document().regionBasedColumnsEnabled()) | 2768 if (!document().regionBasedColumnsEnabled()) |
2740 return; | 2769 return; |
2741 | 2770 |
2742 bool needsFlowThread = style()->specifiesColumns(); | 2771 // Paged overflow trumps multicol in this implementation. Ideally, it should be possible to have |
2743 if (needsFlowThread != static_cast<bool>(multiColumnFlowThread())) { | 2772 // both paged overflow and multicol on the same element, but then we need tw o flow |
2744 if (needsFlowThread) { | 2773 // threads. Anyway, this is nothing to worry about until we can actually nes t multicol properly |
2745 RenderMultiColumnFlowThread* flowThread = RenderMultiColumnFlowThrea d::createAnonymous(document(), style()); | 2774 // inside other fragmentation contexts. |
2746 addChild(flowThread); | 2775 FlowThreadType type = flowThreadType(style()); |
2747 flowThread->populate(); | 2776 |
2748 RenderBlockFlowRareData& rareData = ensureRareData(); | 2777 if (multiColumnFlowThread()) { |
2749 ASSERT(!rareData.m_multiColumnFlowThread); | 2778 ASSERT(oldStyle); |
2750 rareData.m_multiColumnFlowThread = flowThread; | 2779 if (type != flowThreadType(oldStyle)) { |
2751 } else { | 2780 // If we're no longer to be multicol/paged, destroy the flow thread. Also destroy it |
2781 // when switching between multicol and paged, since that affects the column set | |
2782 // structure (multicol containers may have spanners, paged container s may not). | |
2752 multiColumnFlowThread()->evacuateAndDestroy(); | 2783 multiColumnFlowThread()->evacuateAndDestroy(); |
2753 ASSERT(!multiColumnFlowThread()); | 2784 ASSERT(!multiColumnFlowThread()); |
2754 } | 2785 } |
2755 } | 2786 } |
2787 | |
2788 if (type == NoFlowThread || multiColumnFlowThread()) | |
2789 return; | |
2790 | |
2791 RenderMultiColumnFlowThread* flowThread = createMultiColumnFlowThread(type); | |
rune
2014/07/04 12:30:53
Sweet.
| |
2792 addChild(flowThread); | |
2793 flowThread->populate(); | |
2794 RenderBlockFlowRareData& rareData = ensureRareData(); | |
2795 ASSERT(!rareData.m_multiColumnFlowThread); | |
2796 rareData.m_multiColumnFlowThread = flowThread; | |
2756 } | 2797 } |
2757 | 2798 |
2758 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() | 2799 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() |
2759 { | 2800 { |
2760 if (m_rareData) | 2801 if (m_rareData) |
2761 return *m_rareData; | 2802 return *m_rareData; |
2762 | 2803 |
2763 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); | 2804 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); |
2764 return *m_rareData; | 2805 return *m_rareData; |
2765 } | 2806 } |
2766 | 2807 |
2767 } // namespace WebCore | 2808 } // namespace WebCore |
OLD | NEW |