| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. |
| 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 10 * | 10 * |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 341 } |
| 342 | 342 |
| 343 void CanvasRenderingContext2D::State::fontsNeedUpdate(CSSFontSelector* fontSelec
tor) | 343 void CanvasRenderingContext2D::State::fontsNeedUpdate(CSSFontSelector* fontSelec
tor) |
| 344 { | 344 { |
| 345 ASSERT_ARG(fontSelector, fontSelector == m_font.fontSelector()); | 345 ASSERT_ARG(fontSelector, fontSelector == m_font.fontSelector()); |
| 346 ASSERT(m_realizedFont); | 346 ASSERT(m_realizedFont); |
| 347 | 347 |
| 348 m_font.update(fontSelector); | 348 m_font.update(fontSelector); |
| 349 } | 349 } |
| 350 | 350 |
| 351 void CanvasRenderingContext2D::State::trace(Visitor* visitor) |
| 352 { |
| 353 visitor->trace(m_strokeStyle); |
| 354 visitor->trace(m_fillStyle); |
| 355 CSSFontSelectorClient::trace(visitor); |
| 356 } |
| 357 |
| 351 void CanvasRenderingContext2D::realizeSaves() | 358 void CanvasRenderingContext2D::realizeSaves() |
| 352 { | 359 { |
| 353 validateStateStack(); | 360 validateStateStack(); |
| 354 if (state().m_unrealizedSaveCount) { | 361 if (state().m_unrealizedSaveCount) { |
| 355 ASSERT(m_stateStack.size() >= 1); | 362 ASSERT(m_stateStack.size() >= 1); |
| 356 // Reduce the current state's unrealized count by one now, | 363 // Reduce the current state's unrealized count by one now, |
| 357 // to reflect the fact we are saving one state. | 364 // to reflect the fact we are saving one state. |
| 358 m_stateStack.last()->m_unrealizedSaveCount--; | 365 m_stateStack.last()->m_unrealizedSaveCount--; |
| 359 m_stateStack.append(adoptPtrWillBeNoop(new State(state()))); | 366 m_stateStack.append(adoptPtrWillBeNoop(new State(state()))); |
| 360 // Set the new state's unrealized count to 0, because it has no outstand
ing saves. | 367 // Set the new state's unrealized count to 0, because it has no outstand
ing saves. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 387 if (c) | 394 if (c) |
| 388 c->restore(); | 395 c->restore(); |
| 389 validateStateStack(); | 396 validateStateStack(); |
| 390 } | 397 } |
| 391 | 398 |
| 392 CanvasStyle* CanvasRenderingContext2D::strokeStyle() const | 399 CanvasStyle* CanvasRenderingContext2D::strokeStyle() const |
| 393 { | 400 { |
| 394 return state().m_strokeStyle.get(); | 401 return state().m_strokeStyle.get(); |
| 395 } | 402 } |
| 396 | 403 |
| 397 void CanvasRenderingContext2D::setStrokeStyle(PassRefPtr<CanvasStyle> prpStyle) | 404 void CanvasRenderingContext2D::setStrokeStyle(PassRefPtrWillBeRawPtr<CanvasStyle
> prpStyle) |
| 398 { | 405 { |
| 399 RefPtr<CanvasStyle> style = prpStyle; | 406 RefPtrWillBeRawPtr<CanvasStyle> style = prpStyle; |
| 400 | 407 |
| 401 if (!style) | 408 if (!style) |
| 402 return; | 409 return; |
| 403 | 410 |
| 404 if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentColor(*style
)) | 411 if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentColor(*style
)) |
| 405 return; | 412 return; |
| 406 | 413 |
| 407 if (style->isCurrentColor()) { | 414 if (style->isCurrentColor()) { |
| 408 if (style->hasOverrideAlpha()) | 415 if (style->hasOverrideAlpha()) |
| 409 style = CanvasStyle::createFromRGBA(colorWithOverrideAlpha(currentCo
lor(canvas()), style->overrideAlpha())); | 416 style = CanvasStyle::createFromRGBA(colorWithOverrideAlpha(currentCo
lor(canvas()), style->overrideAlpha())); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 420 return; | 427 return; |
| 421 state().m_strokeStyle->applyStrokeColor(c); | 428 state().m_strokeStyle->applyStrokeColor(c); |
| 422 modifiableState().m_unparsedStrokeColor = String(); | 429 modifiableState().m_unparsedStrokeColor = String(); |
| 423 } | 430 } |
| 424 | 431 |
| 425 CanvasStyle* CanvasRenderingContext2D::fillStyle() const | 432 CanvasStyle* CanvasRenderingContext2D::fillStyle() const |
| 426 { | 433 { |
| 427 return state().m_fillStyle.get(); | 434 return state().m_fillStyle.get(); |
| 428 } | 435 } |
| 429 | 436 |
| 430 void CanvasRenderingContext2D::setFillStyle(PassRefPtr<CanvasStyle> prpStyle) | 437 void CanvasRenderingContext2D::setFillStyle(PassRefPtrWillBeRawPtr<CanvasStyle>
prpStyle) |
| 431 { | 438 { |
| 432 RefPtr<CanvasStyle> style = prpStyle; | 439 RefPtrWillBeRawPtr<CanvasStyle> style = prpStyle; |
| 433 | 440 |
| 434 if (!style) | 441 if (!style) |
| 435 return; | 442 return; |
| 436 | 443 |
| 437 if (state().m_fillStyle && state().m_fillStyle->isEquivalentColor(*style)) | 444 if (state().m_fillStyle && state().m_fillStyle->isEquivalentColor(*style)) |
| 438 return; | 445 return; |
| 439 | 446 |
| 440 if (style->isCurrentColor()) { | 447 if (style->isCurrentColor()) { |
| 441 if (style->hasOverrideAlpha()) | 448 if (style->hasOverrideAlpha()) |
| 442 style = CanvasStyle::createFromRGBA(colorWithOverrideAlpha(currentCo
lor(canvas()), style->overrideAlpha())); | 449 style = CanvasStyle::createFromRGBA(colorWithOverrideAlpha(currentCo
lor(canvas()), style->overrideAlpha())); |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1648 GraphicsContext* c = drawingContext(); | 1655 GraphicsContext* c = drawingContext(); |
| 1649 ASSERT(c); | 1656 ASSERT(c); |
| 1650 c->beginLayer(1, state().m_globalComposite); | 1657 c->beginLayer(1, state().m_globalComposite); |
| 1651 CompositeOperator previousOperator = c->compositeOperation(); | 1658 CompositeOperator previousOperator = c->compositeOperation(); |
| 1652 c->setCompositeOperation(CompositeSourceOver); | 1659 c->setCompositeOperation(CompositeSourceOver); |
| 1653 strokePrimitive(area, c); | 1660 strokePrimitive(area, c); |
| 1654 c->setCompositeOperation(previousOperator); | 1661 c->setCompositeOperation(previousOperator); |
| 1655 c->endLayer(); | 1662 c->endLayer(); |
| 1656 } | 1663 } |
| 1657 | 1664 |
| 1658 PassRefPtr<CanvasGradient> CanvasRenderingContext2D::createLinearGradient(float
x0, float y0, float x1, float y1) | 1665 PassRefPtrWillBeRawPtr<CanvasGradient> CanvasRenderingContext2D::createLinearGra
dient(float x0, float y0, float x1, float y1) |
| 1659 { | 1666 { |
| 1660 RefPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0),
FloatPoint(x1, y1)); | 1667 RefPtrWillBeRawPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPo
int(x0, y0), FloatPoint(x1, y1)); |
| 1661 return gradient.release(); | 1668 return gradient.release(); |
| 1662 } | 1669 } |
| 1663 | 1670 |
| 1664 PassRefPtr<CanvasGradient> CanvasRenderingContext2D::createRadialGradient(float
x0, float y0, float r0, float x1, float y1, float r1, ExceptionState& exceptionS
tate) | 1671 PassRefPtrWillBeRawPtr<CanvasGradient> CanvasRenderingContext2D::createRadialGra
dient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionState
& exceptionState) |
| 1665 { | 1672 { |
| 1666 if (r0 < 0 || r1 < 0) { | 1673 if (r0 < 0 || r1 < 0) { |
| 1667 exceptionState.throwDOMException(IndexSizeError, String::format("The %s
provided is less than 0.", r0 < 0 ? "r0" : "r1")); | 1674 exceptionState.throwDOMException(IndexSizeError, String::format("The %s
provided is less than 0.", r0 < 0 ? "r0" : "r1")); |
| 1668 return nullptr; | 1675 return nullptr; |
| 1669 } | 1676 } |
| 1670 | 1677 |
| 1671 RefPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPoint(x0, y0),
r0, FloatPoint(x1, y1), r1); | 1678 RefPtrWillBeRawPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPo
int(x0, y0), r0, FloatPoint(x1, y1), r1); |
| 1672 return gradient.release(); | 1679 return gradient.release(); |
| 1673 } | 1680 } |
| 1674 | 1681 |
| 1675 PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(CanvasImageSou
rce* imageSource, | 1682 PassRefPtrWillBeRawPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(Ca
nvasImageSource* imageSource, |
| 1676 const String& repetitionType, ExceptionState& exceptionState) | 1683 const String& repetitionType, ExceptionState& exceptionState) |
| 1677 { | 1684 { |
| 1678 bool repeatX, repeatY; | 1685 bool repeatX, repeatY; |
| 1679 CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, excepti
onState); | 1686 CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, excepti
onState); |
| 1680 if (exceptionState.hadException()) | 1687 if (exceptionState.hadException()) |
| 1681 return nullptr; | 1688 return nullptr; |
| 1682 | 1689 |
| 1683 SourceImageStatus status; | 1690 SourceImageStatus status; |
| 1684 RefPtr<Image> imageForRendering = imageSource->getSourceImageForCanvas(CopyS
ourceImageIfVolatile, &status); | 1691 RefPtr<Image> imageForRendering = imageSource->getSourceImageForCanvas(CopyS
ourceImageIfVolatile, &status); |
| 1685 | 1692 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2055 for (unsigned i = 0; i < textLength; i++) { | 2062 for (unsigned i = 0; i < textLength; i++) { |
| 2056 if (isSpaceCharacter(text[i])) | 2063 if (isSpaceCharacter(text[i])) |
| 2057 charVector[i] = ' '; | 2064 charVector[i] = ' '; |
| 2058 else | 2065 else |
| 2059 charVector[i] = text[i]; | 2066 charVector[i] = text[i]; |
| 2060 } | 2067 } |
| 2061 | 2068 |
| 2062 return String(charVector); | 2069 return String(charVector); |
| 2063 } | 2070 } |
| 2064 | 2071 |
| 2065 PassRefPtr<TextMetrics> CanvasRenderingContext2D::measureText(const String& text
) | 2072 PassRefPtrWillBeRawPtr<TextMetrics> CanvasRenderingContext2D::measureText(const
String& text) |
| 2066 { | 2073 { |
| 2067 RefPtr<TextMetrics> metrics = TextMetrics::create(); | 2074 RefPtrWillBeRawPtr<TextMetrics> metrics = TextMetrics::create(); |
| 2068 | 2075 |
| 2069 // The style resolution required for rendering text is not available in fram
e-less documents. | 2076 // The style resolution required for rendering text is not available in fram
e-less documents. |
| 2070 if (!canvas()->document().frame()) | 2077 if (!canvas()->document().frame()) |
| 2071 return metrics.release(); | 2078 return metrics.release(); |
| 2072 | 2079 |
| 2073 FontCachePurgePreventer fontCachePurgePreventer; | 2080 FontCachePurgePreventer fontCachePurgePreventer; |
| 2074 canvas()->document().updateRenderTreeIfNeeded(); | 2081 canvas()->document().updateRenderTreeIfNeeded(); |
| 2075 const Font& font = accessFont(); | 2082 const Font& font = accessFont(); |
| 2076 String normalizedText = normalizeSpaces(text); | 2083 String normalizedText = normalizeSpaces(text); |
| 2077 const TextRun textRun(normalizedText); | 2084 const TextRun textRun(normalizedText); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2279 if (enabled == state().m_imageSmoothingEnabled) | 2286 if (enabled == state().m_imageSmoothingEnabled) |
| 2280 return; | 2287 return; |
| 2281 | 2288 |
| 2282 realizeSaves(); | 2289 realizeSaves(); |
| 2283 modifiableState().m_imageSmoothingEnabled = enabled; | 2290 modifiableState().m_imageSmoothingEnabled = enabled; |
| 2284 GraphicsContext* c = drawingContext(); | 2291 GraphicsContext* c = drawingContext(); |
| 2285 if (c) | 2292 if (c) |
| 2286 c->setImageInterpolationQuality(enabled ? CanvasDefaultInterpolationQual
ity : InterpolationNone); | 2293 c->setImageInterpolationQuality(enabled ? CanvasDefaultInterpolationQual
ity : InterpolationNone); |
| 2287 } | 2294 } |
| 2288 | 2295 |
| 2289 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib
utes() const | 2296 PassRefPtrWillBeRawPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getC
ontextAttributes() const |
| 2290 { | 2297 { |
| 2291 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr
eate(); | 2298 RefPtrWillBeRawPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAt
tributes::create(); |
| 2292 attributes->setAlpha(m_hasAlpha); | 2299 attributes->setAlpha(m_hasAlpha); |
| 2293 return attributes.release(); | 2300 return attributes.release(); |
| 2294 } | 2301 } |
| 2295 | 2302 |
| 2296 void CanvasRenderingContext2D::drawFocusIfNeeded(Element* element) | 2303 void CanvasRenderingContext2D::drawFocusIfNeeded(Element* element) |
| 2297 { | 2304 { |
| 2298 drawFocusIfNeededInternal(m_path, element); | 2305 drawFocusIfNeededInternal(m_path, element); |
| 2299 } | 2306 } |
| 2300 | 2307 |
| 2301 void CanvasRenderingContext2D::drawFocusIfNeeded(Path2D* path2d, Element* elemen
t) | 2308 void CanvasRenderingContext2D::drawFocusIfNeeded(Path2D* path2d, Element* elemen
t) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2441 | 2448 |
| 2442 unsigned CanvasRenderingContext2D::hitRegionsCount() const | 2449 unsigned CanvasRenderingContext2D::hitRegionsCount() const |
| 2443 { | 2450 { |
| 2444 if (m_hitRegionManager) | 2451 if (m_hitRegionManager) |
| 2445 return m_hitRegionManager->getHitRegionsCount(); | 2452 return m_hitRegionManager->getHitRegionsCount(); |
| 2446 | 2453 |
| 2447 return 0; | 2454 return 0; |
| 2448 } | 2455 } |
| 2449 | 2456 |
| 2450 } // namespace WebCore | 2457 } // namespace WebCore |
| OLD | NEW |