From: ojan@chromium.org Date: Fri, 15 Feb 2013 21:18:20 +0000 (+0000) Subject: Implement RenderGrid::computeIntrinsicLogicalWidths X-Git-Url: https://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=d9c4cc8b874bfea405e42c7a8f0c489458fda6c7;hp=c980ce4d456f98966a54c8e520f9eabf52016a28 Implement RenderGrid::computeIntrinsicLogicalWidths https://bugs.webkit.org/show_bug.cgi?id=109881 Reviewed by Tony Chang. For now this is not observable due to the FIXMEs for unimplemented bits of computePreferredLogicalWidths. But, soon, I'll be removing the computePreferredLogicalWidths override entirely and instead use RenderBlock's, which will also address the RenderGrid FIXMEs. * rendering/RenderGrid.cpp: (WebCore::RenderGrid::computeIntrinsicLogicalWidths): const_cast the usages of m_grid. Alternately, we could stack allocate it, but there's disagreement on whether that's the right choice. See https://bugs.webkit.org/show_bug.cgi?id=109880. (WebCore::RenderGrid::computePreferredLogicalWidths): * rendering/RenderGrid.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143043 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index ded7140247b3..b16449b73674 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,24 @@ +2013-02-14 Ojan Vafai + + Implement RenderGrid::computeIntrinsicLogicalWidths + https://bugs.webkit.org/show_bug.cgi?id=109881 + + Reviewed by Tony Chang. + + For now this is not observable due to the FIXMEs for unimplemented bits + of computePreferredLogicalWidths. But, soon, I'll be removing the computePreferredLogicalWidths + override entirely and instead use RenderBlock's, which will also address the + RenderGrid FIXMEs. + + * rendering/RenderGrid.cpp: + (WebCore::RenderGrid::computeIntrinsicLogicalWidths): + const_cast the usages of m_grid. Alternately, we could stack allocate it, but there's disagreement on + whether that's the right choice. See https://bugs.webkit.org/show_bug.cgi?id=109880. + + (WebCore::RenderGrid::computePreferredLogicalWidths): + * rendering/RenderGrid.h: + + 2013-02-15 Xueqing Huang Flexbox should ignore firstLine pseudo element. diff --git a/Source/WebCore/rendering/RenderGrid.cpp b/Source/WebCore/rendering/RenderGrid.cpp index 13efad999f24..af8e8cb0b3f8 100644 --- a/Source/WebCore/rendering/RenderGrid.cpp +++ b/Source/WebCore/rendering/RenderGrid.cpp @@ -168,30 +168,34 @@ void RenderGrid::layoutBlock(bool relayoutChildren, LayoutUnit) setNeedsLayout(false); } -void RenderGrid::computePreferredLogicalWidths() +void RenderGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const { - ASSERT(preferredLogicalWidthsDirty()); - - placeItemsOnGrid(); - - m_minPreferredLogicalWidth = 0; - m_maxPreferredLogicalWidth = 0; - - // FIXME: We don't take our own logical width into account. + const_cast(this)->placeItemsOnGrid(); const Vector& trackStyles = style()->gridColumns(); - for (size_t i = 0; i < trackStyles.size(); ++i) { LayoutUnit minTrackBreadth = computePreferredTrackWidth(trackStyles[i].minTrackBreadth(), i); LayoutUnit maxTrackBreadth = computePreferredTrackWidth(trackStyles[i].maxTrackBreadth(), i); maxTrackBreadth = std::max(maxTrackBreadth, minTrackBreadth); - m_minPreferredLogicalWidth += minTrackBreadth; - m_maxPreferredLogicalWidth += maxTrackBreadth; + minLogicalWidth += minTrackBreadth; + maxLogicalWidth += maxTrackBreadth; // FIXME: This should add in the scrollbarWidth (e.g. see RenderFlexibleBox). } + const_cast(this)->m_grid.clear(); +} + +void RenderGrid::computePreferredLogicalWidths() +{ + ASSERT(preferredLogicalWidthsDirty()); + + m_minPreferredLogicalWidth = 0; + m_maxPreferredLogicalWidth = 0; + + // FIXME: We don't take our own logical width into account. + computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth); // FIXME: We should account for min / max logical width. LayoutUnit borderAndPaddingInInlineDirection = borderAndPaddingLogicalWidth(); @@ -199,7 +203,6 @@ void RenderGrid::computePreferredLogicalWidths() m_maxPreferredLogicalWidth += borderAndPaddingInInlineDirection; setPreferredLogicalWidthsDirty(false); - m_grid.clear(); } LayoutUnit RenderGrid::computePreferredTrackWidth(const Length& length, size_t trackIndex) const diff --git a/Source/WebCore/rendering/RenderGrid.h b/Source/WebCore/rendering/RenderGrid.h index d3c6bb190ace..726fb1441a9f 100644 --- a/Source/WebCore/rendering/RenderGrid.h +++ b/Source/WebCore/rendering/RenderGrid.h @@ -46,6 +46,7 @@ public: private: virtual bool isRenderGrid() const OVERRIDE { return true; } + virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE; virtual void computePreferredLogicalWidths() OVERRIDE; LayoutUnit computePreferredTrackWidth(const Length&, size_t) const;