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 21 matching lines...) Expand all Loading... | |
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/LayoutRepainter.h" | 38 #include "core/rendering/LayoutRepainter.h" |
39 #include "core/rendering/RenderFlowThread.h" | 39 #include "core/rendering/RenderFlowThread.h" |
40 #include "core/rendering/RenderLayer.h" | 40 #include "core/rendering/RenderLayer.h" |
41 #include "core/rendering/RenderMultiColumnFlowThread.h" | 41 #include "core/rendering/RenderMultiColumnFlowThread.h" |
42 #include "core/rendering/RenderPagedFlowThread.h" | |
42 #include "core/rendering/RenderText.h" | 43 #include "core/rendering/RenderText.h" |
43 #include "core/rendering/RenderView.h" | 44 #include "core/rendering/RenderView.h" |
44 #include "core/rendering/line/LineWidth.h" | 45 #include "core/rendering/line/LineWidth.h" |
45 #include "core/rendering/svg/SVGTextRunRenderingContext.h" | 46 #include "core/rendering/svg/SVGTextRunRenderingContext.h" |
46 #include "platform/text/BidiTextRun.h" | 47 #include "platform/text/BidiTextRun.h" |
47 | 48 |
48 using namespace std; | 49 using namespace std; |
49 | 50 |
50 namespace WebCore { | 51 namespace WebCore { |
51 | 52 |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1854 } | 1855 } |
1855 } | 1856 } |
1856 } | 1857 } |
1857 } | 1858 } |
1858 | 1859 |
1859 parentBlockFlow->markAllDescendantsWithFloatsForLayout(); | 1860 parentBlockFlow->markAllDescendantsWithFloatsForLayout(); |
1860 parentBlockFlow->markSiblingsWithFloatsForLayout(); | 1861 parentBlockFlow->markSiblingsWithFloatsForLayout(); |
1861 } | 1862 } |
1862 | 1863 |
1863 if (diff.needsFullLayout() || !oldStyle) | 1864 if (diff.needsFullLayout() || !oldStyle) |
1864 createOrDestroyMultiColumnFlowThreadIfNeeded(); | 1865 createOrDestroyMultiColumnFlowThreadIfNeeded(oldStyle); |
1865 } | 1866 } |
1866 | 1867 |
1867 void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, Layou tUnit logicalTop) | 1868 void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, Layou tUnit logicalTop) |
1868 { | 1869 { |
1869 if (child->style()->isOriginalDisplayInlineType()) | 1870 if (child->style()->isOriginalDisplayInlineType()) |
1870 setStaticInlinePositionForChild(child, logicalTop, startAlignedOffsetFor Line(logicalTop, false)); | 1871 setStaticInlinePositionForChild(child, logicalTop, startAlignedOffsetFor Line(logicalTop, false)); |
1871 else | 1872 else |
1872 setStaticInlinePositionForChild(child, logicalTop, startOffsetForContent ()); | 1873 setStaticInlinePositionForChild(child, logicalTop, startOffsetForContent ()); |
1873 } | 1874 } |
1874 | 1875 |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2772 bool hasStrongDirectionality; | 2773 bool hasStrongDirectionality; |
2773 run.setDirection(directionForRun(run, hasStrongDirectionality)); | 2774 run.setDirection(directionForRun(run, hasStrongDirectionality)); |
2774 return run; | 2775 return run; |
2775 } | 2776 } |
2776 | 2777 |
2777 RootInlineBox* RenderBlockFlow::createRootInlineBox() | 2778 RootInlineBox* RenderBlockFlow::createRootInlineBox() |
2778 { | 2779 { |
2779 return new RootInlineBox(*this); | 2780 return new RootInlineBox(*this); |
2780 } | 2781 } |
2781 | 2782 |
2782 void RenderBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded() | 2783 static inline bool isPagedOverflow(const RenderBlockFlow* renderer, const Render Style* style) |
2784 { | |
2785 return style->isOverflowPaged() && renderer->node() != renderer->document(). viewportDefiningElement(); | |
rune
2014/06/18 22:09:05
"this" is always passed as renderer. Why not make
| |
2786 } | |
2787 | |
2788 void RenderBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded(const RenderS tyle* oldStyle) | |
2783 { | 2789 { |
2784 if (!document().regionBasedColumnsEnabled()) | 2790 if (!document().regionBasedColumnsEnabled()) |
2785 return; | 2791 return; |
2786 | 2792 |
2787 bool needsFlowThread = style()->specifiesColumns(); | 2793 // Paged overflow trumps multicol in this implementation. Ideally, it should be possible to have |
2788 if (needsFlowThread != static_cast<bool>(multiColumnFlowThread())) { | 2794 // both paged overflow and multicol on the same element, but then we need tw o flow |
2789 if (needsFlowThread) { | 2795 // threads. Anyway, this is nothing to worry about until we can actually nes t multicol properly |
2790 RenderMultiColumnFlowThread* flowThread = RenderMultiColumnFlowThrea d::createAnonymous(document(), style()); | 2796 // inside other fragmentation contexts. |
2791 addChild(flowThread); | 2797 bool shouldBePaged = isPagedOverflow(this, style()); |
2792 flowThread->populate(); | 2798 bool shouldBeMulticol = !shouldBePaged && style()->specifiesColumns(); |
2793 RenderBlockFlowRareData& rareData = ensureRareData(); | 2799 |
rune
2014/06/18 22:09:05
We can get rid of this code duplication. Also we c
| |
2794 ASSERT(!rareData.m_multiColumnFlowThread); | 2800 if (multiColumnFlowThread()) { |
2795 rareData.m_multiColumnFlowThread = flowThread; | 2801 ASSERT(oldStyle); |
2796 } else { | 2802 bool wasPaged = isPagedOverflow(this, oldStyle); |
2803 bool wasMulticol = !wasPaged && oldStyle->specifiesColumns(); | |
2804 if (wasMulticol != shouldBeMulticol || wasPaged != shouldBePaged) { | |
2805 // If we're no longer to be multicol/paged, destroy the flow thread. Also destroy it | |
2806 // when switching between multicol and paged, since that affects the column set | |
2807 // structure (multicol containers may have spanners, paged container s may not). | |
2797 multiColumnFlowThread()->evacuateAndDestroy(); | 2808 multiColumnFlowThread()->evacuateAndDestroy(); |
2798 ASSERT(!multiColumnFlowThread()); | 2809 ASSERT(!multiColumnFlowThread()); |
2799 } | 2810 } |
2800 } | 2811 } |
2812 if ((shouldBeMulticol || shouldBePaged) && !multiColumnFlowThread()) { | |
2813 RenderMultiColumnFlowThread* flowThread; | |
2814 if (shouldBePaged) { | |
2815 // Paged overflow is currently done using the multicol implementatio n. | |
2816 flowThread = RenderPagedFlowThread::createAnonymous(document(), styl e()); | |
2817 } else { | |
2818 flowThread = RenderMultiColumnFlowThread::createAnonymous(document() , style()); | |
2819 } | |
2820 addChild(flowThread); | |
2821 flowThread->populate(); | |
2822 RenderBlockFlowRareData& rareData = ensureRareData(); | |
2823 ASSERT(!rareData.m_multiColumnFlowThread); | |
2824 rareData.m_multiColumnFlowThread = flowThread; | |
2825 } | |
2801 } | 2826 } |
2802 | 2827 |
2803 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() | 2828 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() |
2804 { | 2829 { |
2805 if (m_rareData) | 2830 if (m_rareData) |
2806 return *m_rareData; | 2831 return *m_rareData; |
2807 | 2832 |
2808 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); | 2833 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); |
2809 return *m_rareData; | 2834 return *m_rareData; |
2810 } | 2835 } |
2811 | 2836 |
2812 } // namespace WebCore | 2837 } // namespace WebCore |
OLD | NEW |