OLD | NEW |
1 /** | 1 /** |
2 * Copyright (C) 2007 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007 Rob Buis <buis@kde.org> |
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 static inline bool textShouldBePainted(RenderSVGInlineText* textRenderer) | 182 static inline bool textShouldBePainted(RenderSVGInlineText* textRenderer) |
183 { | 183 { |
184 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which re
turns "int(x + 0.5)". | 184 // Font::pixelSize(), returns FontDescription::computedPixelSize(), which re
turns "int(x + 0.5)". |
185 // If the absolute font size on screen is below x=0.5, don't render anything
. | 185 // If the absolute font size on screen is below x=0.5, don't render anything
. |
186 return textRenderer->scaledFont().pixelSize(); | 186 return textRenderer->scaledFont().pixelSize(); |
187 } | 187 } |
188 | 188 |
189 void SVGInlineTextBox::paintSelectionBackground(PaintInfo& paintInfo) | 189 void SVGInlineTextBox::paintSelectionBackground(PaintInfo& paintInfo) |
190 { | 190 { |
191 ASSERT(paintInfo.shouldPaintWithinRoot(renderer())); | 191 ASSERT(paintInfo.shouldPaintWithinRoot(renderer())); |
192 ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh
aseSelection); | 192 ASSERT(paintInfo.getPhase() == PaintPhaseForeground || paintInfo.getPhase()
== PaintPhaseSelection); |
193 ASSERT(truncation() == cNoTruncation); | 193 ASSERT(truncation() == cNoTruncation); |
194 | 194 |
195 if (renderer()->style()->visibility() != VISIBLE) | 195 if (renderer()->style()->visibility() != VISIBLE) |
196 return; | 196 return; |
197 | 197 |
198 RenderObject* parentRenderer = parent()->renderer(); | 198 RenderObject* parentRenderer = parent()->renderer(); |
199 ASSERT(parentRenderer); | 199 ASSERT(parentRenderer); |
200 ASSERT(!parentRenderer->document()->printing()); | 200 ASSERT(!parentRenderer->document()->printing()); |
201 | 201 |
202 // Determine whether or not we're selected. | 202 // Determine whether or not we're selected. |
203 bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection; | 203 bool paintSelectedTextOnly = paintInfo.getPhase() == PaintPhaseSelection; |
204 bool hasSelection = selectionState() != RenderObject::SelectionNone; | 204 bool hasSelection = selectionState() != RenderObject::SelectionNone; |
205 if (!hasSelection || paintSelectedTextOnly) | 205 if (!hasSelection || paintSelectedTextOnly) |
206 return; | 206 return; |
207 | 207 |
208 Color backgroundColor = renderer()->selectionBackgroundColor(); | 208 Color backgroundColor = renderer()->selectionBackgroundColor(); |
209 if (!backgroundColor.alpha()) | 209 if (!backgroundColor.alpha()) |
210 return; | 210 return; |
211 | 211 |
212 RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer
()); | 212 RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer
()); |
213 ASSERT(textRenderer); | 213 ASSERT(textRenderer); |
(...skipping 19 matching lines...) Expand all Loading... |
233 unsigned textFragmentsSize = m_textFragments.size(); | 233 unsigned textFragmentsSize = m_textFragments.size(); |
234 for (unsigned i = 0; i < textFragmentsSize; ++i) { | 234 for (unsigned i = 0; i < textFragmentsSize; ++i) { |
235 SVGTextFragment& fragment = m_textFragments.at(i); | 235 SVGTextFragment& fragment = m_textFragments.at(i); |
236 ASSERT(!m_paintingResource); | 236 ASSERT(!m_paintingResource); |
237 | 237 |
238 fragmentStartPosition = startPosition; | 238 fragmentStartPosition = startPosition; |
239 fragmentEndPosition = endPosition; | 239 fragmentEndPosition = endPosition; |
240 if (!mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStart
Position, fragmentEndPosition)) | 240 if (!mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStart
Position, fragmentEndPosition)) |
241 continue; | 241 continue; |
242 | 242 |
243 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 243 GraphicsContextStateSaver stateSaver(*(paintInfo.getContext())); |
244 fragment.buildFragmentTransform(fragmentTransform); | 244 fragment.buildFragmentTransform(fragmentTransform); |
245 if (!fragmentTransform.isIdentity()) | 245 if (!fragmentTransform.isIdentity()) |
246 paintInfo.context->concatCTM(fragmentTransform); | 246 paintInfo.getContext()->concatCTM(fragmentTransform); |
247 | 247 |
248 paintInfo.context->setFillColor(backgroundColor); | 248 paintInfo.getContext()->setFillColor(backgroundColor); |
249 paintInfo.context->fillRect(selectionRectForTextFragment(fragment, fragm
entStartPosition, fragmentEndPosition, style), backgroundColor); | 249 paintInfo.getContext()->fillRect(selectionRectForTextFragment(fragment,
fragmentStartPosition, fragmentEndPosition, style), backgroundColor); |
250 | 250 |
251 m_paintingResourceMode = ApplyToDefaultMode; | 251 m_paintingResourceMode = ApplyToDefaultMode; |
252 } | 252 } |
253 | 253 |
254 ASSERT(!m_paintingResource); | 254 ASSERT(!m_paintingResource); |
255 } | 255 } |
256 | 256 |
257 void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint&, LayoutUni
t, LayoutUnit) | 257 void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint&, LayoutUni
t, LayoutUnit) |
258 { | 258 { |
259 ASSERT(paintInfo.shouldPaintWithinRoot(renderer())); | 259 ASSERT(paintInfo.shouldPaintWithinRoot(renderer())); |
260 ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh
aseSelection); | 260 ASSERT(paintInfo.getPhase() == PaintPhaseForeground || paintInfo.getPhase()
== PaintPhaseSelection); |
261 ASSERT(truncation() == cNoTruncation); | 261 ASSERT(truncation() == cNoTruncation); |
262 | 262 |
263 if (renderer()->style()->visibility() != VISIBLE) | 263 if (renderer()->style()->visibility() != VISIBLE) |
264 return; | 264 return; |
265 | 265 |
266 // Note: We're explicitely not supporting composition & custom underlines an
d custom highlighters - unlike InlineTextBox. | 266 // Note: We're explicitely not supporting composition & custom underlines an
d custom highlighters - unlike InlineTextBox. |
267 // If we ever need that for SVG, it's very easy to refactor and reuse the co
de. | 267 // If we ever need that for SVG, it's very easy to refactor and reuse the co
de. |
268 | 268 |
269 RenderObject* parentRenderer = parent()->renderer(); | 269 RenderObject* parentRenderer = parent()->renderer(); |
270 ASSERT(parentRenderer); | 270 ASSERT(parentRenderer); |
271 | 271 |
272 bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection; | 272 bool paintSelectedTextOnly = paintInfo.getPhase() == PaintPhaseSelection; |
273 bool hasSelection = !parentRenderer->document()->printing() && selectionStat
e() != RenderObject::SelectionNone; | 273 bool hasSelection = !parentRenderer->document()->printing() && selectionStat
e() != RenderObject::SelectionNone; |
274 if (!hasSelection && paintSelectedTextOnly) | 274 if (!hasSelection && paintSelectedTextOnly) |
275 return; | 275 return; |
276 | 276 |
277 RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer
()); | 277 RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer
()); |
278 ASSERT(textRenderer); | 278 ASSERT(textRenderer); |
279 if (!textShouldBePainted(textRenderer)) | 279 if (!textShouldBePainted(textRenderer)) |
280 return; | 280 return; |
281 | 281 |
282 RenderStyle* style = parentRenderer->style(); | 282 RenderStyle* style = parentRenderer->style(); |
(...skipping 24 matching lines...) Expand all Loading... |
307 hasFill = true; | 307 hasFill = true; |
308 hasVisibleStroke = false; | 308 hasVisibleStroke = false; |
309 } | 309 } |
310 | 310 |
311 AffineTransform fragmentTransform; | 311 AffineTransform fragmentTransform; |
312 unsigned textFragmentsSize = m_textFragments.size(); | 312 unsigned textFragmentsSize = m_textFragments.size(); |
313 for (unsigned i = 0; i < textFragmentsSize; ++i) { | 313 for (unsigned i = 0; i < textFragmentsSize; ++i) { |
314 SVGTextFragment& fragment = m_textFragments.at(i); | 314 SVGTextFragment& fragment = m_textFragments.at(i); |
315 ASSERT(!m_paintingResource); | 315 ASSERT(!m_paintingResource); |
316 | 316 |
317 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 317 GraphicsContextStateSaver stateSaver(*(paintInfo.getContext())); |
318 fragment.buildFragmentTransform(fragmentTransform); | 318 fragment.buildFragmentTransform(fragmentTransform); |
319 if (!fragmentTransform.isIdentity()) | 319 if (!fragmentTransform.isIdentity()) |
320 paintInfo.context->concatCTM(fragmentTransform); | 320 paintInfo.getContext()->concatCTM(fragmentTransform); |
321 | 321 |
322 // Spec: All text decorations except line-through should be drawn before
the text is filled and stroked; thus, the text is rendered on top of these deco
rations. | 322 // Spec: All text decorations except line-through should be drawn before
the text is filled and stroked; thus, the text is rendered on top of these deco
rations. |
323 int decorations = style->textDecorationsInEffect(); | 323 int decorations = style->textDecorationsInEffect(); |
324 if (decorations & TextDecorationUnderline) | 324 if (decorations & TextDecorationUnderline) |
325 paintDecoration(paintInfo.context, TextDecorationUnderline, fragment
); | 325 paintDecoration(paintInfo.getContext(), TextDecorationUnderline, fra
gment); |
326 if (decorations & TextDecorationOverline) | 326 if (decorations & TextDecorationOverline) |
327 paintDecoration(paintInfo.context, TextDecorationOverline, fragment)
; | 327 paintDecoration(paintInfo.getContext(), TextDecorationOverline, frag
ment); |
328 | 328 |
329 // Fill text | 329 // Fill text |
330 if (hasFill) { | 330 if (hasFill) { |
331 m_paintingResourceMode = ApplyToFillMode | ApplyToTextMode; | 331 m_paintingResourceMode = ApplyToFillMode | ApplyToTextMode; |
332 paintText(paintInfo.context, style, selectionStyle, fragment, hasSel
ection, paintSelectedTextOnly); | 332 paintText(paintInfo.getContext(), style, selectionStyle, fragment, h
asSelection, paintSelectedTextOnly); |
333 } | 333 } |
334 | 334 |
335 // Stroke text | 335 // Stroke text |
336 if (hasVisibleStroke) { | 336 if (hasVisibleStroke) { |
337 m_paintingResourceMode = ApplyToStrokeMode | ApplyToTextMode; | 337 m_paintingResourceMode = ApplyToStrokeMode | ApplyToTextMode; |
338 paintText(paintInfo.context, style, selectionStyle, fragment, hasSel
ection, paintSelectedTextOnly); | 338 paintText(paintInfo.getContext(), style, selectionStyle, fragment, h
asSelection, paintSelectedTextOnly); |
339 } | 339 } |
340 | 340 |
341 // Spec: Line-through should be drawn after the text is filled and strok
ed; thus, the line-through is rendered on top of the text. | 341 // Spec: Line-through should be drawn after the text is filled and strok
ed; thus, the line-through is rendered on top of the text. |
342 if (decorations & TextDecorationLineThrough) | 342 if (decorations & TextDecorationLineThrough) |
343 paintDecoration(paintInfo.context, TextDecorationLineThrough, fragme
nt); | 343 paintDecoration(paintInfo.getContext(), TextDecorationLineThrough, f
ragment); |
344 | 344 |
345 m_paintingResourceMode = ApplyToDefaultMode; | 345 m_paintingResourceMode = ApplyToDefaultMode; |
346 } | 346 } |
347 | 347 |
348 ASSERT(!m_paintingResource); | 348 ASSERT(!m_paintingResource); |
349 } | 349 } |
350 | 350 |
351 bool SVGInlineTextBox::acquirePaintingResource(GraphicsContext*& context, float
scalingFactor, RenderObject* renderer, RenderStyle* style) | 351 bool SVGInlineTextBox::acquirePaintingResource(GraphicsContext*& context, float
scalingFactor, RenderObject* renderer, RenderStyle* style) |
352 { | 352 { |
353 ASSERT(scalingFactor); | 353 ASSERT(scalingFactor); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 renderer()->updateHitTestResult(result, locationInContainer.poin
t() - toLayoutSize(accumulatedOffset)); | 732 renderer()->updateHitTestResult(result, locationInContainer.poin
t() - toLayoutSize(accumulatedOffset)); |
733 if (!result.addNodeToRectBasedTestResult(renderer()->node(), req
uest, locationInContainer, rect)) | 733 if (!result.addNodeToRectBasedTestResult(renderer()->node(), req
uest, locationInContainer, rect)) |
734 return true; | 734 return true; |
735 } | 735 } |
736 } | 736 } |
737 } | 737 } |
738 return false; | 738 return false; |
739 } | 739 } |
740 | 740 |
741 } // namespace WebCore | 741 } // namespace WebCore |
OLD | NEW |