| 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) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. | 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 * | 21 * |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #include "config.h" | 24 #include "config.h" |
| 25 #include "core/rendering/RenderFieldset.h" | 25 #include "core/rendering/RenderFieldset.h" |
| 26 | 26 |
| 27 #include "core/CSSPropertyNames.h" | 27 #include "core/CSSPropertyNames.h" |
| 28 #include "core/HTMLNames.h" | 28 #include "core/HTMLNames.h" |
| 29 #include "core/html/HTMLLegendElement.h" | 29 #include "core/html/HTMLLegendElement.h" |
| 30 #include "core/paint/BoxDecorationData.h" | 30 #include "core/paint/FieldsetPainter.h" |
| 31 #include "core/paint/BoxPainter.h" | |
| 32 #include "core/paint/DrawingRecorder.h" | |
| 33 #include "core/rendering/PaintInfo.h" | 31 #include "core/rendering/PaintInfo.h" |
| 34 #include "platform/graphics/GraphicsContextStateSaver.h" | 32 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 35 | 33 |
| 36 using std::min; | 34 using std::min; |
| 37 using std::max; | 35 using std::max; |
| 38 | 36 |
| 39 namespace blink { | 37 namespace blink { |
| 40 | 38 |
| 41 using namespace HTMLNames; | 39 using namespace HTMLNames; |
| 42 | 40 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 continue; | 132 continue; |
| 135 | 133 |
| 136 if (isHTMLLegendElement(legend->node())) | 134 if (isHTMLLegendElement(legend->node())) |
| 137 return toRenderBox(legend); | 135 return toRenderBox(legend); |
| 138 } | 136 } |
| 139 return 0; | 137 return 0; |
| 140 } | 138 } |
| 141 | 139 |
| 142 void RenderFieldset::paintBoxDecorationBackground(PaintInfo& paintInfo, const La
youtPoint& paintOffset) | 140 void RenderFieldset::paintBoxDecorationBackground(PaintInfo& paintInfo, const La
youtPoint& paintOffset) |
| 143 { | 141 { |
| 144 if (!paintInfo.shouldPaintWithinRoot(this)) | 142 FieldsetPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset); |
| 145 return; | |
| 146 | |
| 147 LayoutRect paintRect(paintOffset, size()); | |
| 148 RenderBox* legend = findLegend(); | |
| 149 if (!legend) | |
| 150 return RenderBlockFlow::paintBoxDecorationBackground(paintInfo, paintOff
set); | |
| 151 | |
| 152 // FIXME: We need to work with "rl" and "bt" block flow directions. In thos
e | |
| 153 // cases the legend is embedded in the right and bottom borders respectively
. | |
| 154 // https://bugs.webkit.org/show_bug.cgi?id=47236 | |
| 155 if (style()->isHorizontalWritingMode()) { | |
| 156 LayoutUnit yOff = (legend->y() > 0) ? LayoutUnit() : (legend->height() -
borderTop()) / 2; | |
| 157 paintRect.setHeight(paintRect.height() - yOff); | |
| 158 paintRect.setY(paintRect.y() + yOff); | |
| 159 } else { | |
| 160 LayoutUnit xOff = (legend->x() > 0) ? LayoutUnit() : (legend->width() -
borderLeft()) / 2; | |
| 161 paintRect.setWidth(paintRect.width() - xOff); | |
| 162 paintRect.setX(paintRect.x() + xOff); | |
| 163 } | |
| 164 | |
| 165 BoxDecorationData boxDecorationData(*style(), canRenderBorderImage(), backgr
oundHasOpaqueTopLayer(), paintInfo.context); | |
| 166 DrawingRecorder recorder(paintInfo.context, this, paintInfo.phase, pixelSnap
pedIntRect(paintOffset, paintRect.size())); | |
| 167 | |
| 168 if (boxDecorationData.bleedAvoidance() == BackgroundBleedNone) | |
| 169 BoxPainter::paintBoxShadow(paintInfo, paintRect, style(), Normal); | |
| 170 BoxPainter(*this).paintFillLayers(paintInfo, boxDecorationData.backgroundCol
or, style()->backgroundLayers(), paintRect); | |
| 171 BoxPainter::paintBoxShadow(paintInfo, paintRect, style(), Inset); | |
| 172 | |
| 173 if (!boxDecorationData.hasBorder) | |
| 174 return; | |
| 175 | |
| 176 // Create a clipping region around the legend and paint the border as normal | |
| 177 GraphicsContext* graphicsContext = paintInfo.context; | |
| 178 GraphicsContextStateSaver stateSaver(*graphicsContext); | |
| 179 | |
| 180 // FIXME: We need to work with "rl" and "bt" block flow directions. In thos
e | |
| 181 // cases the legend is embedded in the right and bottom borders respectively
. | |
| 182 // https://bugs.webkit.org/show_bug.cgi?id=47236 | |
| 183 if (style()->isHorizontalWritingMode()) { | |
| 184 LayoutUnit clipTop = paintRect.y(); | |
| 185 LayoutUnit clipHeight = max(static_cast<LayoutUnit>(style()->borderTopWi
dth()), legend->height() - ((legend->height() - borderTop()) / 2)); | |
| 186 graphicsContext->clipOut(pixelSnappedIntRect(paintRect.x() + legend->x()
, clipTop, legend->width(), clipHeight)); | |
| 187 } else { | |
| 188 LayoutUnit clipLeft = paintRect.x(); | |
| 189 LayoutUnit clipWidth = max(static_cast<LayoutUnit>(style()->borderLeftWi
dth()), legend->width()); | |
| 190 graphicsContext->clipOut(pixelSnappedIntRect(clipLeft, paintRect.y() + l
egend->y(), clipWidth, legend->height())); | |
| 191 } | |
| 192 | |
| 193 BoxPainter::paintBorder(*this, paintInfo, paintRect, style()); | |
| 194 } | 143 } |
| 195 | 144 |
| 196 void RenderFieldset::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOff
set) | 145 void RenderFieldset::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOff
set) |
| 197 { | 146 { |
| 198 if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) | 147 FieldsetPainter(*this).paintMask(paintInfo, paintOffset); |
| 199 return; | |
| 200 | |
| 201 LayoutRect paintRect = LayoutRect(paintOffset, size()); | |
| 202 RenderBox* legend = findLegend(); | |
| 203 if (!legend) | |
| 204 return RenderBlockFlow::paintMask(paintInfo, paintOffset); | |
| 205 | |
| 206 // FIXME: We need to work with "rl" and "bt" block flow directions. In thos
e | |
| 207 // cases the legend is embedded in the right and bottom borders respectively
. | |
| 208 // https://bugs.webkit.org/show_bug.cgi?id=47236 | |
| 209 if (style()->isHorizontalWritingMode()) { | |
| 210 LayoutUnit yOff = (legend->y() > 0) ? LayoutUnit() : (legend->height() -
borderTop()) / 2; | |
| 211 paintRect.expand(0, -yOff); | |
| 212 paintRect.move(0, yOff); | |
| 213 } else { | |
| 214 LayoutUnit xOff = (legend->x() > 0) ? LayoutUnit() : (legend->width() -
borderLeft()) / 2; | |
| 215 paintRect.expand(-xOff, 0); | |
| 216 paintRect.move(xOff, 0); | |
| 217 } | |
| 218 | |
| 219 BoxPainter(*this).paintMaskImages(paintInfo, paintRect); | |
| 220 } | 148 } |
| 221 | 149 |
| 222 } // namespace blink | 150 } // namespace blink |
| OLD | NEW |