Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: Source/core/rendering/RenderMultiColumnSet.cpp

Issue 601623002: Move paint code from RenderMultiColumnSet to MultiColumnSetPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merged Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderMultiColumnSet.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/rendering/RenderMultiColumnSet.h" 27 #include "core/rendering/RenderMultiColumnSet.h"
28 28
29 #include "core/paint/BoxPainter.h" 29 #include "core/paint/BoxPainter.h"
30 #include "core/paint/MultiColumnSetPainter.h"
30 #include "core/paint/ObjectPainter.h" 31 #include "core/paint/ObjectPainter.h"
31 #include "core/rendering/PaintInfo.h" 32 #include "core/rendering/PaintInfo.h"
32 #include "core/rendering/RenderLayer.h" 33 #include "core/rendering/RenderLayer.h"
33 #include "core/rendering/RenderMultiColumnFlowThread.h" 34 #include "core/rendering/RenderMultiColumnFlowThread.h"
34 35
35 namespace blink { 36 namespace blink {
36 37
37 RenderMultiColumnSet::RenderMultiColumnSet(RenderFlowThread* flowThread) 38 RenderMultiColumnSet::RenderMultiColumnSet(RenderFlowThread* flowThread)
38 : RenderRegion(0, flowThread) 39 : RenderRegion(0, flowThread)
39 , m_columnHeight(0) 40 , m_columnHeight(0)
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 if (!isLeftmostColumn) 415 if (!isLeftmostColumn)
415 overflowRect.shiftYEdgeTo(portionRect.y() - colGap / 2); 416 overflowRect.shiftYEdgeTo(portionRect.y() - colGap / 2);
416 if (!isRightmostColumn) 417 if (!isRightmostColumn)
417 overflowRect.shiftMaxYEdgeTo(portionRect.maxY() + colGap - colGap / 2); 418 overflowRect.shiftMaxYEdgeTo(portionRect.maxY() + colGap - colGap / 2);
418 } 419 }
419 return overflowRect; 420 return overflowRect;
420 } 421 }
421 422
422 void RenderMultiColumnSet::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 423 void RenderMultiColumnSet::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
423 { 424 {
424 if (style()->visibility() != VISIBLE) 425 MultiColumnSetPainter(*this).paintObject(paintInfo, paintOffset);
425 return;
426
427 RenderBlockFlow::paintObject(paintInfo, paintOffset);
428
429 // FIXME: Right now we're only painting in the foreground phase.
430 // Columns should technically respect phases and allow for background/float/ foreground overlap etc., just like
431 // RenderBlocks do. Note this is a pretty minor issue, since the old column implementation clipped columns
432 // anyway, thus making it impossible for them to overlap one another. It's a lso really unlikely that the columns
433 // would overlap another block.
434 if (!m_flowThread || !isValid() || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
435 return;
436
437 paintColumnRules(paintInfo, paintOffset);
438 }
439
440 void RenderMultiColumnSet::paintColumnRules(PaintInfo& paintInfo, const LayoutPo int& paintOffset)
441 {
442 if (flowThread()->isRenderPagedFlowThread())
443 return;
444
445 RenderStyle* blockStyle = multiColumnBlockFlow()->style();
446 const Color& ruleColor = resolveColor(blockStyle, CSSPropertyWebkitColumnRul eColor);
447 bool ruleTransparent = blockStyle->columnRuleIsTransparent();
448 EBorderStyle ruleStyle = blockStyle->columnRuleStyle();
449 LayoutUnit ruleThickness = blockStyle->columnRuleWidth();
450 LayoutUnit colGap = columnGap();
451 bool renderRule = ruleStyle > BHIDDEN && !ruleTransparent;
452 if (!renderRule)
453 return;
454
455 unsigned colCount = actualColumnCount();
456 if (colCount <= 1)
457 return;
458
459 bool antialias = BoxPainter::shouldAntialiasLines(paintInfo.context);
460
461 bool leftToRight = style()->isLeftToRightDirection();
462 LayoutUnit currLogicalLeftOffset = leftToRight ? LayoutUnit() : contentLogic alWidth();
463 LayoutUnit ruleAdd = borderAndPaddingLogicalLeft();
464 LayoutUnit ruleLogicalLeft = leftToRight ? LayoutUnit() : contentLogicalWidt h();
465 LayoutUnit inlineDirectionSize = pageLogicalWidth();
466 BoxSide boxSide = isHorizontalWritingMode()
467 ? leftToRight ? BSLeft : BSRight
468 : leftToRight ? BSTop : BSBottom;
469
470 for (unsigned i = 0; i < colCount; i++) {
471 // Move to the next position.
472 if (leftToRight) {
473 ruleLogicalLeft += inlineDirectionSize + colGap / 2;
474 currLogicalLeftOffset += inlineDirectionSize + colGap;
475 } else {
476 ruleLogicalLeft -= (inlineDirectionSize + colGap / 2);
477 currLogicalLeftOffset -= (inlineDirectionSize + colGap);
478 }
479
480 // Now paint the column rule.
481 if (i < colCount - 1) {
482 LayoutUnit ruleLeft = isHorizontalWritingMode() ? paintOffset.x() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd : paintOffset.x() + borderLeft() + paddingLeft();
483 LayoutUnit ruleRight = isHorizontalWritingMode() ? ruleLeft + ruleTh ickness : ruleLeft + contentWidth();
484 LayoutUnit ruleTop = isHorizontalWritingMode() ? paintOffset.y() + b orderTop() + paddingTop() : paintOffset.y() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd;
485 LayoutUnit ruleBottom = isHorizontalWritingMode() ? ruleTop + conten tHeight() : ruleTop + ruleThickness;
486 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(ruleLeft , ruleTop, ruleRight, ruleBottom);
487 ObjectPainter::drawLineForBoxSide(paintInfo.context, pixelSnappedRul eRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRu leRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias);
488 }
489
490 ruleLogicalLeft = currLogicalLeftOffset;
491 }
492 } 426 }
493 427
494 void RenderMultiColumnSet::paintInvalidationForFlowThreadContent(const LayoutRec t& paintInvalidationRect) const 428 void RenderMultiColumnSet::paintInvalidationForFlowThreadContent(const LayoutRec t& paintInvalidationRect) const
495 { 429 {
496 // Figure out the start and end columns and only check within that range so that we don't walk the 430 // Figure out the start and end columns and only check within that range so that we don't walk the
497 // entire column set. Put the paint invalidation rect into flow thread coord inates by flipping it first. 431 // entire column set. Put the paint invalidation rect into flow thread coord inates by flipping it first.
498 LayoutRect flowThreadPaintInvalidationRect(paintInvalidationRect); 432 LayoutRect flowThreadPaintInvalidationRect(paintInvalidationRect);
499 flowThread()->flipForWritingMode(flowThreadPaintInvalidationRect); 433 flowThread()->flipForWritingMode(flowThreadPaintInvalidationRect);
500 434
501 // Now we can compare this rect with the flow thread portions owned by each column. First let's 435 // Now we can compare this rect with the flow thread portions owned by each column. First let's
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 620
687 void RenderMultiColumnSet::detachRegion() 621 void RenderMultiColumnSet::detachRegion()
688 { 622 {
689 if (m_flowThread) { 623 if (m_flowThread) {
690 m_flowThread->removeRegionFromThread(this); 624 m_flowThread->removeRegionFromThread(this);
691 m_flowThread = 0; 625 m_flowThread = 0;
692 } 626 }
693 } 627 }
694 628
695 } 629 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderMultiColumnSet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698