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

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

Issue 21430003: Implement interfaces in PaintInfo and make it a class. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@getterPaintInfo01
Patch Set: Second try Created 7 years, 4 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
OLDNEW
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 2925 matching lines...) Expand 10 before | Expand all | Expand 10 after
2936 } 2936 }
2937 } 2937 }
2938 } 2938 }
2939 2939
2940 void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 2940 void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
2941 { 2941 {
2942 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); 2942 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this);
2943 2943
2944 LayoutPoint adjustedPaintOffset = paintOffset + location(); 2944 LayoutPoint adjustedPaintOffset = paintOffset + location();
2945 2945
2946 PaintPhase phase = paintInfo.phase; 2946 PaintPhase phase = paintInfo.getPhase();
2947 2947
2948 // Check if we need to do anything at all. 2948 // Check if we need to do anything at all.
2949 // FIXME: Could eliminate the isRoot() check if we fix background painting s o that the RenderView 2949 // FIXME: Could eliminate the isRoot() check if we fix background painting s o that the RenderView
2950 // paints the root's background. 2950 // paints the root's background.
2951 if (!isRoot()) { 2951 if (!isRoot()) {
2952 LayoutRect overflowBox = overflowRectForPaintRejection(); 2952 LayoutRect overflowBox = overflowRectForPaintRejection();
2953 flipForWritingMode(overflowBox); 2953 flipForWritingMode(overflowBox);
2954 overflowBox.inflate(maximalOutlineSize(paintInfo.phase)); 2954 overflowBox.inflate(maximalOutlineSize(paintInfo.getPhase()));
2955 overflowBox.moveBy(adjustedPaintOffset); 2955 overflowBox.moveBy(adjustedPaintOffset);
2956 if (!overflowBox.intersects(paintInfo.rect)) 2956 if (!overflowBox.intersects(paintInfo.getRect()))
2957 return; 2957 return;
2958 } 2958 }
2959 2959
2960 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset); 2960 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset);
2961 paintObject(paintInfo, adjustedPaintOffset); 2961 paintObject(paintInfo, adjustedPaintOffset);
2962 if (pushedClip) 2962 if (pushedClip)
2963 popContentsClip(paintInfo, phase, adjustedPaintOffset); 2963 popContentsClip(paintInfo, phase, adjustedPaintOffset);
2964 2964
2965 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with 2965 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with
2966 // z-index. We paint after we painted the background/border, so that the sc rollbars will 2966 // z-index. We paint after we painted the background/border, so that the sc rollbars will
2967 // sit above the background/border. 2967 // sit above the background/border.
2968 if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == Paint PhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.sh ouldPaintWithinRoot(this) && !paintInfo.paintRootBackgroundOnly()) 2968 if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == Paint PhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.sh ouldPaintWithinRoot(this) && !paintInfo.paintRootBackgroundOnly())
2969 layer()->paintOverflowControls(paintInfo.context, roundedIntPoint(adjust edPaintOffset), paintInfo.rect); 2969 layer()->paintOverflowControls(paintInfo.getContext(), roundedIntPoint(a djustedPaintOffset), paintInfo.getRect());
2970 } 2970 }
2971 2971
2972 void RenderBlock::paintColumnRules(PaintInfo& paintInfo, const LayoutPoint& pain tOffset) 2972 void RenderBlock::paintColumnRules(PaintInfo& paintInfo, const LayoutPoint& pain tOffset)
2973 { 2973 {
2974 if (paintInfo.context->paintingDisabled()) 2974 if (paintInfo.getContext()->paintingDisabled())
2975 return; 2975 return;
2976 2976
2977 const Color& ruleColor = resolveColor(CSSPropertyWebkitColumnRuleColor); 2977 const Color& ruleColor = resolveColor(CSSPropertyWebkitColumnRuleColor);
2978 bool ruleTransparent = style()->columnRuleIsTransparent(); 2978 bool ruleTransparent = style()->columnRuleIsTransparent();
2979 EBorderStyle ruleStyle = style()->columnRuleStyle(); 2979 EBorderStyle ruleStyle = style()->columnRuleStyle();
2980 LayoutUnit ruleThickness = style()->columnRuleWidth(); 2980 LayoutUnit ruleThickness = style()->columnRuleWidth();
2981 LayoutUnit colGap = columnGap(); 2981 LayoutUnit colGap = columnGap();
2982 bool renderRule = ruleStyle > BHIDDEN && !ruleTransparent; 2982 bool renderRule = ruleStyle > BHIDDEN && !ruleTransparent;
2983 if (!renderRule) 2983 if (!renderRule)
2984 return; 2984 return;
2985 2985
2986 ColumnInfo* colInfo = columnInfo(); 2986 ColumnInfo* colInfo = columnInfo();
2987 unsigned colCount = columnCount(colInfo); 2987 unsigned colCount = columnCount(colInfo);
2988 2988
2989 bool antialias = shouldAntialiasLines(paintInfo.context); 2989 bool antialias = shouldAntialiasLines(paintInfo.getContext());
2990 2990
2991 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) { 2991 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) {
2992 bool leftToRight = style()->isLeftToRightDirection() ^ colInfo->progress ionIsReversed(); 2992 bool leftToRight = style()->isLeftToRightDirection() ^ colInfo->progress ionIsReversed();
2993 LayoutUnit currLogicalLeftOffset = leftToRight ? LayoutUnit() : contentL ogicalWidth(); 2993 LayoutUnit currLogicalLeftOffset = leftToRight ? LayoutUnit() : contentL ogicalWidth();
2994 LayoutUnit ruleAdd = logicalLeftOffsetForContent(); 2994 LayoutUnit ruleAdd = logicalLeftOffsetForContent();
2995 LayoutUnit ruleLogicalLeft = leftToRight ? LayoutUnit() : contentLogical Width(); 2995 LayoutUnit ruleLogicalLeft = leftToRight ? LayoutUnit() : contentLogical Width();
2996 LayoutUnit inlineDirectionSize = colInfo->desiredColumnWidth(); 2996 LayoutUnit inlineDirectionSize = colInfo->desiredColumnWidth();
2997 BoxSide boxSide = isHorizontalWritingMode() 2997 BoxSide boxSide = isHorizontalWritingMode()
2998 ? leftToRight ? BSLeft : BSRight 2998 ? leftToRight ? BSLeft : BSRight
2999 : leftToRight ? BSTop : BSBottom; 2999 : leftToRight ? BSTop : BSBottom;
3000 3000
3001 for (unsigned i = 0; i < colCount; i++) { 3001 for (unsigned i = 0; i < colCount; i++) {
3002 // Move to the next position. 3002 // Move to the next position.
3003 if (leftToRight) { 3003 if (leftToRight) {
3004 ruleLogicalLeft += inlineDirectionSize + colGap / 2; 3004 ruleLogicalLeft += inlineDirectionSize + colGap / 2;
3005 currLogicalLeftOffset += inlineDirectionSize + colGap; 3005 currLogicalLeftOffset += inlineDirectionSize + colGap;
3006 } else { 3006 } else {
3007 ruleLogicalLeft -= (inlineDirectionSize + colGap / 2); 3007 ruleLogicalLeft -= (inlineDirectionSize + colGap / 2);
3008 currLogicalLeftOffset -= (inlineDirectionSize + colGap); 3008 currLogicalLeftOffset -= (inlineDirectionSize + colGap);
3009 } 3009 }
3010 3010
3011 // Now paint the column rule. 3011 // Now paint the column rule.
3012 if (i < colCount - 1) { 3012 if (i < colCount - 1) {
3013 LayoutUnit ruleLeft = isHorizontalWritingMode() ? paintOffset.x( ) + ruleLogicalLeft - ruleThickness / 2 + ruleAdd : paintOffset.x() + borderLeft () + paddingLeft(); 3013 LayoutUnit ruleLeft = isHorizontalWritingMode() ? paintOffset.x( ) + ruleLogicalLeft - ruleThickness / 2 + ruleAdd : paintOffset.x() + borderLeft () + paddingLeft();
3014 LayoutUnit ruleRight = isHorizontalWritingMode() ? ruleLeft + ru leThickness : ruleLeft + contentWidth(); 3014 LayoutUnit ruleRight = isHorizontalWritingMode() ? ruleLeft + ru leThickness : ruleLeft + contentWidth();
3015 LayoutUnit ruleTop = isHorizontalWritingMode() ? paintOffset.y() + borderTop() + paddingTop() : paintOffset.y() + ruleLogicalLeft - ruleThicknes s / 2 + ruleAdd; 3015 LayoutUnit ruleTop = isHorizontalWritingMode() ? paintOffset.y() + borderTop() + paddingTop() : paintOffset.y() + ruleLogicalLeft - ruleThicknes s / 2 + ruleAdd;
3016 LayoutUnit ruleBottom = isHorizontalWritingMode() ? ruleTop + co ntentHeight() : ruleTop + ruleThickness; 3016 LayoutUnit ruleBottom = isHorizontalWritingMode() ? ruleTop + co ntentHeight() : ruleTop + ruleThickness;
3017 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(rule Left, ruleTop, ruleRight, ruleBottom); 3017 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(rule Left, ruleTop, ruleRight, ruleBottom);
3018 drawLineForBoxSide(paintInfo.context, pixelSnappedRuleRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.maxY (), boxSide, ruleColor, ruleStyle, 0, 0, antialias); 3018 drawLineForBoxSide(paintInfo.getContext(), pixelSnappedRuleRect. x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect .maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias);
3019 } 3019 }
3020 3020
3021 ruleLogicalLeft = currLogicalLeftOffset; 3021 ruleLogicalLeft = currLogicalLeftOffset;
3022 } 3022 }
3023 } else { 3023 } else {
3024 bool topToBottom = !style()->isFlippedBlocksWritingMode() ^ colInfo->pro gressionIsReversed(); 3024 bool topToBottom = !style()->isFlippedBlocksWritingMode() ^ colInfo->pro gressionIsReversed();
3025 LayoutUnit ruleLeft = isHorizontalWritingMode() 3025 LayoutUnit ruleLeft = isHorizontalWritingMode()
3026 ? borderLeft() + paddingLeft() 3026 ? borderLeft() + paddingLeft()
3027 : colGap / 2 - colGap - ruleThickness / 2 + (!colInfo->progressionIs Reversed() ? borderBefore() + paddingBefore() : borderAfter() + paddingAfter()); 3027 : colGap / 2 - colGap - ruleThickness / 2 + (!colInfo->progressionIs Reversed() ? borderBefore() + paddingBefore() : borderAfter() + paddingAfter());
3028 LayoutUnit ruleWidth = isHorizontalWritingMode() ? contentWidth() : rule Thickness; 3028 LayoutUnit ruleWidth = isHorizontalWritingMode() ? contentWidth() : rule Thickness;
(...skipping 16 matching lines...) Expand all
3045 ? topToBottom ? BSTop : BSBottom 3045 ? topToBottom ? BSTop : BSBottom
3046 : topToBottom ? BSLeft : BSRight; 3046 : topToBottom ? BSLeft : BSRight;
3047 3047
3048 LayoutSize step(0, topToBottom ? colInfo->columnHeight() + colGap : -(co lInfo->columnHeight() + colGap)); 3048 LayoutSize step(0, topToBottom ? colInfo->columnHeight() + colGap : -(co lInfo->columnHeight() + colGap));
3049 if (!isHorizontalWritingMode()) 3049 if (!isHorizontalWritingMode())
3050 step = step.transposedSize(); 3050 step = step.transposedSize();
3051 3051
3052 for (unsigned i = 1; i < colCount; i++) { 3052 for (unsigned i = 1; i < colCount; i++) {
3053 ruleRect.move(step); 3053 ruleRect.move(step);
3054 IntRect pixelSnappedRuleRect = pixelSnappedIntRect(ruleRect); 3054 IntRect pixelSnappedRuleRect = pixelSnappedIntRect(ruleRect);
3055 drawLineForBoxSide(paintInfo.context, pixelSnappedRuleRect.x(), pixe lSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); 3055 drawLineForBoxSide(paintInfo.getContext(), pixelSnappedRuleRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.max Y(), boxSide, ruleColor, ruleStyle, 0, 0, antialias);
3056 } 3056 }
3057 } 3057 }
3058 } 3058 }
3059 3059
3060 void RenderBlock::paintColumnContents(PaintInfo& paintInfo, const LayoutPoint& p aintOffset, bool paintingFloats) 3060 void RenderBlock::paintColumnContents(PaintInfo& paintInfo, const LayoutPoint& p aintOffset, bool paintingFloats)
3061 { 3061 {
3062 // We need to do multiple passes, breaking up our child painting into strips . 3062 // We need to do multiple passes, breaking up our child painting into strips .
3063 GraphicsContext* context = paintInfo.context; 3063 GraphicsContext* context = paintInfo.getContext();
3064 ColumnInfo* colInfo = columnInfo(); 3064 ColumnInfo* colInfo = columnInfo();
3065 unsigned colCount = columnCount(colInfo); 3065 unsigned colCount = columnCount(colInfo);
3066 if (!colCount) 3066 if (!colCount)
3067 return; 3067 return;
3068 LayoutUnit currLogicalTopOffset = 0; 3068 LayoutUnit currLogicalTopOffset = 0;
3069 LayoutUnit colGap = columnGap(); 3069 LayoutUnit colGap = columnGap();
3070 for (unsigned i = 0; i < colCount; i++) { 3070 for (unsigned i = 0; i < colCount; i++) {
3071 // For each rect, we clip to the rect, and then we adjust our coords. 3071 // For each rect, we clip to the rect, and then we adjust our coords.
3072 LayoutRect colRect = columnRectAt(colInfo, i); 3072 LayoutRect colRect = columnRectAt(colInfo, i);
3073 flipForWritingMode(colRect); 3073 flipForWritingMode(colRect);
3074 LayoutUnit logicalLeftOffset = (isHorizontalWritingMode() ? colRect.x() : colRect.y()) - logicalLeftOffsetForContent(); 3074 LayoutUnit logicalLeftOffset = (isHorizontalWritingMode() ? colRect.x() : colRect.y()) - logicalLeftOffsetForContent();
3075 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(logicalLeftOf fset, currLogicalTopOffset) : LayoutSize(currLogicalTopOffset, logicalLeftOffset ); 3075 LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(logicalLeftOf fset, currLogicalTopOffset) : LayoutSize(currLogicalTopOffset, logicalLeftOffset );
3076 if (colInfo->progressionAxis() == ColumnInfo::BlockAxis) { 3076 if (colInfo->progressionAxis() == ColumnInfo::BlockAxis) {
3077 if (isHorizontalWritingMode()) 3077 if (isHorizontalWritingMode())
3078 offset.expand(0, colRect.y() - borderTop() - paddingTop()); 3078 offset.expand(0, colRect.y() - borderTop() - paddingTop());
3079 else 3079 else
3080 offset.expand(colRect.x() - borderLeft() - paddingLeft(), 0); 3080 offset.expand(colRect.x() - borderLeft() - paddingLeft(), 0);
3081 } 3081 }
3082 colRect.moveBy(paintOffset); 3082 colRect.moveBy(paintOffset);
3083 PaintInfo info(paintInfo); 3083 PaintInfo info(paintInfo);
3084 info.rect.intersect(pixelSnappedIntRect(colRect)); 3084 info.getRect().intersect(pixelSnappedIntRect(colRect));
3085 3085
3086 if (!info.rect.isEmpty()) { 3086 if (!info.getRect().isEmpty()) {
3087 GraphicsContextStateSaver stateSaver(*context); 3087 GraphicsContextStateSaver stateSaver(*context);
3088 LayoutRect clipRect(colRect); 3088 LayoutRect clipRect(colRect);
3089 3089
3090 if (i < colCount - 1) { 3090 if (i < colCount - 1) {
3091 if (isHorizontalWritingMode()) 3091 if (isHorizontalWritingMode())
3092 clipRect.expand(colGap / 2, 0); 3092 clipRect.expand(colGap / 2, 0);
3093 else 3093 else
3094 clipRect.expand(0, colGap / 2); 3094 clipRect.expand(0, colGap / 2);
3095 } 3095 }
3096 // Each strip pushes a clip, since column boxes are specified as bei ng 3096 // Each strip pushes a clip, since column boxes are specified as bei ng
3097 // like overflow:hidden. 3097 // like overflow:hidden.
3098 // FIXME: Content and column rules that extend outside column boxes at the edges of the multi-column element 3098 // FIXME: Content and column rules that extend outside column boxes at the edges of the multi-column element
3099 // are clipped according to the 'overflow' property. 3099 // are clipped according to the 'overflow' property.
3100 context->clip(pixelSnappedIntRect(clipRect)); 3100 context->clip(pixelSnappedIntRect(clipRect));
3101 3101
3102 // Adjust our x and y when painting. 3102 // Adjust our x and y when painting.
3103 LayoutPoint adjustedPaintOffset = paintOffset + offset; 3103 LayoutPoint adjustedPaintOffset = paintOffset + offset;
3104 if (paintingFloats) 3104 if (paintingFloats)
3105 paintFloats(info, adjustedPaintOffset, paintInfo.phase == PaintP haseSelection || paintInfo.phase == PaintPhaseTextClip); 3105 paintFloats(info, adjustedPaintOffset, paintInfo.getPhase() == P aintPhaseSelection || paintInfo.getPhase() == PaintPhaseTextClip);
3106 else 3106 else
3107 paintContents(info, adjustedPaintOffset); 3107 paintContents(info, adjustedPaintOffset);
3108 } 3108 }
3109 3109
3110 LayoutUnit blockDelta = (isHorizontalWritingMode() ? colRect.height() : colRect.width()); 3110 LayoutUnit blockDelta = (isHorizontalWritingMode() ? colRect.height() : colRect.width());
3111 if (style()->isFlippedBlocksWritingMode()) 3111 if (style()->isFlippedBlocksWritingMode())
3112 currLogicalTopOffset += blockDelta; 3112 currLogicalTopOffset += blockDelta;
3113 else 3113 else
3114 currLogicalTopOffset -= blockDelta; 3114 currLogicalTopOffset -= blockDelta;
3115 } 3115 }
3116 } 3116 }
3117 3117
3118 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) 3118 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
3119 { 3119 {
3120 // Avoid painting descendants of the root element when stylesheets haven't l oaded. This eliminates FOUC. 3120 // Avoid painting descendants of the root element when stylesheets haven't l oaded. This eliminates FOUC.
3121 // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document 3121 // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document
3122 // will do a full repaint. 3122 // will do a full repaint.
3123 if (document()->didLayoutWithPendingStylesheets() && !isRenderView()) 3123 if (document()->didLayoutWithPendingStylesheets() && !isRenderView())
3124 return; 3124 return;
3125 3125
3126 if (childrenInline()) 3126 if (childrenInline())
3127 m_lineBoxes.paint(this, paintInfo, paintOffset); 3127 m_lineBoxes.paint(this, paintInfo, paintOffset);
3128 else { 3128 else {
3129 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? Pai ntPhaseOutline : paintInfo.phase; 3129 PaintPhase newPhase = (paintInfo.getPhase() == PaintPhaseChildOutlines) ? PaintPhaseOutline : paintInfo.getPhase();
3130 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi ldBlockBackground : newPhase; 3130 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi ldBlockBackground : newPhase;
3131 3131
3132 // We don't paint our own background, but we do let the kids paint their backgrounds. 3132 // We don't paint our own background, but we do let the kids paint their backgrounds.
3133 PaintInfo paintInfoForChild(paintInfo); 3133 PaintInfo paintInfoForChild(paintInfo);
3134 paintInfoForChild.phase = newPhase; 3134 paintInfoForChild.setPhase(newPhase);
3135 paintInfoForChild.updatePaintingRootForChildren(this); 3135 paintInfoForChild.updatePaintingRootForChildren(this);
3136 paintChildren(paintInfoForChild, paintOffset); 3136 paintChildren(paintInfoForChild, paintOffset);
3137 } 3137 }
3138 } 3138 }
3139 3139
3140 void RenderBlock::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) 3140 void RenderBlock::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
3141 { 3141 {
3142 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) 3142 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x())
3143 paintChild(child, paintInfo, paintOffset); 3143 paintChild(child, paintInfo, paintOffset);
3144 } 3144 }
(...skipping 15 matching lines...) Expand all
3160 if (type == CursorCaret) { 3160 if (type == CursorCaret) {
3161 caretPainter = frame()->selection()->caretRenderer(); 3161 caretPainter = frame()->selection()->caretRenderer();
3162 isContentEditable = frame()->selection()->rendererIsEditable(); 3162 isContentEditable = frame()->selection()->rendererIsEditable();
3163 } else { 3163 } else {
3164 caretPainter = frame()->page()->dragCaretController()->caretRenderer(); 3164 caretPainter = frame()->page()->dragCaretController()->caretRenderer();
3165 isContentEditable = frame()->page()->dragCaretController()->isContentEdi table(); 3165 isContentEditable = frame()->page()->dragCaretController()->isContentEdi table();
3166 } 3166 }
3167 3167
3168 if (caretPainter == this && (isContentEditable || caretBrowsing)) { 3168 if (caretPainter == this && (isContentEditable || caretBrowsing)) {
3169 if (type == CursorCaret) 3169 if (type == CursorCaret)
3170 frame()->selection()->paintCaret(paintInfo.context, paintOffset, pai ntInfo.rect); 3170 frame()->selection()->paintCaret(paintInfo.getContext(), paintOffset , paintInfo.getRect());
3171 else 3171 else
3172 frame()->page()->dragCaretController()->paintDragCaret(frame(), pain tInfo.context, paintOffset, paintInfo.rect); 3172 frame()->page()->dragCaretController()->paintDragCaret(frame(), pain tInfo.getContext(), paintOffset, paintInfo.getRect());
3173 } 3173 }
3174 } 3174 }
3175 3175
3176 void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs et) 3176 void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs et)
3177 { 3177 {
3178 PaintPhase paintPhase = paintInfo.phase; 3178 PaintPhase paintPhase = paintInfo.getPhase();
3179 3179
3180 // 1. paint background, borders etc 3180 // 1. paint background, borders etc
3181 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil dBlockBackground) && style()->visibility() == VISIBLE) { 3181 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil dBlockBackground) && style()->visibility() == VISIBLE) {
3182 if (hasBoxDecorations()) 3182 if (hasBoxDecorations())
3183 paintBoxDecorations(paintInfo, paintOffset); 3183 paintBoxDecorations(paintInfo, paintOffset);
3184 if (hasColumns() && !paintInfo.paintRootBackgroundOnly()) 3184 if (hasColumns() && !paintInfo.paintRootBackgroundOnly())
3185 paintColumnRules(paintInfo, paintOffset); 3185 paintColumnRules(paintInfo, paintOffset);
3186 } 3186 }
3187 3187
3188 if (paintPhase == PaintPhaseMask && style()->visibility() == VISIBLE) { 3188 if (paintPhase == PaintPhaseMask && style()->visibility() == VISIBLE) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3279 if (!floats) 3279 if (!floats)
3280 return; 3280 return;
3281 3281
3282 const FloatingObjectSet& floatingObjectSet = floats->set(); 3282 const FloatingObjectSet& floatingObjectSet = floats->set();
3283 FloatingObjectSetIterator end = floatingObjectSet.end(); 3283 FloatingObjectSetIterator end = floatingObjectSet.end();
3284 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { 3284 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) {
3285 FloatingObject* r = *it; 3285 FloatingObject* r = *it;
3286 // Only paint the object if our m_shouldPaint flag is set. 3286 // Only paint the object if our m_shouldPaint flag is set.
3287 if (r->shouldPaint() && !r->m_renderer->hasSelfPaintingLayer()) { 3287 if (r->shouldPaint() && !r->m_renderer->hasSelfPaintingLayer()) {
3288 PaintInfo currentPaintInfo(paintInfo); 3288 PaintInfo currentPaintInfo(paintInfo);
3289 currentPaintInfo.phase = preservePhase ? paintInfo.phase : PaintPhas eBlockBackground; 3289 PaintPhase phase = preservePhase ? paintInfo.getPhase() : PaintPhase BlockBackground;
3290 currentPaintInfo.setPhase(phase);
3290 LayoutPoint childPoint = flipFloatForWritingModeForChild(r, LayoutPo int(paintOffset.x() + xPositionForFloatIncludingMargin(r) - r->m_renderer->x(), paintOffset.y() + yPositionForFloatIncludingMargin(r) - r->m_renderer->y())); 3291 LayoutPoint childPoint = flipFloatForWritingModeForChild(r, LayoutPo int(paintOffset.x() + xPositionForFloatIncludingMargin(r) - r->m_renderer->x(), paintOffset.y() + yPositionForFloatIncludingMargin(r) - r->m_renderer->y()));
3291 r->m_renderer->paint(currentPaintInfo, childPoint); 3292 r->m_renderer->paint(currentPaintInfo, childPoint);
3292 if (!preservePhase) { 3293 if (!preservePhase) {
3293 currentPaintInfo.phase = PaintPhaseChildBlockBackgrounds; 3294 currentPaintInfo.setPhase(PaintPhaseChildBlockBackgrounds);
3294 r->m_renderer->paint(currentPaintInfo, childPoint); 3295 r->m_renderer->paint(currentPaintInfo, childPoint);
3295 currentPaintInfo.phase = PaintPhaseFloat; 3296 currentPaintInfo.setPhase(PaintPhaseFloat);
3296 r->m_renderer->paint(currentPaintInfo, childPoint); 3297 r->m_renderer->paint(currentPaintInfo, childPoint);
3297 currentPaintInfo.phase = PaintPhaseForeground; 3298 currentPaintInfo.setPhase(PaintPhaseForeground);
3298 r->m_renderer->paint(currentPaintInfo, childPoint); 3299 r->m_renderer->paint(currentPaintInfo, childPoint);
3299 currentPaintInfo.phase = PaintPhaseOutline; 3300 currentPaintInfo.setPhase(PaintPhaseOutline);
3300 r->m_renderer->paint(currentPaintInfo, childPoint); 3301 r->m_renderer->paint(currentPaintInfo, childPoint);
3301 } 3302 }
3302 } 3303 }
3303 } 3304 }
3304 } 3305 }
3305 3306
3306 RenderInline* RenderBlock::inlineElementContinuation() const 3307 RenderInline* RenderBlock::inlineElementContinuation() const
3307 { 3308 {
3308 RenderBoxModelObject* continuation = this->continuation(); 3309 RenderBoxModelObject* continuation = this->continuation();
3309 return continuation && continuation->isInline() ? toRenderInline(continuatio n) : 0; 3310 return continuation && continuation->isInline() ? toRenderInline(continuatio n) : 0;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3426 3427
3427 LayoutUnit lastTop = 0; 3428 LayoutUnit lastTop = 0;
3428 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop); 3429 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop);
3429 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop); 3430 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop);
3430 3431
3431 return selectionGaps(this, offsetFromRepaintContainer, IntSize(), lastTop, l astLeft, lastRight); 3432 return selectionGaps(this, offsetFromRepaintContainer, IntSize(), lastTop, l astLeft, lastRight);
3432 } 3433 }
3433 3434
3434 void RenderBlock::paintSelection(PaintInfo& paintInfo, const LayoutPoint& paintO ffset) 3435 void RenderBlock::paintSelection(PaintInfo& paintInfo, const LayoutPoint& paintO ffset)
3435 { 3436 {
3436 if (shouldPaintSelectionGaps() && paintInfo.phase == PaintPhaseForeground) { 3437 if (shouldPaintSelectionGaps() && paintInfo.getPhase() == PaintPhaseForegrou nd) {
3437 LayoutUnit lastTop = 0; 3438 LayoutUnit lastTop = 0;
3438 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop); 3439 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop);
3439 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop); 3440 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop);
3440 GraphicsContextStateSaver stateSaver(*paintInfo.context); 3441 GraphicsContextStateSaver stateSaver(*paintInfo.getContext());
3441 3442
3442 LayoutRect gapRectsBounds = selectionGaps(this, paintOffset, LayoutSize( ), lastTop, lastLeft, lastRight, &paintInfo); 3443 LayoutRect gapRectsBounds = selectionGaps(this, paintOffset, LayoutSize( ), lastTop, lastLeft, lastRight, &paintInfo);
3443 if (!gapRectsBounds.isEmpty()) { 3444 if (!gapRectsBounds.isEmpty()) {
3444 if (RenderLayer* layer = enclosingLayer()) { 3445 if (RenderLayer* layer = enclosingLayer()) {
3445 gapRectsBounds.moveBy(-paintOffset); 3446 gapRectsBounds.moveBy(-paintOffset);
3446 if (!hasLayer()) { 3447 if (!hasLayer()) {
3447 LayoutRect localBounds(gapRectsBounds); 3448 LayoutRect localBounds(gapRectsBounds);
3448 flipForWritingMode(localBounds); 3449 flipForWritingMode(localBounds);
3449 gapRectsBounds = localToContainerQuad(FloatRect(localBounds) , layer->renderer()).enclosingBoundingBox(); 3450 gapRectsBounds = localToContainerQuad(FloatRect(localBounds) , layer->renderer()).enclosingBoundingBox();
3450 if (layer->renderer()->hasOverflowClip()) 3451 if (layer->renderer()->hasOverflowClip())
3451 gapRectsBounds.move(layer->renderBox()->scrolledContentO ffset()); 3452 gapRectsBounds.move(layer->renderBox()->scrolledContentO ffset());
3452 } 3453 }
3453 layer->addBlockSelectionGapsBounds(gapRectsBounds); 3454 layer->addBlockSelectionGapsBounds(gapRectsBounds);
3454 } 3455 }
3455 } 3456 }
3456 } 3457 }
3457 } 3458 }
3458 3459
3459 static void clipOutPositionedObjects(const PaintInfo* paintInfo, const LayoutPoi nt& offset, TrackedRendererListHashSet* positionedObjects) 3460 static void clipOutPositionedObjects(PaintInfo* paintInfo, const LayoutPoint& of fset, TrackedRendererListHashSet* positionedObjects)
3460 { 3461 {
3461 if (!positionedObjects) 3462 if (!positionedObjects)
3462 return; 3463 return;
3463 3464
3464 TrackedRendererListHashSet::const_iterator end = positionedObjects->end(); 3465 TrackedRendererListHashSet::const_iterator end = positionedObjects->end();
3465 for (TrackedRendererListHashSet::const_iterator it = positionedObjects->begi n(); it != end; ++it) { 3466 for (TrackedRendererListHashSet::const_iterator it = positionedObjects->begi n(); it != end; ++it) {
3466 RenderBox* r = *it; 3467 RenderBox* r = *it;
3467 paintInfo->context->clipOut(IntRect(offset.x() + r->x(), offset.y() + r- >y(), r->width(), r->height())); 3468 paintInfo->getContext()->clipOut(IntRect(offset.x() + r->x(), offset.y() + r->y(), r->width(), r->height()));
3468 } 3469 }
3469 } 3470 }
3470 3471
3471 static LayoutUnit blockDirectionOffset(RenderBlock* rootBlock, const LayoutSize& offsetFromRootBlock) 3472 static LayoutUnit blockDirectionOffset(RenderBlock* rootBlock, const LayoutSize& offsetFromRootBlock)
3472 { 3473 {
3473 return rootBlock->isHorizontalWritingMode() ? offsetFromRootBlock.height() : offsetFromRootBlock.width(); 3474 return rootBlock->isHorizontalWritingMode() ? offsetFromRootBlock.height() : offsetFromRootBlock.width();
3474 } 3475 }
3475 3476
3476 static LayoutUnit inlineDirectionOffset(RenderBlock* rootBlock, const LayoutSize & offsetFromRootBlock) 3477 static LayoutUnit inlineDirectionOffset(RenderBlock* rootBlock, const LayoutSize & offsetFromRootBlock)
3477 { 3478 {
3478 return rootBlock->isHorizontalWritingMode() ? offsetFromRootBlock.width() : offsetFromRootBlock.height(); 3479 return rootBlock->isHorizontalWritingMode() ? offsetFromRootBlock.width() : offsetFromRootBlock.height();
3479 } 3480 }
3480 3481
3481 LayoutRect RenderBlock::logicalRectToPhysicalRect(const LayoutPoint& rootBlockPh ysicalPosition, const LayoutRect& logicalRect) 3482 LayoutRect RenderBlock::logicalRectToPhysicalRect(const LayoutPoint& rootBlockPh ysicalPosition, const LayoutRect& logicalRect)
3482 { 3483 {
3483 LayoutRect result; 3484 LayoutRect result;
3484 if (isHorizontalWritingMode()) 3485 if (isHorizontalWritingMode())
3485 result = logicalRect; 3486 result = logicalRect;
3486 else 3487 else
3487 result = LayoutRect(logicalRect.y(), logicalRect.x(), logicalRect.height (), logicalRect.width()); 3488 result = LayoutRect(logicalRect.y(), logicalRect.x(), logicalRect.height (), logicalRect.width());
3488 flipForWritingMode(result); 3489 flipForWritingMode(result);
3489 result.moveBy(rootBlockPhysicalPosition); 3490 result.moveBy(rootBlockPhysicalPosition);
3490 return result; 3491 return result;
3491 } 3492 }
3492 3493
3493 GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& r ootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 3494 GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& r ootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
3494 LayoutUnit& lastLogicalTop, LayoutUnit& last LogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo) 3495 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, PaintInfo* paintInfo)
3495 { 3496 {
3496 // IMPORTANT: Callers of this method that intend for painting to happen need to do a save/restore. 3497 // IMPORTANT: Callers of this method that intend for painting to happen need to do a save/restore.
3497 // Clip out floating and positioned objects when painting selection gaps. 3498 // Clip out floating and positioned objects when painting selection gaps.
3498 if (paintInfo) { 3499 if (paintInfo) {
3499 // Note that we don't clip out overflow for positioned objects. We just stick to the border box. 3500 // Note that we don't clip out overflow for positioned objects. We just stick to the border box.
3500 LayoutRect flippedBlockRect(offsetFromRootBlock.width(), offsetFromRootB lock.height(), width(), height()); 3501 LayoutRect flippedBlockRect(offsetFromRootBlock.width(), offsetFromRootB lock.height(), width(), height());
3501 rootBlock->flipForWritingMode(flippedBlockRect); 3502 rootBlock->flipForWritingMode(flippedBlockRect);
3502 flippedBlockRect.moveBy(rootBlockPhysicalPosition); 3503 flippedBlockRect.moveBy(rootBlockPhysicalPosition);
3503 clipOutPositionedObjects(paintInfo, flippedBlockRect.location(), positio nedObjects()); 3504 clipOutPositionedObjects(paintInfo, flippedBlockRect.location(), positio nedObjects());
3504 if (isBody() || isRoot()) // The <body> must make sure to examine its co ntainingBlock's positioned objects. 3505 if (isBody() || isRoot()) // The <body> must make sure to examine its co ntainingBlock's positioned objects.
3505 for (RenderBlock* cb = containingBlock(); cb && !cb->isRenderView(); cb = cb->containingBlock()) 3506 for (RenderBlock* cb = containingBlock(); cb && !cb->isRenderView(); cb = cb->containingBlock())
3506 clipOutPositionedObjects(paintInfo, LayoutPoint(cb->x(), cb->y() ), cb->positionedObjects()); // FIXME: Not right for flipped writing modes. 3507 clipOutPositionedObjects(paintInfo, LayoutPoint(cb->x(), cb->y() ), cb->positionedObjects()); // FIXME: Not right for flipped writing modes.
3507 if (FloatingObjects* floats = floatingObjects()) { 3508 if (FloatingObjects* floats = floatingObjects()) {
3508 const FloatingObjectSet& floatingObjectSet = floats->set(); 3509 const FloatingObjectSet& floatingObjectSet = floats->set();
3509 FloatingObjectSetIterator end = floatingObjectSet.end(); 3510 FloatingObjectSetIterator end = floatingObjectSet.end();
3510 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { 3511 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
3511 FloatingObject* r = *it; 3512 FloatingObject* r = *it;
3512 LayoutRect floatBox(offsetFromRootBlock.width() + xPositionForFl oatIncludingMargin(r), 3513 LayoutRect floatBox(offsetFromRootBlock.width() + xPositionForFl oatIncludingMargin(r),
3513 offsetFromRootBlock.height() + yPositionForF loatIncludingMargin(r), 3514 offsetFromRootBlock.height() + yPositionForF loatIncludingMargin(r),
3514 r->m_renderer->width(), r->m_renderer->heigh t()); 3515 r->m_renderer->width(), r->m_renderer->heigh t());
3515 rootBlock->flipForWritingMode(floatBox); 3516 rootBlock->flipForWritingMode(floatBox);
3516 floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPo sition.y()); 3517 floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPo sition.y());
3517 paintInfo->context->clipOut(pixelSnappedIntRect(floatBox)); 3518 paintInfo->getContext()->clipOut(pixelSnappedIntRect(floatBox));
3518 } 3519 }
3519 } 3520 }
3520 } 3521 }
3521 3522
3522 // 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 3523 // 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
3523 // fixed). 3524 // fixed).
3524 GapRects result; 3525 GapRects result;
3525 if (!isBlockFlow()) // FIXME: Make multi-column selection gap filling work s omeday. 3526 if (!isBlockFlow()) // FIXME: Make multi-column selection gap filling work s omeday.
3526 return result; 3527 return result;
3527 3528
(...skipping 11 matching lines...) Expand all
3539 result = blockSelectionGaps(rootBlock, rootBlockPhysicalPosition, offset FromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo); 3540 result = blockSelectionGaps(rootBlock, rootBlockPhysicalPosition, offset FromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo);
3540 3541
3541 // Go ahead and fill the vertical gap all the way to the bottom of our block if the selection extends past our block. 3542 // Go ahead and fill the vertical gap all the way to the bottom of our block if the selection extends past our block.
3542 if (rootBlock == this && (selectionState() != SelectionBoth && selectionStat e() != SelectionEnd)) 3543 if (rootBlock == this && (selectionState() != SelectionBoth && selectionStat e() != SelectionEnd))
3543 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPositio n, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, 3544 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPositio n, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight,
3544 logicalHeight(), paintInfo)); 3545 logicalHeight(), paintInfo));
3545 return result; 3546 return result;
3546 } 3547 }
3547 3548
3548 GapRects RenderBlock::inlineSelectionGaps(RenderBlock* rootBlock, const LayoutPo int& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 3549 GapRects RenderBlock::inlineSelectionGaps(RenderBlock* rootBlock, const LayoutPo int& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
3549 LayoutUnit& lastLogicalTop, LayoutUnit & lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo) 3550 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, PaintInfo* paintInfo)
3550 { 3551 {
3551 GapRects result; 3552 GapRects result;
3552 3553
3553 bool containsStart = selectionState() == SelectionStart || selectionState() == SelectionBoth; 3554 bool containsStart = selectionState() == SelectionStart || selectionState() == SelectionBoth;
3554 3555
3555 if (!firstLineBox()) { 3556 if (!firstLineBox()) {
3556 if (containsStart) { 3557 if (containsStart) {
3557 // Go ahead and update our lastLogicalTop to be the bottom of the bl ock. <hr>s or empty blocks with height can trip this 3558 // Go ahead and update our lastLogicalTop to be the bottom of the bl ock. <hr>s or empty blocks with height can trip this
3558 // case. 3559 // case.
3559 lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock ) + logicalHeight(); 3560 lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock ) + logicalHeight();
(...skipping 13 matching lines...) Expand all
3573 LayoutUnit selHeight = curr->selectionHeightAdjustedForPrecedingBlock(); 3574 LayoutUnit selHeight = curr->selectionHeightAdjustedForPrecedingBlock();
3574 3575
3575 if (!containsStart && !lastSelectedLine && 3576 if (!containsStart && !lastSelectedLine &&
3576 selectionState() != SelectionStart && selectionState() != SelectionB oth) 3577 selectionState() != SelectionStart && selectionState() != SelectionB oth)
3577 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPos ition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, 3578 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPos ition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight,
3578 selTop, paintInfo)); 3579 selTop, paintInfo));
3579 3580
3580 LayoutRect logicalRect(curr->logicalLeft(), selTop, curr->logicalWidth() , selTop + selHeight); 3581 LayoutRect logicalRect(curr->logicalLeft(), selTop, curr->logicalWidth() , selTop + selHeight);
3581 logicalRect.move(isHorizontalWritingMode() ? offsetFromRootBlock : offse tFromRootBlock.transposedSize()); 3582 logicalRect.move(isHorizontalWritingMode() ? offsetFromRootBlock : offse tFromRootBlock.transposedSize());
3582 LayoutRect physicalRect = rootBlock->logicalRectToPhysicalRect(rootBlock PhysicalPosition, logicalRect); 3583 LayoutRect physicalRect = rootBlock->logicalRectToPhysicalRect(rootBlock PhysicalPosition, logicalRect);
3583 if (!paintInfo || (isHorizontalWritingMode() && physicalRect.y() < paint Info->rect.maxY() && physicalRect.maxY() > paintInfo->rect.y()) 3584 if (!paintInfo || (isHorizontalWritingMode() && physicalRect.y() < paint Info->getRect().maxY() && physicalRect.maxY() > paintInfo->getRect().y())
3584 || (!isHorizontalWritingMode() && physicalRect.x() < paintInfo->rect .maxX() && physicalRect.maxX() > paintInfo->rect.x())) 3585 || (!isHorizontalWritingMode() && physicalRect.x() < paintInfo->getR ect().maxX() && physicalRect.maxX() > paintInfo->getRect().x()))
3585 result.unite(curr->lineSelectionGap(rootBlock, rootBlockPhysicalPosi tion, offsetFromRootBlock, selTop, selHeight, paintInfo)); 3586 result.unite(curr->lineSelectionGap(rootBlock, rootBlockPhysicalPosi tion, offsetFromRootBlock, selTop, selHeight, paintInfo));
3586 3587
3587 lastSelectedLine = curr; 3588 lastSelectedLine = curr;
3588 } 3589 }
3589 3590
3590 if (containsStart && !lastSelectedLine) 3591 if (containsStart && !lastSelectedLine)
3591 // VisibleSelection must start just after our last line. 3592 // VisibleSelection must start just after our last line.
3592 lastSelectedLine = lastRootBox(); 3593 lastSelectedLine = lastRootBox();
3593 3594
3594 if (lastSelectedLine && selectionState() != SelectionEnd && selectionState() != SelectionBoth) { 3595 if (lastSelectedLine && selectionState() != SelectionEnd && selectionState() != SelectionBoth) {
3595 // Go ahead and update our lastY to be the bottom of the last selected l ine. 3596 // Go ahead and update our lastY to be the bottom of the last selected l ine.
3596 lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + lastSelectedLine->selectionBottom(); 3597 lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + lastSelectedLine->selectionBottom();
3597 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastSelectedLine ->selectionBottom()); 3598 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastSelectedLine ->selectionBottom());
3598 lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastSelectedLi ne->selectionBottom()); 3599 lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastSelectedLi ne->selectionBottom());
3599 } 3600 }
3600 return result; 3601 return result;
3601 } 3602 }
3602 3603
3603 GapRects RenderBlock::blockSelectionGaps(RenderBlock* rootBlock, const LayoutPoi nt& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 3604 GapRects RenderBlock::blockSelectionGaps(RenderBlock* rootBlock, const LayoutPoi nt& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
3604 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* paintInfo) 3605 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, PaintInfo* paintInfo)
3605 { 3606 {
3606 GapRects result; 3607 GapRects result;
3607 3608
3608 // Go ahead and jump right to the first block child that contains some selec ted objects. 3609 // Go ahead and jump right to the first block child that contains some selec ted objects.
3609 RenderBox* curr; 3610 RenderBox* curr;
3610 for (curr = firstChildBox(); curr && curr->selectionState() == SelectionNone ; curr = curr->nextSiblingBox()) { } 3611 for (curr = firstChildBox(); curr && curr->selectionState() == SelectionNone ; curr = curr->nextSiblingBox()) { }
3611 3612
3612 for (bool sawSelectionEnd = false; curr && !sawSelectionEnd; curr = curr->ne xtSiblingBox()) { 3613 for (bool sawSelectionEnd = false; curr && !sawSelectionEnd; curr = curr->ne xtSiblingBox()) {
3613 SelectionState childState = curr->selectionState(); 3614 SelectionState childState = curr->selectionState();
3614 if (childState == SelectionBoth || childState == SelectionEnd) 3615 if (childState == SelectionBoth || childState == SelectionEnd)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3656 lastLogicalRight = logicalRightSelectionOffset(rootBlock, curr->logi calBottom()); 3657 lastLogicalRight = logicalRightSelectionOffset(rootBlock, curr->logi calBottom());
3657 } else if (childState != SelectionNone) 3658 } else if (childState != SelectionNone)
3658 // We must be a block that has some selected object inside it. Go a head and recur. 3659 // We must be a block that has some selected object inside it. Go a head and recur.
3659 result.unite(toRenderBlock(curr)->selectionGaps(rootBlock, rootBlock PhysicalPosition, LayoutSize(offsetFromRootBlock.width() + curr->x(), offsetFrom RootBlock.height() + curr->y()), 3660 result.unite(toRenderBlock(curr)->selectionGaps(rootBlock, rootBlock PhysicalPosition, LayoutSize(offsetFromRootBlock.width() + curr->x(), offsetFrom RootBlock.height() + curr->y()),
3660 lastLogicalTop, last LogicalLeft, lastLogicalRight, paintInfo)); 3661 lastLogicalTop, last LogicalLeft, lastLogicalRight, paintInfo));
3661 } 3662 }
3662 return result; 3663 return result;
3663 } 3664 }
3664 3665
3665 LayoutRect RenderBlock::blockSelectionGap(RenderBlock* rootBlock, const LayoutPo int& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 3666 LayoutRect RenderBlock::blockSelectionGap(RenderBlock* rootBlock, const LayoutPo int& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
3666 LayoutUnit lastLogicalTop, LayoutUnit lastLogicalLeft, LayoutUnit lastLogicalRight, LayoutUnit logicalBottom, const Pa intInfo* paintInfo) 3667 LayoutUnit lastLogicalTop, LayoutUnit lastLogicalLeft, LayoutUnit lastLogica lRight, LayoutUnit logicalBottom, PaintInfo* paintInfo)
3667 { 3668 {
3668 LayoutUnit logicalTop = lastLogicalTop; 3669 LayoutUnit logicalTop = lastLogicalTop;
3669 LayoutUnit logicalHeight = blockDirectionOffset(rootBlock, offsetFromRootBlo ck) + logicalBottom - logicalTop; 3670 LayoutUnit logicalHeight = blockDirectionOffset(rootBlock, offsetFromRootBlo ck) + logicalBottom - logicalTop;
3670 if (logicalHeight <= 0) 3671 if (logicalHeight <= 0)
3671 return LayoutRect(); 3672 return LayoutRect();
3672 3673
3673 // Get the selection offsets for the bottom of the gap 3674 // Get the selection offsets for the bottom of the gap
3674 LayoutUnit logicalLeft = max(lastLogicalLeft, logicalLeftSelectionOffset(roo tBlock, logicalBottom)); 3675 LayoutUnit logicalLeft = max(lastLogicalLeft, logicalLeftSelectionOffset(roo tBlock, logicalBottom));
3675 LayoutUnit logicalRight = min(lastLogicalRight, logicalRightSelectionOffset( rootBlock, logicalBottom)); 3676 LayoutUnit logicalRight = min(lastLogicalRight, logicalRightSelectionOffset( rootBlock, logicalBottom));
3676 LayoutUnit logicalWidth = logicalRight - logicalLeft; 3677 LayoutUnit logicalWidth = logicalRight - logicalLeft;
3677 if (logicalWidth <= 0) 3678 if (logicalWidth <= 0)
3678 return LayoutRect(); 3679 return LayoutRect();
3679 3680
3680 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight)); 3681 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight));
3681 if (paintInfo) 3682 if (paintInfo)
3682 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selectionBack groundColor()); 3683 paintInfo->getContext()->fillRect(pixelSnappedIntRect(gapRect), selectio nBackgroundColor());
3683 return gapRect; 3684 return gapRect;
3684 } 3685 }
3685 3686
3686 LayoutRect RenderBlock::logicalLeftSelectionGap(RenderBlock* rootBlock, const La youtPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 3687 LayoutRect RenderBlock::logicalLeftSelectionGap(RenderBlock* rootBlock, const La youtPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
3687 RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo) 3688 RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutU nit logicalHeight, PaintInfo* paintInfo)
3688 { 3689 {
3689 LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromR ootBlock) + logicalTop; 3690 LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromR ootBlock) + logicalTop;
3690 LayoutUnit rootBlockLogicalLeft = max(logicalLeftSelectionOffset(rootBlock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight)); 3691 LayoutUnit rootBlockLogicalLeft = max(logicalLeftSelectionOffset(rootBlock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight));
3691 LayoutUnit rootBlockLogicalRight = min(inlineDirectionOffset(rootBlock, offs etFromRootBlock) + floorToInt(logicalLeft), min(logicalRightSelectionOffset(root Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH eight))); 3692 LayoutUnit rootBlockLogicalRight = min(inlineDirectionOffset(rootBlock, offs etFromRootBlock) + floorToInt(logicalLeft), min(logicalRightSelectionOffset(root Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH eight)));
3692 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft; 3693 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
3693 if (rootBlockLogicalWidth <= 0) 3694 if (rootBlockLogicalWidth <= 0)
3694 return LayoutRect(); 3695 return LayoutRect();
3695 3696
3696 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight)); 3697 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
3697 if (paintInfo) 3698 if (paintInfo)
3698 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selObj->selec tionBackgroundColor()); 3699 paintInfo->getContext()->fillRect(pixelSnappedIntRect(gapRect), selObj-> selectionBackgroundColor());
3699 return gapRect; 3700 return gapRect;
3700 } 3701 }
3701 3702
3702 LayoutRect RenderBlock::logicalRightSelectionGap(RenderBlock* rootBlock, const L ayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 3703 LayoutRect RenderBlock::logicalRightSelectionGap(RenderBlock* rootBlock, const L ayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
3703 RenderObject* selObj, LayoutUni t logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo * paintInfo) 3704 RenderObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, Layout Unit logicalHeight, PaintInfo* paintInfo)
3704 { 3705 {
3705 LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromR ootBlock) + logicalTop; 3706 LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromR ootBlock) + logicalTop;
3706 LayoutUnit rootBlockLogicalLeft = max(inlineDirectionOffset(rootBlock, offse tFromRootBlock) + floorToInt(logicalRight), max(logicalLeftSelectionOffset(rootB lock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHei ght))); 3707 LayoutUnit rootBlockLogicalLeft = max(inlineDirectionOffset(rootBlock, offse tFromRootBlock) + floorToInt(logicalRight), max(logicalLeftSelectionOffset(rootB lock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHei ght)));
3707 LayoutUnit rootBlockLogicalRight = min(logicalRightSelectionOffset(rootBlock , logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHeight )); 3708 LayoutUnit rootBlockLogicalRight = min(logicalRightSelectionOffset(rootBlock , logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHeight ));
3708 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft; 3709 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
3709 if (rootBlockLogicalWidth <= 0) 3710 if (rootBlockLogicalWidth <= 0)
3710 return LayoutRect(); 3711 return LayoutRect();
3711 3712
3712 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight)); 3713 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
3713 if (paintInfo) 3714 if (paintInfo)
3714 paintInfo->context->fillRect(pixelSnappedIntRect(gapRect), selObj->selec tionBackgroundColor()); 3715 paintInfo->getContext()->fillRect(pixelSnappedIntRect(gapRect), selObj-> selectionBackgroundColor());
3715 return gapRect; 3716 return gapRect;
3716 } 3717 }
3717 3718
3718 void RenderBlock::getSelectionGapInfo(SelectionState state, bool& leftGap, bool& rightGap) 3719 void RenderBlock::getSelectionGapInfo(SelectionState state, bool& leftGap, bool& rightGap)
3719 { 3720 {
3720 bool ltr = style()->isLeftToRightDirection(); 3721 bool ltr = style()->isLeftToRightDirection();
3721 leftGap = (state == RenderObject::SelectionInside) || 3722 leftGap = (state == RenderObject::SelectionInside) ||
3722 (state == RenderObject::SelectionEnd && ltr) || 3723 (state == RenderObject::SelectionEnd && ltr) ||
3723 (state == RenderObject::SelectionStart && !ltr); 3724 (state == RenderObject::SelectionStart && !ltr);
3724 rightGap = (state == RenderObject::SelectionInside) || 3725 rightGap = (state == RenderObject::SelectionInside) ||
(...skipping 4547 matching lines...) Expand 10 before | Expand all | Expand 10 after
8272 } 8273 }
8273 8274
8274 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl oatingObject* floatingObject) 8275 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl oatingObject* floatingObject)
8275 { 8276 {
8276 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped MaxY()); 8277 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped MaxY());
8277 } 8278 }
8278 8279
8279 #endif 8280 #endif
8280 8281
8281 } // namespace WebCore 8282 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698