Chromium Code Reviews| 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 void RenderBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded(const RenderS tyle* oldStyle) | |
| 2738 { | 2753 { |
| 2739 if (!document().regionBasedColumnsEnabled()) | 2754 if (!document().regionBasedColumnsEnabled()) |
| 2740 return; | 2755 return; |
| 2741 | 2756 |
| 2742 bool needsFlowThread = style()->specifiesColumns(); | 2757 // Paged overflow trumps multicol in this implementation. Ideally, it should be possible to have |
| 2743 if (needsFlowThread != static_cast<bool>(multiColumnFlowThread())) { | 2758 // both paged overflow and multicol on the same element, but then we need tw o flow |
| 2744 if (needsFlowThread) { | 2759 // threads. Anyway, this is nothing to worry about until we can actually nes t multicol properly |
| 2745 RenderMultiColumnFlowThread* flowThread = RenderMultiColumnFlowThrea d::createAnonymous(document(), style()); | 2760 // inside other fragmentation contexts. |
| 2746 addChild(flowThread); | 2761 FlowThreadType type = flowThreadType(style()); |
| 2747 flowThread->populate(); | 2762 |
| 2748 RenderBlockFlowRareData& rareData = ensureRareData(); | 2763 if (multiColumnFlowThread()) { |
| 2749 ASSERT(!rareData.m_multiColumnFlowThread); | 2764 ASSERT(oldStyle); |
| 2750 rareData.m_multiColumnFlowThread = flowThread; | 2765 if (type != flowThreadType(oldStyle)) { |
| 2751 } else { | 2766 // If we're no longer to be multicol/paged, destroy the flow thread. Also destroy it |
| 2767 // when switching between multicol and paged, since that affects the column set | |
| 2768 // structure (multicol containers may have spanners, paged container s may not). | |
| 2752 multiColumnFlowThread()->evacuateAndDestroy(); | 2769 multiColumnFlowThread()->evacuateAndDestroy(); |
| 2753 ASSERT(!multiColumnFlowThread()); | 2770 ASSERT(!multiColumnFlowThread()); |
| 2754 } | 2771 } |
| 2755 } | 2772 } |
| 2773 if ((type != NoFlowThread) && !multiColumnFlowThread()) { | |
|
rune
2014/07/04 09:44:25
The blink code often use early returns. How about:
| |
| 2774 RenderMultiColumnFlowThread* flowThread; | |
| 2775 if (type == PagedFlowThread) { | |
| 2776 // Paged overflow is currently done using the multicol implementatio n. | |
| 2777 flowThread = RenderPagedFlowThread::createAnonymous(document(), styl e()); | |
| 2778 } else { | |
| 2779 flowThread = RenderMultiColumnFlowThread::createAnonymous(document() , style()); | |
| 2780 } | |
| 2781 addChild(flowThread); | |
| 2782 flowThread->populate(); | |
| 2783 RenderBlockFlowRareData& rareData = ensureRareData(); | |
| 2784 ASSERT(!rareData.m_multiColumnFlowThread); | |
| 2785 rareData.m_multiColumnFlowThread = flowThread; | |
| 2786 } | |
| 2756 } | 2787 } |
| 2757 | 2788 |
| 2758 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() | 2789 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() |
| 2759 { | 2790 { |
| 2760 if (m_rareData) | 2791 if (m_rareData) |
| 2761 return *m_rareData; | 2792 return *m_rareData; |
| 2762 | 2793 |
| 2763 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); | 2794 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); |
| 2764 return *m_rareData; | 2795 return *m_rareData; |
| 2765 } | 2796 } |
| 2766 | 2797 |
| 2767 } // namespace WebCore | 2798 } // namespace WebCore |
| OLD | NEW |