| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 2898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2909 } | 2909 } |
| 2910 } | 2910 } |
| 2911 } | 2911 } |
| 2912 | 2912 |
| 2913 void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 2913 void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
| 2914 { | 2914 { |
| 2915 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 2915 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); |
| 2916 | 2916 |
| 2917 LayoutPoint adjustedPaintOffset = paintOffset + location(); | 2917 LayoutPoint adjustedPaintOffset = paintOffset + location(); |
| 2918 | 2918 |
| 2919 PaintPhase phase = paintInfo.phase; | 2919 PaintPhase phase = paintInfo.getPhase(); |
| 2920 | 2920 |
| 2921 // Check if we need to do anything at all. | 2921 // Check if we need to do anything at all. |
| 2922 // FIXME: Could eliminate the isRoot() check if we fix background painting s
o that the RenderView | 2922 // FIXME: Could eliminate the isRoot() check if we fix background painting s
o that the RenderView |
| 2923 // paints the root's background. | 2923 // paints the root's background. |
| 2924 if (!isRoot()) { | 2924 if (!isRoot()) { |
| 2925 LayoutRect overflowBox = overflowRectForPaintRejection(); | 2925 LayoutRect overflowBox = overflowRectForPaintRejection(); |
| 2926 flipForWritingMode(overflowBox); | 2926 flipForWritingMode(overflowBox); |
| 2927 overflowBox.inflate(maximalOutlineSize(paintInfo.phase)); | 2927 overflowBox.inflate(maximalOutlineSize(paintInfo.getPhase())); |
| 2928 overflowBox.moveBy(adjustedPaintOffset); | 2928 overflowBox.moveBy(adjustedPaintOffset); |
| 2929 if (!overflowBox.intersects(paintInfo.rect)) | 2929 if (!overflowBox.intersects(paintInfo.getRect())) |
| 2930 return; | 2930 return; |
| 2931 } | 2931 } |
| 2932 | 2932 |
| 2933 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset); | 2933 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset); |
| 2934 paintObject(paintInfo, adjustedPaintOffset); | 2934 paintObject(paintInfo, adjustedPaintOffset); |
| 2935 if (pushedClip) | 2935 if (pushedClip) |
| 2936 popContentsClip(paintInfo, phase, adjustedPaintOffset); | 2936 popContentsClip(paintInfo, phase, adjustedPaintOffset); |
| 2937 | 2937 |
| 2938 // Our scrollbar widgets paint exactly when we tell them to, so that they wo
rk properly with | 2938 // Our scrollbar widgets paint exactly when we tell them to, so that they wo
rk properly with |
| 2939 // z-index. We paint after we painted the background/border, so that the sc
rollbars will | 2939 // z-index. We paint after we painted the background/border, so that the sc
rollbars will |
| 2940 // sit above the background/border. | 2940 // sit above the background/border. |
| 2941 if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == Paint
PhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.sh
ouldPaintWithinRoot(this) && !paintInfo.paintRootBackgroundOnly()) | 2941 if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == Paint
PhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.sh
ouldPaintWithinRoot(this) && !paintInfo.paintRootBackgroundOnly()) |
| 2942 layer()->paintOverflowControls(paintInfo.context, roundedIntPoint(adjust
edPaintOffset), paintInfo.rect); | 2942 layer()->paintOverflowControls(paintInfo.getContext(), roundedIntPoint(a
djustedPaintOffset), paintInfo.getRect()); |
| 2943 } | 2943 } |
| 2944 | 2944 |
| 2945 void RenderBlock::paintColumnRules(PaintInfo& paintInfo, const LayoutPoint& pain
tOffset) | 2945 void RenderBlock::paintColumnRules(PaintInfo& paintInfo, const LayoutPoint& pain
tOffset) |
| 2946 { | 2946 { |
| 2947 if (paintInfo.context->paintingDisabled()) | 2947 if (paintInfo.getContext()->paintingDisabled()) |
| 2948 return; | 2948 return; |
| 2949 | 2949 |
| 2950 const Color& ruleColor = resolveColor(CSSPropertyWebkitColumnRuleColor); | 2950 const Color& ruleColor = resolveColor(CSSPropertyWebkitColumnRuleColor); |
| 2951 bool ruleTransparent = style()->columnRuleIsTransparent(); | 2951 bool ruleTransparent = style()->columnRuleIsTransparent(); |
| 2952 EBorderStyle ruleStyle = style()->columnRuleStyle(); | 2952 EBorderStyle ruleStyle = style()->columnRuleStyle(); |
| 2953 LayoutUnit ruleThickness = style()->columnRuleWidth(); | 2953 LayoutUnit ruleThickness = style()->columnRuleWidth(); |
| 2954 LayoutUnit colGap = columnGap(); | 2954 LayoutUnit colGap = columnGap(); |
| 2955 bool renderRule = ruleStyle > BHIDDEN && !ruleTransparent; | 2955 bool renderRule = ruleStyle > BHIDDEN && !ruleTransparent; |
| 2956 if (!renderRule) | 2956 if (!renderRule) |
| 2957 return; | 2957 return; |
| 2958 | 2958 |
| 2959 ColumnInfo* colInfo = columnInfo(); | 2959 ColumnInfo* colInfo = columnInfo(); |
| 2960 unsigned colCount = columnCount(colInfo); | 2960 unsigned colCount = columnCount(colInfo); |
| 2961 | 2961 |
| 2962 bool antialias = shouldAntialiasLines(paintInfo.context); | 2962 bool antialias = shouldAntialiasLines(paintInfo.getContext()); |
| 2963 | 2963 |
| 2964 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) { | 2964 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) { |
| 2965 bool leftToRight = style()->isLeftToRightDirection() ^ colInfo->progress
ionIsReversed(); | 2965 bool leftToRight = style()->isLeftToRightDirection() ^ colInfo->progress
ionIsReversed(); |
| 2966 LayoutUnit currLogicalLeftOffset = leftToRight ? LayoutUnit() : contentL
ogicalWidth(); | 2966 LayoutUnit currLogicalLeftOffset = leftToRight ? LayoutUnit() : contentL
ogicalWidth(); |
| 2967 LayoutUnit ruleAdd = logicalLeftOffsetForContent(); | 2967 LayoutUnit ruleAdd = logicalLeftOffsetForContent(); |
| 2968 LayoutUnit ruleLogicalLeft = leftToRight ? LayoutUnit() : contentLogical
Width(); | 2968 LayoutUnit ruleLogicalLeft = leftToRight ? LayoutUnit() : contentLogical
Width(); |
| 2969 LayoutUnit inlineDirectionSize = colInfo->desiredColumnWidth(); | 2969 LayoutUnit inlineDirectionSize = colInfo->desiredColumnWidth(); |
| 2970 BoxSide boxSide = isHorizontalWritingMode() | 2970 BoxSide boxSide = isHorizontalWritingMode() |
| 2971 ? leftToRight ? BSLeft : BSRight | 2971 ? leftToRight ? BSLeft : BSRight |
| 2972 : leftToRight ? BSTop : BSBottom; | 2972 : leftToRight ? BSTop : BSBottom; |
| 2973 | 2973 |
| 2974 for (unsigned i = 0; i < colCount; i++) { | 2974 for (unsigned i = 0; i < colCount; i++) { |
| 2975 // Move to the next position. | 2975 // Move to the next position. |
| 2976 if (leftToRight) { | 2976 if (leftToRight) { |
| 2977 ruleLogicalLeft += inlineDirectionSize + colGap / 2; | 2977 ruleLogicalLeft += inlineDirectionSize + colGap / 2; |
| 2978 currLogicalLeftOffset += inlineDirectionSize + colGap; | 2978 currLogicalLeftOffset += inlineDirectionSize + colGap; |
| 2979 } else { | 2979 } else { |
| 2980 ruleLogicalLeft -= (inlineDirectionSize + colGap / 2); | 2980 ruleLogicalLeft -= (inlineDirectionSize + colGap / 2); |
| 2981 currLogicalLeftOffset -= (inlineDirectionSize + colGap); | 2981 currLogicalLeftOffset -= (inlineDirectionSize + colGap); |
| 2982 } | 2982 } |
| 2983 | 2983 |
| 2984 // Now paint the column rule. | 2984 // Now paint the column rule. |
| 2985 if (i < colCount - 1) { | 2985 if (i < colCount - 1) { |
| 2986 LayoutUnit ruleLeft = isHorizontalWritingMode() ? paintOffset.x(
) + ruleLogicalLeft - ruleThickness / 2 + ruleAdd : paintOffset.x() + borderLeft
() + paddingLeft(); | 2986 LayoutUnit ruleLeft = isHorizontalWritingMode() ? paintOffset.x(
) + ruleLogicalLeft - ruleThickness / 2 + ruleAdd : paintOffset.x() + borderLeft
() + paddingLeft(); |
| 2987 LayoutUnit ruleRight = isHorizontalWritingMode() ? ruleLeft + ru
leThickness : ruleLeft + contentWidth(); | 2987 LayoutUnit ruleRight = isHorizontalWritingMode() ? ruleLeft + ru
leThickness : ruleLeft + contentWidth(); |
| 2988 LayoutUnit ruleTop = isHorizontalWritingMode() ? paintOffset.y()
+ borderTop() + paddingTop() : paintOffset.y() + ruleLogicalLeft - ruleThicknes
s / 2 + ruleAdd; | 2988 LayoutUnit ruleTop = isHorizontalWritingMode() ? paintOffset.y()
+ borderTop() + paddingTop() : paintOffset.y() + ruleLogicalLeft - ruleThicknes
s / 2 + ruleAdd; |
| 2989 LayoutUnit ruleBottom = isHorizontalWritingMode() ? ruleTop + co
ntentHeight() : ruleTop + ruleThickness; | 2989 LayoutUnit ruleBottom = isHorizontalWritingMode() ? ruleTop + co
ntentHeight() : ruleTop + ruleThickness; |
| 2990 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(rule
Left, ruleTop, ruleRight, ruleBottom); | 2990 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(rule
Left, ruleTop, ruleRight, ruleBottom); |
| 2991 drawLineForBoxSide(paintInfo.context, pixelSnappedRuleRect.x(),
pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.maxY
(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); | 2991 drawLineForBoxSide(paintInfo.getContext(), pixelSnappedRuleRect.
x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect
.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); |
| 2992 } | 2992 } |
| 2993 | 2993 |
| 2994 ruleLogicalLeft = currLogicalLeftOffset; | 2994 ruleLogicalLeft = currLogicalLeftOffset; |
| 2995 } | 2995 } |
| 2996 } else { | 2996 } else { |
| 2997 bool topToBottom = !style()->isFlippedBlocksWritingMode() ^ colInfo->pro
gressionIsReversed(); | 2997 bool topToBottom = !style()->isFlippedBlocksWritingMode() ^ colInfo->pro
gressionIsReversed(); |
| 2998 LayoutUnit ruleLeft = isHorizontalWritingMode() | 2998 LayoutUnit ruleLeft = isHorizontalWritingMode() |
| 2999 ? borderLeft() + paddingLeft() | 2999 ? borderLeft() + paddingLeft() |
| 3000 : colGap / 2 - colGap - ruleThickness / 2 + (!colInfo->progressionIs
Reversed() ? borderBefore() + paddingBefore() : borderAfter() + paddingAfter()); | 3000 : colGap / 2 - colGap - ruleThickness / 2 + (!colInfo->progressionIs
Reversed() ? borderBefore() + paddingBefore() : borderAfter() + paddingAfter()); |
| 3001 LayoutUnit ruleWidth = isHorizontalWritingMode() ? contentWidth() : rule
Thickness; | 3001 LayoutUnit ruleWidth = isHorizontalWritingMode() ? contentWidth() : rule
Thickness; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3018 ? topToBottom ? BSTop : BSBottom | 3018 ? topToBottom ? BSTop : BSBottom |
| 3019 : topToBottom ? BSLeft : BSRight; | 3019 : topToBottom ? BSLeft : BSRight; |
| 3020 | 3020 |
| 3021 LayoutSize step(0, topToBottom ? colInfo->columnHeight() + colGap : -(co
lInfo->columnHeight() + colGap)); | 3021 LayoutSize step(0, topToBottom ? colInfo->columnHeight() + colGap : -(co
lInfo->columnHeight() + colGap)); |
| 3022 if (!isHorizontalWritingMode()) | 3022 if (!isHorizontalWritingMode()) |
| 3023 step = step.transposedSize(); | 3023 step = step.transposedSize(); |
| 3024 | 3024 |
| 3025 for (unsigned i = 1; i < colCount; i++) { | 3025 for (unsigned i = 1; i < colCount; i++) { |
| 3026 ruleRect.move(step); | 3026 ruleRect.move(step); |
| 3027 IntRect pixelSnappedRuleRect = pixelSnappedIntRect(ruleRect); | 3027 IntRect pixelSnappedRuleRect = pixelSnappedIntRect(ruleRect); |
| 3028 drawLineForBoxSide(paintInfo.context, pixelSnappedRuleRect.x(), pixe
lSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.maxY(),
boxSide, ruleColor, ruleStyle, 0, 0, antialias); | 3028 drawLineForBoxSide(paintInfo.getContext(), pixelSnappedRuleRect.x(),
pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.max
Y(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); |
| 3029 } | 3029 } |
| 3030 } | 3030 } |
| 3031 } | 3031 } |
| 3032 | 3032 |
| 3033 void RenderBlock::paintColumnContents(PaintInfo& paintInfo, const LayoutPoint& p
aintOffset, bool paintingFloats) | 3033 void RenderBlock::paintColumnContents(PaintInfo& paintInfo, const LayoutPoint& p
aintOffset, bool paintingFloats) |
| 3034 { | 3034 { |
| 3035 // We need to do multiple passes, breaking up our child painting into strips
. | 3035 // We need to do multiple passes, breaking up our child painting into strips
. |
| 3036 GraphicsContext* context = paintInfo.context; | 3036 GraphicsContext* context = paintInfo.getContext(); |
| 3037 ColumnInfo* colInfo = columnInfo(); | 3037 ColumnInfo* colInfo = columnInfo(); |
| 3038 unsigned colCount = columnCount(colInfo); | 3038 unsigned colCount = columnCount(colInfo); |
| 3039 if (!colCount) | 3039 if (!colCount) |
| 3040 return; | 3040 return; |
| 3041 LayoutUnit currLogicalTopOffset = 0; | 3041 LayoutUnit currLogicalTopOffset = 0; |
| 3042 LayoutUnit colGap = columnGap(); | 3042 LayoutUnit colGap = columnGap(); |
| 3043 for (unsigned i = 0; i < colCount; i++) { | 3043 for (unsigned i = 0; i < colCount; i++) { |
| 3044 // For each rect, we clip to the rect, and then we adjust our coords. | 3044 // For each rect, we clip to the rect, and then we adjust our coords. |
| 3045 LayoutRect colRect = columnRectAt(colInfo, i); | 3045 LayoutRect colRect = columnRectAt(colInfo, i); |
| 3046 flipForWritingMode(colRect); | 3046 flipForWritingMode(colRect); |
| 3047 LayoutUnit logicalLeftOffset = (isHorizontalWritingMode() ? colRect.x()
: colRect.y()) - logicalLeftOffsetForContent(); | 3047 LayoutUnit logicalLeftOffset = (isHorizontalWritingMode() ? colRect.x()
: colRect.y()) - logicalLeftOffsetForContent(); |
| 3048 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(logicalLeftOf
fset, currLogicalTopOffset) : LayoutSize(currLogicalTopOffset, logicalLeftOffset
); | 3048 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(logicalLeftOf
fset, currLogicalTopOffset) : LayoutSize(currLogicalTopOffset, logicalLeftOffset
); |
| 3049 if (colInfo->progressionAxis() == ColumnInfo::BlockAxis) { | 3049 if (colInfo->progressionAxis() == ColumnInfo::BlockAxis) { |
| 3050 if (isHorizontalWritingMode()) | 3050 if (isHorizontalWritingMode()) |
| 3051 offset.expand(0, colRect.y() - borderTop() - paddingTop()); | 3051 offset.expand(0, colRect.y() - borderTop() - paddingTop()); |
| 3052 else | 3052 else |
| 3053 offset.expand(colRect.x() - borderLeft() - paddingLeft(), 0); | 3053 offset.expand(colRect.x() - borderLeft() - paddingLeft(), 0); |
| 3054 } | 3054 } |
| 3055 colRect.moveBy(paintOffset); | 3055 colRect.moveBy(paintOffset); |
| 3056 PaintInfo info(paintInfo); | 3056 PaintInfo info(paintInfo); |
| 3057 info.rect.intersect(pixelSnappedIntRect(colRect)); | 3057 info.getRect().intersect(pixelSnappedIntRect(colRect)); |
| 3058 | 3058 |
| 3059 if (!info.rect.isEmpty()) { | 3059 if (!info.getRect().isEmpty()) { |
| 3060 GraphicsContextStateSaver stateSaver(*context); | 3060 GraphicsContextStateSaver stateSaver(*context); |
| 3061 LayoutRect clipRect(colRect); | 3061 LayoutRect clipRect(colRect); |
| 3062 | 3062 |
| 3063 if (i < colCount - 1) { | 3063 if (i < colCount - 1) { |
| 3064 if (isHorizontalWritingMode()) | 3064 if (isHorizontalWritingMode()) |
| 3065 clipRect.expand(colGap / 2, 0); | 3065 clipRect.expand(colGap / 2, 0); |
| 3066 else | 3066 else |
| 3067 clipRect.expand(0, colGap / 2); | 3067 clipRect.expand(0, colGap / 2); |
| 3068 } | 3068 } |
| 3069 // Each strip pushes a clip, since column boxes are specified as bei
ng | 3069 // Each strip pushes a clip, since column boxes are specified as bei
ng |
| 3070 // like overflow:hidden. | 3070 // like overflow:hidden. |
| 3071 // FIXME: Content and column rules that extend outside column boxes
at the edges of the multi-column element | 3071 // FIXME: Content and column rules that extend outside column boxes
at the edges of the multi-column element |
| 3072 // are clipped according to the 'overflow' property. | 3072 // are clipped according to the 'overflow' property. |
| 3073 context->clip(pixelSnappedIntRect(clipRect)); | 3073 context->clip(pixelSnappedIntRect(clipRect)); |
| 3074 | 3074 |
| 3075 // Adjust our x and y when painting. | 3075 // Adjust our x and y when painting. |
| 3076 LayoutPoint adjustedPaintOffset = paintOffset + offset; | 3076 LayoutPoint adjustedPaintOffset = paintOffset + offset; |
| 3077 if (paintingFloats) | 3077 if (paintingFloats) |
| 3078 paintFloats(info, adjustedPaintOffset, paintInfo.phase == PaintP
haseSelection || paintInfo.phase == PaintPhaseTextClip); | 3078 paintFloats(info, adjustedPaintOffset, paintInfo.getPhase() == P
aintPhaseSelection || paintInfo.getPhase() == PaintPhaseTextClip); |
| 3079 else | 3079 else |
| 3080 paintContents(info, adjustedPaintOffset); | 3080 paintContents(info, adjustedPaintOffset); |
| 3081 } | 3081 } |
| 3082 | 3082 |
| 3083 LayoutUnit blockDelta = (isHorizontalWritingMode() ? colRect.height() :
colRect.width()); | 3083 LayoutUnit blockDelta = (isHorizontalWritingMode() ? colRect.height() :
colRect.width()); |
| 3084 if (style()->isFlippedBlocksWritingMode()) | 3084 if (style()->isFlippedBlocksWritingMode()) |
| 3085 currLogicalTopOffset += blockDelta; | 3085 currLogicalTopOffset += blockDelta; |
| 3086 else | 3086 else |
| 3087 currLogicalTopOffset -= blockDelta; | 3087 currLogicalTopOffset -= blockDelta; |
| 3088 } | 3088 } |
| 3089 } | 3089 } |
| 3090 | 3090 |
| 3091 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) | 3091 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) |
| 3092 { | 3092 { |
| 3093 // Avoid painting descendants of the root element when stylesheets haven't l
oaded. This eliminates FOUC. | 3093 // Avoid painting descendants of the root element when stylesheets haven't l
oaded. This eliminates FOUC. |
| 3094 // It's ok not to draw, because later on, when all the stylesheets do load,
styleResolverChanged() on the Document | 3094 // It's ok not to draw, because later on, when all the stylesheets do load,
styleResolverChanged() on the Document |
| 3095 // will do a full repaint. | 3095 // will do a full repaint. |
| 3096 if (document()->didLayoutWithPendingStylesheets() && !isRenderView()) | 3096 if (document()->didLayoutWithPendingStylesheets() && !isRenderView()) |
| 3097 return; | 3097 return; |
| 3098 | 3098 |
| 3099 if (childrenInline()) | 3099 if (childrenInline()) |
| 3100 m_lineBoxes.paint(this, paintInfo, paintOffset); | 3100 m_lineBoxes.paint(this, paintInfo, paintOffset); |
| 3101 else { | 3101 else { |
| 3102 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? Pai
ntPhaseOutline : paintInfo.phase; | 3102 PaintPhase newPhase = (paintInfo.getPhase() == PaintPhaseChildOutlines)
? PaintPhaseOutline : paintInfo.getPhase(); |
| 3103 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi
ldBlockBackground : newPhase; | 3103 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi
ldBlockBackground : newPhase; |
| 3104 | 3104 |
| 3105 // We don't paint our own background, but we do let the kids paint their
backgrounds. | 3105 // We don't paint our own background, but we do let the kids paint their
backgrounds. |
| 3106 PaintInfo paintInfoForChild(paintInfo); | 3106 PaintInfo paintInfoForChild(paintInfo); |
| 3107 paintInfoForChild.phase = newPhase; | 3107 paintInfoForChild.setPhase(newPhase); |
| 3108 paintInfoForChild.updatePaintingRootForChildren(this); | 3108 paintInfoForChild.updatePaintingRootForChildren(this); |
| 3109 paintChildren(paintInfoForChild, paintOffset); | 3109 paintChildren(paintInfoForChild, paintOffset); |
| 3110 } | 3110 } |
| 3111 } | 3111 } |
| 3112 | 3112 |
| 3113 void RenderBlock::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) | 3113 void RenderBlock::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) |
| 3114 { | 3114 { |
| 3115 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) | 3115 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) |
| 3116 paintChild(child, paintInfo, paintOffset); | 3116 paintChild(child, paintInfo, paintOffset); |
| 3117 } | 3117 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3133 if (type == CursorCaret) { | 3133 if (type == CursorCaret) { |
| 3134 caretPainter = frame()->selection()->caretRenderer(); | 3134 caretPainter = frame()->selection()->caretRenderer(); |
| 3135 isContentEditable = frame()->selection()->rendererIsEditable(); | 3135 isContentEditable = frame()->selection()->rendererIsEditable(); |
| 3136 } else { | 3136 } else { |
| 3137 caretPainter = frame()->page()->dragCaretController()->caretRenderer(); | 3137 caretPainter = frame()->page()->dragCaretController()->caretRenderer(); |
| 3138 isContentEditable = frame()->page()->dragCaretController()->isContentEdi
table(); | 3138 isContentEditable = frame()->page()->dragCaretController()->isContentEdi
table(); |
| 3139 } | 3139 } |
| 3140 | 3140 |
| 3141 if (caretPainter == this && (isContentEditable || caretBrowsing)) { | 3141 if (caretPainter == this && (isContentEditable || caretBrowsing)) { |
| 3142 if (type == CursorCaret) | 3142 if (type == CursorCaret) |
| 3143 frame()->selection()->paintCaret(paintInfo.context, paintOffset, pai
ntInfo.rect); | 3143 frame()->selection()->paintCaret(paintInfo.getContext(), paintOffset
, paintInfo.getRect()); |
| 3144 else | 3144 else |
| 3145 frame()->page()->dragCaretController()->paintDragCaret(frame(), pain
tInfo.context, paintOffset, paintInfo.rect); | 3145 frame()->page()->dragCaretController()->paintDragCaret(frame(), pain
tInfo.getContext(), paintOffset, paintInfo.getRect()); |
| 3146 } | 3146 } |
| 3147 } | 3147 } |
| 3148 | 3148 |
| 3149 void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) | 3149 void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) |
| 3150 { | 3150 { |
| 3151 PaintPhase paintPhase = paintInfo.phase; | 3151 PaintPhase paintPhase = paintInfo.getPhase(); |
| 3152 | 3152 |
| 3153 // 1. paint background, borders etc | 3153 // 1. paint background, borders etc |
| 3154 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil
dBlockBackground) && style()->visibility() == VISIBLE) { | 3154 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil
dBlockBackground) && style()->visibility() == VISIBLE) { |
| 3155 if (hasBoxDecorations()) | 3155 if (hasBoxDecorations()) |
| 3156 paintBoxDecorations(paintInfo, paintOffset); | 3156 paintBoxDecorations(paintInfo, paintOffset); |
| 3157 if (hasColumns() && !paintInfo.paintRootBackgroundOnly()) | 3157 if (hasColumns() && !paintInfo.paintRootBackgroundOnly()) |
| 3158 paintColumnRules(paintInfo, paintOffset); | 3158 paintColumnRules(paintInfo, paintOffset); |
| 3159 } | 3159 } |
| 3160 | 3160 |
| 3161 if (paintPhase == PaintPhaseMask && style()->visibility() == VISIBLE) { | 3161 if (paintPhase == PaintPhaseMask && style()->visibility() == VISIBLE) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3252 if (!floats) | 3252 if (!floats) |
| 3253 return; | 3253 return; |
| 3254 | 3254 |
| 3255 const FloatingObjectSet& floatingObjectSet = floats->set(); | 3255 const FloatingObjectSet& floatingObjectSet = floats->set(); |
| 3256 FloatingObjectSetIterator end = floatingObjectSet.end(); | 3256 FloatingObjectSetIterator end = floatingObjectSet.end(); |
| 3257 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 3257 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
| 3258 FloatingObject* r = *it; | 3258 FloatingObject* r = *it; |
| 3259 // Only paint the object if our m_shouldPaint flag is set. | 3259 // Only paint the object if our m_shouldPaint flag is set. |
| 3260 if (r->shouldPaint() && !r->m_renderer->hasSelfPaintingLayer()) { | 3260 if (r->shouldPaint() && !r->m_renderer->hasSelfPaintingLayer()) { |
| 3261 PaintInfo currentPaintInfo(paintInfo); | 3261 PaintInfo currentPaintInfo(paintInfo); |
| 3262 currentPaintInfo.phase = preservePhase ? paintInfo.phase : PaintPhas
eBlockBackground; | 3262 PaintPhase phase = preservePhase ? paintInfo.getPhase() : PaintPhase
BlockBackground; |
| 3263 currentPaintInfo.setPhase(phase); |
| 3263 LayoutPoint childPoint = flipFloatForWritingModeForChild(r, LayoutPo
int(paintOffset.x() + xPositionForFloatIncludingMargin(r) - r->m_renderer->x(),
paintOffset.y() + yPositionForFloatIncludingMargin(r) - r->m_renderer->y())); | 3264 LayoutPoint childPoint = flipFloatForWritingModeForChild(r, LayoutPo
int(paintOffset.x() + xPositionForFloatIncludingMargin(r) - r->m_renderer->x(),
paintOffset.y() + yPositionForFloatIncludingMargin(r) - r->m_renderer->y())); |
| 3264 r->m_renderer->paint(currentPaintInfo, childPoint); | 3265 r->m_renderer->paint(currentPaintInfo, childPoint); |
| 3265 if (!preservePhase) { | 3266 if (!preservePhase) { |
| 3266 currentPaintInfo.phase = PaintPhaseChildBlockBackgrounds; | 3267 currentPaintInfo.setPhase(PaintPhaseChildBlockBackgrounds); |
| 3267 r->m_renderer->paint(currentPaintInfo, childPoint); | 3268 r->m_renderer->paint(currentPaintInfo, childPoint); |
| 3268 currentPaintInfo.phase = PaintPhaseFloat; | 3269 currentPaintInfo.setPhase(PaintPhaseFloat); |
| 3269 r->m_renderer->paint(currentPaintInfo, childPoint); | 3270 r->m_renderer->paint(currentPaintInfo, childPoint); |
| 3270 currentPaintInfo.phase = PaintPhaseForeground; | 3271 currentPaintInfo.setPhase(PaintPhaseForeground); |
| 3271 r->m_renderer->paint(currentPaintInfo, childPoint); | 3272 r->m_renderer->paint(currentPaintInfo, childPoint); |
| 3272 currentPaintInfo.phase = PaintPhaseOutline; | 3273 currentPaintInfo.setPhase(PaintPhaseOutline); |
| 3273 r->m_renderer->paint(currentPaintInfo, childPoint); | 3274 r->m_renderer->paint(currentPaintInfo, childPoint); |
| 3274 } | 3275 } |
| 3275 } | 3276 } |
| 3276 } | 3277 } |
| 3277 } | 3278 } |
| 3278 | 3279 |
| 3279 RenderInline* RenderBlock::inlineElementContinuation() const | 3280 RenderInline* RenderBlock::inlineElementContinuation() const |
| 3280 { | 3281 { |
| 3281 RenderBoxModelObject* continuation = this->continuation(); | 3282 RenderBoxModelObject* continuation = this->continuation(); |
| 3282 return continuation && continuation->isInline() ? toRenderInline(continuatio
n) : 0; | 3283 return continuation && continuation->isInline() ? toRenderInline(continuatio
n) : 0; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3399 | 3400 |
| 3400 LayoutUnit lastTop = 0; | 3401 LayoutUnit lastTop = 0; |
| 3401 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop); | 3402 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop); |
| 3402 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop); | 3403 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop); |
| 3403 | 3404 |
| 3404 return selectionGaps(this, offsetFromRepaintContainer, IntSize(), lastTop, l
astLeft, lastRight); | 3405 return selectionGaps(this, offsetFromRepaintContainer, IntSize(), lastTop, l
astLeft, lastRight); |
| 3405 } | 3406 } |
| 3406 | 3407 |
| 3407 void RenderBlock::paintSelection(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) | 3408 void RenderBlock::paintSelection(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) |
| 3408 { | 3409 { |
| 3409 if (shouldPaintSelectionGaps() && paintInfo.phase == PaintPhaseForeground) { | 3410 if (shouldPaintSelectionGaps() && paintInfo.getPhase() == PaintPhaseForegrou
nd) { |
| 3410 LayoutUnit lastTop = 0; | 3411 LayoutUnit lastTop = 0; |
| 3411 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop); | 3412 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop); |
| 3412 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop); | 3413 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop); |
| 3413 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 3414 GraphicsContextStateSaver stateSaver(*paintInfo.getContext()); |
| 3414 | 3415 |
| 3415 LayoutRect gapRectsBounds = selectionGaps(this, paintOffset, LayoutSize(
), lastTop, lastLeft, lastRight, &paintInfo); | 3416 LayoutRect gapRectsBounds = selectionGaps(this, paintOffset, LayoutSize(
), lastTop, lastLeft, lastRight, &paintInfo); |
| 3416 if (!gapRectsBounds.isEmpty()) { | 3417 if (!gapRectsBounds.isEmpty()) { |
| 3417 if (RenderLayer* layer = enclosingLayer()) { | 3418 if (RenderLayer* layer = enclosingLayer()) { |
| 3418 gapRectsBounds.moveBy(-paintOffset); | 3419 gapRectsBounds.moveBy(-paintOffset); |
| 3419 if (!hasLayer()) { | 3420 if (!hasLayer()) { |
| 3420 LayoutRect localBounds(gapRectsBounds); | 3421 LayoutRect localBounds(gapRectsBounds); |
| 3421 flipForWritingMode(localBounds); | 3422 flipForWritingMode(localBounds); |
| 3422 gapRectsBounds = localToContainerQuad(FloatRect(localBounds)
, layer->renderer()).enclosingBoundingBox(); | 3423 gapRectsBounds = localToContainerQuad(FloatRect(localBounds)
, layer->renderer()).enclosingBoundingBox(); |
| 3423 if (layer->renderer()->hasOverflowClip()) | 3424 if (layer->renderer()->hasOverflowClip()) |
| 3424 gapRectsBounds.move(layer->renderBox()->scrolledContentO
ffset()); | 3425 gapRectsBounds.move(layer->renderBox()->scrolledContentO
ffset()); |
| 3425 } | 3426 } |
| 3426 layer->addBlockSelectionGapsBounds(gapRectsBounds); | 3427 layer->addBlockSelectionGapsBounds(gapRectsBounds); |
| 3427 } | 3428 } |
| 3428 } | 3429 } |
| 3429 } | 3430 } |
| 3430 } | 3431 } |
| 3431 | 3432 |
| 3432 static void clipOutPositionedObjects(const PaintInfo* paintInfo, const LayoutPoi
nt& offset, TrackedRendererListHashSet* positionedObjects) | 3433 static void clipOutPositionedObjects(PaintInfo* paintInfo, const LayoutPoint& of
fset, TrackedRendererListHashSet* positionedObjects) |
| 3433 { | 3434 { |
| 3434 if (!positionedObjects) | 3435 if (!positionedObjects) |
| 3435 return; | 3436 return; |
| 3436 | 3437 |
| 3437 TrackedRendererListHashSet::const_iterator end = positionedObjects->end(); | 3438 TrackedRendererListHashSet::const_iterator end = positionedObjects->end(); |
| 3438 for (TrackedRendererListHashSet::const_iterator it = positionedObjects->begi
n(); it != end; ++it) { | 3439 for (TrackedRendererListHashSet::const_iterator it = positionedObjects->begi
n(); it != end; ++it) { |
| 3439 RenderBox* r = *it; | 3440 RenderBox* r = *it; |
| 3440 paintInfo->context->clipOut(IntRect(offset.x() + r->x(), offset.y() + r-
>y(), r->width(), r->height())); | 3441 paintInfo->getContext()->clipOut(IntRect(offset.x() + r->x(), offset.y()
+ r->y(), r->width(), r->height())); |
| 3441 } | 3442 } |
| 3442 } | 3443 } |
| 3443 | 3444 |
| 3444 static LayoutUnit blockDirectionOffset(RenderBlock* rootBlock, const LayoutSize&
offsetFromRootBlock) | 3445 static LayoutUnit blockDirectionOffset(RenderBlock* rootBlock, const LayoutSize&
offsetFromRootBlock) |
| 3445 { | 3446 { |
| 3446 return rootBlock->isHorizontalWritingMode() ? offsetFromRootBlock.height() :
offsetFromRootBlock.width(); | 3447 return rootBlock->isHorizontalWritingMode() ? offsetFromRootBlock.height() :
offsetFromRootBlock.width(); |
| 3447 } | 3448 } |
| 3448 | 3449 |
| 3449 static LayoutUnit inlineDirectionOffset(RenderBlock* rootBlock, const LayoutSize
& offsetFromRootBlock) | 3450 static LayoutUnit inlineDirectionOffset(RenderBlock* rootBlock, const LayoutSize
& offsetFromRootBlock) |
| 3450 { | 3451 { |
| 3451 return rootBlock->isHorizontalWritingMode() ? offsetFromRootBlock.width() :
offsetFromRootBlock.height(); | 3452 return rootBlock->isHorizontalWritingMode() ? offsetFromRootBlock.width() :
offsetFromRootBlock.height(); |
| 3452 } | 3453 } |
| 3453 | 3454 |
| 3454 LayoutRect RenderBlock::logicalRectToPhysicalRect(const LayoutPoint& rootBlockPh
ysicalPosition, const LayoutRect& logicalRect) | 3455 LayoutRect RenderBlock::logicalRectToPhysicalRect(const LayoutPoint& rootBlockPh
ysicalPosition, const LayoutRect& logicalRect) |
| 3455 { | 3456 { |
| 3456 LayoutRect result; | 3457 LayoutRect result; |
| 3457 if (isHorizontalWritingMode()) | 3458 if (isHorizontalWritingMode()) |
| 3458 result = logicalRect; | 3459 result = logicalRect; |
| 3459 else | 3460 else |
| 3460 result = LayoutRect(logicalRect.y(), logicalRect.x(), logicalRect.height
(), logicalRect.width()); | 3461 result = LayoutRect(logicalRect.y(), logicalRect.x(), logicalRect.height
(), logicalRect.width()); |
| 3461 flipForWritingMode(result); | 3462 flipForWritingMode(result); |
| 3462 result.moveBy(rootBlockPhysicalPosition); | 3463 result.moveBy(rootBlockPhysicalPosition); |
| 3463 return result; | 3464 return result; |
| 3464 } | 3465 } |
| 3465 | 3466 |
| 3466 GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& r
ootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | 3467 GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& r
ootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, |
| 3467 LayoutUnit& lastLogicalTop, LayoutUnit& last
LogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo) | 3468 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog
icalRight, PaintInfo* paintInfo) |
| 3468 { | 3469 { |
| 3469 // IMPORTANT: Callers of this method that intend for painting to happen need
to do a save/restore. | 3470 // IMPORTANT: Callers of this method that intend for painting to happen need
to do a save/restore. |
| 3470 // Clip out floating and positioned objects when painting selection gaps. | 3471 // Clip out floating and positioned objects when painting selection gaps. |
| 3471 if (paintInfo) { | 3472 if (paintInfo) { |
| 3472 // Note that we don't clip out overflow for positioned objects. We just
stick to the border box. | 3473 // Note that we don't clip out overflow for positioned objects. We just
stick to the border box. |
| 3473 LayoutRect flippedBlockRect(offsetFromRootBlock.width(), offsetFromRootB
lock.height(), width(), height()); | 3474 LayoutRect flippedBlockRect(offsetFromRootBlock.width(), offsetFromRootB
lock.height(), width(), height()); |
| 3474 rootBlock->flipForWritingMode(flippedBlockRect); | 3475 rootBlock->flipForWritingMode(flippedBlockRect); |
| 3475 flippedBlockRect.moveBy(rootBlockPhysicalPosition); | 3476 flippedBlockRect.moveBy(rootBlockPhysicalPosition); |
| 3476 clipOutPositionedObjects(paintInfo, flippedBlockRect.location(), positio
nedObjects()); | 3477 clipOutPositionedObjects(paintInfo, flippedBlockRect.location(), positio
nedObjects()); |
| 3477 if (isBody() || isRoot()) // The <body> must make sure to examine its co
ntainingBlock's positioned objects. | 3478 if (isBody() || isRoot()) // The <body> must make sure to examine its co
ntainingBlock's positioned objects. |
| 3478 for (RenderBlock* cb = containingBlock(); cb && !cb->isRenderView();
cb = cb->containingBlock()) | 3479 for (RenderBlock* cb = containingBlock(); cb && !cb->isRenderView();
cb = cb->containingBlock()) |
| 3479 clipOutPositionedObjects(paintInfo, LayoutPoint(cb->x(), cb->y()
), cb->positionedObjects()); // FIXME: Not right for flipped writing modes. | 3480 clipOutPositionedObjects(paintInfo, LayoutPoint(cb->x(), cb->y()
), cb->positionedObjects()); // FIXME: Not right for flipped writing modes. |
| 3480 if (FloatingObjects* floats = floatingObjects()) { | 3481 if (FloatingObjects* floats = floatingObjects()) { |
| 3481 const FloatingObjectSet& floatingObjectSet = floats->set(); | 3482 const FloatingObjectSet& floatingObjectSet = floats->set(); |
| 3482 FloatingObjectSetIterator end = floatingObjectSet.end(); | 3483 FloatingObjectSetIterator end = floatingObjectSet.end(); |
| 3483 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it !=
end; ++it) { | 3484 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it !=
end; ++it) { |
| 3484 FloatingObject* r = *it; | 3485 FloatingObject* r = *it; |
| 3485 LayoutRect floatBox(offsetFromRootBlock.width() + xPositionForFl
oatIncludingMargin(r), | 3486 LayoutRect floatBox(offsetFromRootBlock.width() + xPositionForFl
oatIncludingMargin(r), |
| 3486 offsetFromRootBlock.height() + yPositionForF
loatIncludingMargin(r), | 3487 offsetFromRootBlock.height() + yPositionForF
loatIncludingMargin(r), |
| 3487 r->m_renderer->width(), r->m_renderer->heigh
t()); | 3488 r->m_renderer->width(), r->m_renderer->heigh
t()); |
| 3488 rootBlock->flipForWritingMode(floatBox); | 3489 rootBlock->flipForWritingMode(floatBox); |
| 3489 floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPo
sition.y()); | 3490 floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPo
sition.y()); |
| 3490 paintInfo->context->clipOut(pixelSnappedIntRect(floatBox)); | 3491 paintInfo->getContext()->clipOut(pixelSnappedIntRect(floatBox)); |
| 3491 } | 3492 } |
| 3492 } | 3493 } |
| 3493 } | 3494 } |
| 3494 | 3495 |
| 3495 // FIXME: overflow: auto/scroll regions need more math here, since painting
in the border box is different from painting in the padding box (one is scrolled
, the other is | 3496 // FIXME: overflow: auto/scroll regions need more math here, since painting
in the border box is different from painting in the padding box (one is scrolled
, the other is |
| 3496 // fixed). | 3497 // fixed). |
| 3497 GapRects result; | 3498 GapRects result; |
| 3498 if (!isBlockFlow()) // FIXME: Make multi-column selection gap filling work s
omeday. | 3499 if (!isBlockFlow()) // FIXME: Make multi-column selection gap filling work s
omeday. |
| 3499 return result; | 3500 return result; |
| 3500 | 3501 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3512 result = blockSelectionGaps(rootBlock, rootBlockPhysicalPosition, offset
FromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo); | 3513 result = blockSelectionGaps(rootBlock, rootBlockPhysicalPosition, offset
FromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo); |
| 3513 | 3514 |
| 3514 // Go ahead and fill the vertical gap all the way to the bottom of our block
if the selection extends past our block. | 3515 // Go ahead and fill the vertical gap all the way to the bottom of our block
if the selection extends past our block. |
| 3515 if (rootBlock == this && (selectionState() != SelectionBoth && selectionStat
e() != SelectionEnd)) | 3516 if (rootBlock == this && (selectionState() != SelectionBoth && selectionStat
e() != SelectionEnd)) |
| 3516 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPositio
n, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, | 3517 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPositio
n, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, |
| 3517 logicalHeight(), paintInfo)); | 3518 logicalHeight(), paintInfo)); |
| 3518 return result; | 3519 return result; |
| 3519 } | 3520 } |
| 3520 | 3521 |
| 3521 GapRects RenderBlock::inlineSelectionGaps(RenderBlock* rootBlock, const LayoutPo
int& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | 3522 GapRects RenderBlock::inlineSelectionGaps(RenderBlock* rootBlock, const LayoutPo
int& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, |
| 3522 LayoutUnit& lastLogicalTop, LayoutUnit
& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo) | 3523 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog
icalRight, PaintInfo* paintInfo) |
| 3523 { | 3524 { |
| 3524 GapRects result; | 3525 GapRects result; |
| 3525 | 3526 |
| 3526 bool containsStart = selectionState() == SelectionStart || selectionState()
== SelectionBoth; | 3527 bool containsStart = selectionState() == SelectionStart || selectionState()
== SelectionBoth; |
| 3527 | 3528 |
| 3528 if (!firstLineBox()) { | 3529 if (!firstLineBox()) { |
| 3529 if (containsStart) { | 3530 if (containsStart) { |
| 3530 // Go ahead and update our lastLogicalTop to be the bottom of the bl
ock. <hr>s or empty blocks with height can trip this | 3531 // Go ahead and update our lastLogicalTop to be the bottom of the bl
ock. <hr>s or empty blocks with height can trip this |
| 3531 // case. | 3532 // case. |
| 3532 lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock
) + logicalHeight(); | 3533 lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock
) + logicalHeight(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3546 LayoutUnit selHeight = curr->selectionHeightAdjustedForPrecedingBlock(); | 3547 LayoutUnit selHeight = curr->selectionHeightAdjustedForPrecedingBlock(); |
| 3547 | 3548 |
| 3548 if (!containsStart && !lastSelectedLine && | 3549 if (!containsStart && !lastSelectedLine && |
| 3549 selectionState() != SelectionStart && selectionState() != SelectionB
oth) | 3550 selectionState() != SelectionStart && selectionState() != SelectionB
oth) |
| 3550 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPos
ition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, | 3551 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPos
ition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, |
| 3551 selTop, paintInfo)); | 3552 selTop, paintInfo)); |
| 3552 | 3553 |
| 3553 LayoutRect logicalRect(curr->logicalLeft(), selTop, curr->logicalWidth()
, selTop + selHeight); | 3554 LayoutRect logicalRect(curr->logicalLeft(), selTop, curr->logicalWidth()
, selTop + selHeight); |
| 3554 logicalRect.move(isHorizontalWritingMode() ? offsetFromRootBlock : offse
tFromRootBlock.transposedSize()); | 3555 logicalRect.move(isHorizontalWritingMode() ? offsetFromRootBlock : offse
tFromRootBlock.transposedSize()); |
| 3555 LayoutRect physicalRect = rootBlock->logicalRectToPhysicalRect(rootBlock
PhysicalPosition, logicalRect); | 3556 LayoutRect physicalRect = rootBlock->logicalRectToPhysicalRect(rootBlock
PhysicalPosition, logicalRect); |
| 3556 if (!paintInfo || (isHorizontalWritingMode() && physicalRect.y() < paint
Info->rect.maxY() && physicalRect.maxY() > paintInfo->rect.y()) | 3557 if (!paintInfo || (isHorizontalWritingMode() && physicalRect.y() < paint
Info->getRect().maxY() && physicalRect.maxY() > paintInfo->getRect().y()) |
| 3557 || (!isHorizontalWritingMode() && physicalRect.x() < paintInfo->rect
.maxX() && physicalRect.maxX() > paintInfo->rect.x())) | 3558 || (!isHorizontalWritingMode() && physicalRect.x() < paintInfo->getR
ect().maxX() && physicalRect.maxX() > paintInfo->getRect().x())) |
| 3558 result.unite(curr->lineSelectionGap(rootBlock, rootBlockPhysicalPosi
tion, offsetFromRootBlock, selTop, selHeight, paintInfo)); | 3559 result.unite(curr->lineSelectionGap(rootBlock, rootBlockPhysicalPosi
tion, offsetFromRootBlock, selTop, selHeight, paintInfo)); |
| 3559 | 3560 |
| 3560 lastSelectedLine = curr; | 3561 lastSelectedLine = curr; |
| 3561 } | 3562 } |
| 3562 | 3563 |
| 3563 if (containsStart && !lastSelectedLine) | 3564 if (containsStart && !lastSelectedLine) |
| 3564 // VisibleSelection must start just after our last line. | 3565 // VisibleSelection must start just after our last line. |
| 3565 lastSelectedLine = lastRootBox(); | 3566 lastSelectedLine = lastRootBox(); |
| 3566 | 3567 |
| 3567 if (lastSelectedLine && selectionState() != SelectionEnd && selectionState()
!= SelectionBoth) { | 3568 if (lastSelectedLine && selectionState() != SelectionEnd && selectionState()
!= SelectionBoth) { |
| 3568 // Go ahead and update our lastY to be the bottom of the last selected l
ine. | 3569 // Go ahead and update our lastY to be the bottom of the last selected l
ine. |
| 3569 lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) +
lastSelectedLine->selectionBottom(); | 3570 lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) +
lastSelectedLine->selectionBottom(); |
| 3570 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastSelectedLine
->selectionBottom()); | 3571 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastSelectedLine
->selectionBottom()); |
| 3571 lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastSelectedLi
ne->selectionBottom()); | 3572 lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastSelectedLi
ne->selectionBottom()); |
| 3572 } | 3573 } |
| 3573 return result; | 3574 return result; |
| 3574 } | 3575 } |
| 3575 | 3576 |
| 3576 GapRects RenderBlock::blockSelectionGaps(RenderBlock* rootBlock, const LayoutPoi
nt& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | 3577 GapRects RenderBlock::blockSelectionGaps(RenderBlock* rootBlock, const LayoutPoi
nt& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, |
| 3577 LayoutUnit& lastLogicalTop, LayoutUnit&
lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo) | 3578 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog
icalRight, PaintInfo* paintInfo) |
| 3578 { | 3579 { |
| 3579 GapRects result; | 3580 GapRects result; |
| 3580 | 3581 |
| 3581 // Go ahead and jump right to the first block child that contains some selec
ted objects. | 3582 // Go ahead and jump right to the first block child that contains some selec
ted objects. |
| 3582 RenderBox* curr; | 3583 RenderBox* curr; |
| 3583 for (curr = firstChildBox(); curr && curr->selectionState() == SelectionNone
; curr = curr->nextSiblingBox()) { } | 3584 for (curr = firstChildBox(); curr && curr->selectionState() == SelectionNone
; curr = curr->nextSiblingBox()) { } |
| 3584 | 3585 |
| 3585 for (bool sawSelectionEnd = false; curr && !sawSelectionEnd; curr = curr->ne
xtSiblingBox()) { | 3586 for (bool sawSelectionEnd = false; curr && !sawSelectionEnd; curr = curr->ne
xtSiblingBox()) { |
| 3586 SelectionState childState = curr->selectionState(); | 3587 SelectionState childState = curr->selectionState(); |
| 3587 if (childState == SelectionBoth || childState == SelectionEnd) | 3588 if (childState == SelectionBoth || childState == SelectionEnd) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3629 lastLogicalRight = logicalRightSelectionOffset(rootBlock, curr->logi
calBottom()); | 3630 lastLogicalRight = logicalRightSelectionOffset(rootBlock, curr->logi
calBottom()); |
| 3630 } else if (childState != SelectionNone) | 3631 } else if (childState != SelectionNone) |
| 3631 // We must be a block that has some selected object inside it. Go a
head and recur. | 3632 // We must be a block that has some selected object inside it. Go a
head and recur. |
| 3632 result.unite(toRenderBlock(curr)->selectionGaps(rootBlock, rootBlock
PhysicalPosition, LayoutSize(offsetFromRootBlock.width() + curr->x(), offsetFrom
RootBlock.height() + curr->y()), | 3633 result.unite(toRenderBlock(curr)->selectionGaps(rootBlock, rootBlock
PhysicalPosition, LayoutSize(offsetFromRootBlock.width() + curr->x(), offsetFrom
RootBlock.height() + curr->y()), |
| 3633 lastLogicalTop, last
LogicalLeft, lastLogicalRight, paintInfo)); | 3634 lastLogicalTop, last
LogicalLeft, lastLogicalRight, paintInfo)); |
| 3634 } | 3635 } |
| 3635 return result; | 3636 return result; |
| 3636 } | 3637 } |
| 3637 | 3638 |
| 3638 LayoutRect RenderBlock::blockSelectionGap(RenderBlock* rootBlock, const LayoutPo
int& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | 3639 LayoutRect RenderBlock::blockSelectionGap(RenderBlock* rootBlock, const LayoutPo
int& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, |
| 3639 LayoutUnit lastLogicalTop, LayoutUnit
lastLogicalLeft, LayoutUnit lastLogicalRight, LayoutUnit logicalBottom, const Pa
intInfo* paintInfo) | 3640 LayoutUnit lastLogicalTop, LayoutUnit lastLogicalLeft, LayoutUnit lastLogica
lRight, LayoutUnit logicalBottom, PaintInfo* paintInfo) |
| 3640 { | 3641 { |
| 3641 LayoutUnit logicalTop = lastLogicalTop; | 3642 LayoutUnit logicalTop = lastLogicalTop; |
| 3642 LayoutUnit logicalHeight = blockDirectionOffset(rootBlock, offsetFromRootBlo
ck) + logicalBottom - logicalTop; | 3643 LayoutUnit logicalHeight = blockDirectionOffset(rootBlock, offsetFromRootBlo
ck) + logicalBottom - logicalTop; |
| 3643 if (logicalHeight <= 0) | 3644 if (logicalHeight <= 0) |
| 3644 return LayoutRect(); | 3645 return LayoutRect(); |
| 3645 | 3646 |
| 3646 // Get the selection offsets for the bottom of the gap | 3647 // Get the selection offsets for the bottom of the gap |
| 3647 LayoutUnit logicalLeft = max(lastLogicalLeft, logicalLeftSelectionOffset(roo
tBlock, logicalBottom)); | 3648 LayoutUnit logicalLeft = max(lastLogicalLeft, logicalLeftSelectionOffset(roo
tBlock, logicalBottom)); |
| 3648 LayoutUnit logicalRight = min(lastLogicalRight, logicalRightSelectionOffset(
rootBlock, logicalBottom)); | 3649 LayoutUnit logicalRight = min(lastLogicalRight, logicalRightSelectionOffset(
rootBlock, logicalBottom)); |
| 3649 LayoutUnit logicalWidth = logicalRight - logicalLeft; | 3650 LayoutUnit logicalWidth = logicalRight - logicalLeft; |
| 3650 if (logicalWidth <= 0) | 3651 if (logicalWidth <= 0) |
| 3651 return LayoutRect(); | 3652 return LayoutRect(); |
| 3652 | 3653 |
| 3653 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP
osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight)); | 3654 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP
osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight)); |
| 3654 if (paintInfo) | 3655 if (paintInfo) |
| 3655 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selectionBack
groundColor()); | 3656 paintInfo->getContext()->fillRect(pixelSnappedIntRect(gapRect), selectio
nBackgroundColor()); |
| 3656 return gapRect; | 3657 return gapRect; |
| 3657 } | 3658 } |
| 3658 | 3659 |
| 3659 LayoutRect RenderBlock::logicalLeftSelectionGap(RenderBlock* rootBlock, const La
youtPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | 3660 LayoutRect RenderBlock::logicalLeftSelectionGap(RenderBlock* rootBlock, const La
youtPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, |
| 3660 RenderObject* selObj, LayoutUnit
logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo*
paintInfo) | 3661 RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutU
nit logicalHeight, PaintInfo* paintInfo) |
| 3661 { | 3662 { |
| 3662 LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromR
ootBlock) + logicalTop; | 3663 LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromR
ootBlock) + logicalTop; |
| 3663 LayoutUnit rootBlockLogicalLeft = max(logicalLeftSelectionOffset(rootBlock,
logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight)); | 3664 LayoutUnit rootBlockLogicalLeft = max(logicalLeftSelectionOffset(rootBlock,
logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight)); |
| 3664 LayoutUnit rootBlockLogicalRight = min(inlineDirectionOffset(rootBlock, offs
etFromRootBlock) + floorToInt(logicalLeft), min(logicalRightSelectionOffset(root
Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH
eight))); | 3665 LayoutUnit rootBlockLogicalRight = min(inlineDirectionOffset(rootBlock, offs
etFromRootBlock) + floorToInt(logicalLeft), min(logicalRightSelectionOffset(root
Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH
eight))); |
| 3665 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL
eft; | 3666 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL
eft; |
| 3666 if (rootBlockLogicalWidth <= 0) | 3667 if (rootBlockLogicalWidth <= 0) |
| 3667 return LayoutRect(); | 3668 return LayoutRect(); |
| 3668 | 3669 |
| 3669 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP
osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW
idth, logicalHeight)); | 3670 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP
osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW
idth, logicalHeight)); |
| 3670 if (paintInfo) | 3671 if (paintInfo) |
| 3671 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selObj->selec
tionBackgroundColor()); | 3672 paintInfo->getContext()->fillRect(pixelSnappedIntRect(gapRect), selObj->
selectionBackgroundColor()); |
| 3672 return gapRect; | 3673 return gapRect; |
| 3673 } | 3674 } |
| 3674 | 3675 |
| 3675 LayoutRect RenderBlock::logicalRightSelectionGap(RenderBlock* rootBlock, const L
ayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | 3676 LayoutRect RenderBlock::logicalRightSelectionGap(RenderBlock* rootBlock, const L
ayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, |
| 3676 RenderObject* selObj, LayoutUni
t logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo
* paintInfo) | 3677 RenderObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, Layout
Unit logicalHeight, PaintInfo* paintInfo) |
| 3677 { | 3678 { |
| 3678 LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromR
ootBlock) + logicalTop; | 3679 LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromR
ootBlock) + logicalTop; |
| 3679 LayoutUnit rootBlockLogicalLeft = max(inlineDirectionOffset(rootBlock, offse
tFromRootBlock) + floorToInt(logicalRight), max(logicalLeftSelectionOffset(rootB
lock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHei
ght))); | 3680 LayoutUnit rootBlockLogicalLeft = max(inlineDirectionOffset(rootBlock, offse
tFromRootBlock) + floorToInt(logicalRight), max(logicalLeftSelectionOffset(rootB
lock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHei
ght))); |
| 3680 LayoutUnit rootBlockLogicalRight = min(logicalRightSelectionOffset(rootBlock
, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHeight
)); | 3681 LayoutUnit rootBlockLogicalRight = min(logicalRightSelectionOffset(rootBlock
, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHeight
)); |
| 3681 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL
eft; | 3682 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL
eft; |
| 3682 if (rootBlockLogicalWidth <= 0) | 3683 if (rootBlockLogicalWidth <= 0) |
| 3683 return LayoutRect(); | 3684 return LayoutRect(); |
| 3684 | 3685 |
| 3685 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP
osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW
idth, logicalHeight)); | 3686 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP
osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW
idth, logicalHeight)); |
| 3686 if (paintInfo) | 3687 if (paintInfo) |
| 3687 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selObj->selec
tionBackgroundColor()); | 3688 paintInfo->getContext()->fillRect(pixelSnappedIntRect(gapRect), selObj->
selectionBackgroundColor()); |
| 3688 return gapRect; | 3689 return gapRect; |
| 3689 } | 3690 } |
| 3690 | 3691 |
| 3691 void RenderBlock::getSelectionGapInfo(SelectionState state, bool& leftGap, bool&
rightGap) | 3692 void RenderBlock::getSelectionGapInfo(SelectionState state, bool& leftGap, bool&
rightGap) |
| 3692 { | 3693 { |
| 3693 bool ltr = style()->isLeftToRightDirection(); | 3694 bool ltr = style()->isLeftToRightDirection(); |
| 3694 leftGap = (state == RenderObject::SelectionInside) || | 3695 leftGap = (state == RenderObject::SelectionInside) || |
| 3695 (state == RenderObject::SelectionEnd && ltr) || | 3696 (state == RenderObject::SelectionEnd && ltr) || |
| 3696 (state == RenderObject::SelectionStart && !ltr); | 3697 (state == RenderObject::SelectionStart && !ltr); |
| 3697 rightGap = (state == RenderObject::SelectionInside) || | 3698 rightGap = (state == RenderObject::SelectionInside) || |
| (...skipping 4560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8258 } | 8259 } |
| 8259 | 8260 |
| 8260 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl
oatingObject* floatingObject) | 8261 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl
oatingObject* floatingObject) |
| 8261 { | 8262 { |
| 8262 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr
ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating
Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped
MaxY()); | 8263 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr
ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating
Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped
MaxY()); |
| 8263 } | 8264 } |
| 8264 | 8265 |
| 8265 #endif | 8266 #endif |
| 8266 | 8267 |
| 8267 } // namespace WebCore | 8268 } // namespace WebCore |
| OLD | NEW |