Modified: trunk/Source/WebCore/ChangeLog (123523 => 123524)
--- trunk/Source/WebCore/ChangeLog 2012-07-24 20:46:31 UTC (rev 123523)
+++ trunk/Source/WebCore/ChangeLog 2012-07-24 20:53:19 UTC (rev 123524)
@@ -1,3 +1,22 @@
+2012-07-24 Tony Chang <[email protected]>
+
+ Make RenderBlock::paintChildren virtual so sub classes can change the paint order
+ https://bugs.webkit.org/show_bug.cgi?id=92042
+
+ Reviewed by Ojan Vafai.
+
+ The flexbox spec says that the order property should change the paint order of flex children.
+ To make that possible, make paintChildren virtual so RenderFlexibleBox can override it.
+
+ No new tests, this is just a refactoring.
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::paintContents): Move some code out of paintChildren into paintContents.
+ (WebCore::RenderBlock::paintChildren): Make virtual and just have it be a simple for loop.
+ (WebCore::RenderBlock::paintChild): Move code out of paintChildren so subclasses can reuse.
+ * rendering/RenderBlock.h:
+ (RenderBlock): Make paintChildren virtual and protected so sub classes can call paintChild.
+
2012-07-24 Anna Cavender <[email protected]>
Create SourceBuffer and SourceBufferList objects
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (123523 => 123524)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-07-24 20:46:31 UTC (rev 123523)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-07-24 20:53:19 UTC (rev 123524)
@@ -2866,62 +2866,70 @@
if (childrenInline())
m_lineBoxes.paint(this, paintInfo, paintOffset);
- else
- paintChildren(paintInfo, paintOffset);
+ else {
+ PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? PaintPhaseOutline : paintInfo.phase;
+ newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChildBlockBackground : newPhase;
+
+ // We don't paint our own background, but we do let the kids paint their backgrounds.
+ PaintInfo paintInfoForChild(paintInfo);
+ paintInfoForChild.phase = newPhase;
+ paintInfoForChild.updatePaintingRootForChildren(this);
+
+ // FIXME: Paint-time pagination is obsolete and is now only used by embedded WebViews inside AppKit
+ // NSViews. Do not add any more code for this.
+ bool usePrintRect = !view()->printRect().isEmpty();
+ paintChildren(paintInfo, paintOffset, paintInfoForChild, usePrintRect);
+ }
}
-void RenderBlock::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+void RenderBlock::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& paintInfoForChild, bool usePrintRect)
{
- PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? PaintPhaseOutline : paintInfo.phase;
- newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChildBlockBackground : newPhase;
-
- // We don't paint our own background, but we do let the kids paint their backgrounds.
- PaintInfo info(paintInfo);
- info.phase = newPhase;
- info.updatePaintingRootForChildren(this);
-
- // FIXME: Paint-time pagination is obsolete and is now only used by embedded WebViews inside AppKit
- // NSViews. Do not add any more code for this.
- RenderView* renderView = view();
- bool usePrintRect = !renderView->printRect().isEmpty();
-
- for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
- // Check for page-break-before: always, and if it's set, break and bail.
- bool checkBeforeAlways = !childrenInline() && (usePrintRect && child->style()->pageBreakBefore() == PBALWAYS);
- LayoutUnit absoluteChildY = paintOffset.y() + child->y();
- if (checkBeforeAlways
- && absoluteChildY > paintInfo.rect.y()
- && absoluteChildY < paintInfo.rect.maxY()) {
- view()->setBestTruncatedAt(absoluteChildY, this, true);
+ for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
+ if (!paintChild(child, paintInfo, paintOffset, paintInfoForChild, usePrintRect))
return;
- }
+ }
+}
- if (!child->isFloating() && child->isReplaced() && usePrintRect && child->height() <= renderView->printRect().height()) {
- // Paginate block-level replaced elements.
- if (absoluteChildY + child->height() > renderView->printRect().maxY()) {
- if (absoluteChildY < renderView->truncatedAt())
- renderView->setBestTruncatedAt(absoluteChildY, child);
- // If we were able to truncate, don't paint.
- if (absoluteChildY >= renderView->truncatedAt())
- break;
- }
+bool RenderBlock::paintChild(RenderBox* child, PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& paintInfoForChild, bool usePrintRect)
+{
+ // Check for page-break-before: always, and if it's set, break and bail.
+ bool checkBeforeAlways = !childrenInline() && (usePrintRect && child->style()->pageBreakBefore() == PBALWAYS);
+ LayoutUnit absoluteChildY = paintOffset.y() + child->y();
+ if (checkBeforeAlways
+ && absoluteChildY > paintInfo.rect.y()
+ && absoluteChildY < paintInfo.rect.maxY()) {
+ view()->setBestTruncatedAt(absoluteChildY, this, true);
+ return false;
+ }
+
+ RenderView* renderView = view();
+ if (!child->isFloating() && child->isReplaced() && usePrintRect && child->height() <= renderView->printRect().height()) {
+ // Paginate block-level replaced elements.
+ if (absoluteChildY + child->height() > renderView->printRect().maxY()) {
+ if (absoluteChildY < renderView->truncatedAt())
+ renderView->setBestTruncatedAt(absoluteChildY, child);
+ // If we were able to truncate, don't paint.
+ if (absoluteChildY >= renderView->truncatedAt())
+ return false;
}
+ }
- LayoutPoint childPoint = flipForWritingModeForChild(child, paintOffset);
- if (!child->hasSelfPaintingLayer() && !child->isFloating())
- child->paint(info, childPoint);
+ LayoutPoint childPoint = flipForWritingModeForChild(child, paintOffset);
+ if (!child->hasSelfPaintingLayer() && !child->isFloating())
+ child->paint(paintInfoForChild, childPoint);
- // Check for page-break-after: always, and if it's set, break and bail.
- bool checkAfterAlways = !childrenInline() && (usePrintRect && child->style()->pageBreakAfter() == PBALWAYS);
- if (checkAfterAlways
- && (absoluteChildY + child->height()) > paintInfo.rect.y()
- && (absoluteChildY + child->height()) < paintInfo.rect.maxY()) {
- view()->setBestTruncatedAt(absoluteChildY + child->height() + max(ZERO_LAYOUT_UNIT, child->collapsedMarginAfter()), this, true);
- return;
- }
+ // Check for page-break-after: always, and if it's set, break and bail.
+ bool checkAfterAlways = !childrenInline() && (usePrintRect && child->style()->pageBreakAfter() == PBALWAYS);
+ if (checkAfterAlways
+ && (absoluteChildY + child->height()) > paintInfo.rect.y()
+ && (absoluteChildY + child->height()) < paintInfo.rect.maxY()) {
+ view()->setBestTruncatedAt(absoluteChildY + child->height() + max(ZERO_LAYOUT_UNIT, child->collapsedMarginAfter()), this, true);
+ return false;
}
+ return true;
}
+
void RenderBlock::paintCaret(PaintInfo& paintInfo, const LayoutPoint& paintOffset, CaretType type)
{
// Paint the caret if the FrameSelection says so or if caret browsing is enabled
Modified: trunk/Source/WebCore/rendering/RenderBlock.h (123523 => 123524)
--- trunk/Source/WebCore/rendering/RenderBlock.h 2012-07-24 20:46:31 UTC (rev 123523)
+++ trunk/Source/WebCore/rendering/RenderBlock.h 2012-07-24 20:53:19 UTC (rev 123524)
@@ -414,6 +414,8 @@
virtual void paint(PaintInfo&, const LayoutPoint&);
virtual void paintObject(PaintInfo&, const LayoutPoint&);
+ virtual void paintChildren(PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect);
+ bool paintChild(RenderBox*, PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect);
LayoutUnit logicalRightOffsetForLine(LayoutUnit position, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* logicalHeightRemaining = 0, LayoutUnit logicalHeight = 0) const;
LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* logicalHeightRemaining = 0, LayoutUnit logicalHeight = 0) const;
@@ -732,7 +734,6 @@
void paintContents(PaintInfo&, const LayoutPoint&);
void paintColumnContents(PaintInfo&, const LayoutPoint&, bool paintFloats = false);
void paintColumnRules(PaintInfo&, const LayoutPoint&);
- void paintChildren(PaintInfo&, const LayoutPoint&);
void paintEllipsisBoxes(PaintInfo&, const LayoutPoint&);
void paintSelection(PaintInfo&, const LayoutPoint&);
void paintCaret(PaintInfo&, const LayoutPoint&, CaretType);