| 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 void CanvasRenderingContext2D::scrollPathIntoView(Path2D* path2d) | 315 void CanvasRenderingContext2D::scrollPathIntoView(Path2D* path2d) |
| 316 { | 316 { |
| 317 scrollPathIntoViewInternal(path2d->path()); | 317 scrollPathIntoViewInternal(path2d->path()); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path) | 320 void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path) |
| 321 { | 321 { |
| 322 if (!state().isTransformInvertible() || path.isEmpty()) | 322 if (!state().isTransformInvertible() || path.isEmpty()) |
| 323 return; | 323 return; |
| 324 | 324 |
| 325 canvas()->document().updateLayoutIgnorePendingStylesheets(); | 325 canvas()->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 326 | 326 |
| 327 LayoutObject* renderer = canvas()->layoutObject(); | 327 LayoutObject* renderer = canvas()->layoutObject(); |
| 328 LayoutBox* layoutBox = canvas()->layoutBox(); | 328 LayoutBox* layoutBox = canvas()->layoutBox(); |
| 329 if (!renderer || !layoutBox) | 329 if (!renderer || !layoutBox) |
| 330 return; | 330 return; |
| 331 | 331 |
| 332 // Apply transformation and get the bounding rect | 332 // Apply transformation and get the bounding rect |
| 333 Path transformedPath = path; | 333 Path transformedPath = path; |
| 334 transformedPath.transform(state().transform()); | 334 transformedPath.transform(state().transform()); |
| 335 FloatRect boundingRect = transformedPath.boundingRect(); | 335 FloatRect boundingRect = transformedPath.boundingRect(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 448 |
| 449 return serializedFont.toString(); | 449 return serializedFont.toString(); |
| 450 } | 450 } |
| 451 | 451 |
| 452 void CanvasRenderingContext2D::setFont(const String& newFont) | 452 void CanvasRenderingContext2D::setFont(const String& newFont) |
| 453 { | 453 { |
| 454 // The style resolution required for rendering text is not available in fram
e-less documents. | 454 // The style resolution required for rendering text is not available in fram
e-less documents. |
| 455 if (!canvas()->document().frame()) | 455 if (!canvas()->document().frame()) |
| 456 return; | 456 return; |
| 457 | 457 |
| 458 canvas()->document().updateLayoutTreeForNode(canvas()); | 458 canvas()->document().updateStyleAndLayoutTreeForNode(canvas()); |
| 459 | 459 |
| 460 // The following early exit is dependent on the cache not being empty | 460 // The following early exit is dependent on the cache not being empty |
| 461 // because an empty cache may indicate that a style change has occured | 461 // because an empty cache may indicate that a style change has occured |
| 462 // which would require that the font be re-resolved. This check has to | 462 // which would require that the font be re-resolved. This check has to |
| 463 // come after the layout tree update to flush pending style changes. | 463 // come after the layout tree update to flush pending style changes. |
| 464 if (newFont == state().unparsedFont() && state().hasRealizedFont() && m_font
sResolvedUsingCurrentStyle.size() > 0) | 464 if (newFont == state().unparsedFont() && state().hasRealizedFont() && m_font
sResolvedUsingCurrentStyle.size() > 0) |
| 465 return; | 465 return; |
| 466 | 466 |
| 467 CanvasFontCache* canvasFontCache = canvas()->document().canvasFontCache(); | 467 CanvasFontCache* canvasFontCache = canvas()->document().canvasFontCache(); |
| 468 | 468 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 case CanvasRenderingContext2DState::DirectionLTR: | 661 case CanvasRenderingContext2DState::DirectionLTR: |
| 662 return LTR; | 662 return LTR; |
| 663 } | 663 } |
| 664 ASSERT_NOT_REACHED(); | 664 ASSERT_NOT_REACHED(); |
| 665 return LTR; | 665 return LTR; |
| 666 } | 666 } |
| 667 | 667 |
| 668 String CanvasRenderingContext2D::direction() const | 668 String CanvasRenderingContext2D::direction() const |
| 669 { | 669 { |
| 670 if (state().getDirection() == CanvasRenderingContext2DState::DirectionInheri
t) | 670 if (state().getDirection() == CanvasRenderingContext2DState::DirectionInheri
t) |
| 671 canvas()->document().updateLayoutTreeForNode(canvas()); | 671 canvas()->document().updateStyleAndLayoutTreeForNode(canvas()); |
| 672 return toTextDirection(state().getDirection(), canvas()) == RTL ? rtl : ltr; | 672 return toTextDirection(state().getDirection(), canvas()) == RTL ? rtl : ltr; |
| 673 } | 673 } |
| 674 | 674 |
| 675 void CanvasRenderingContext2D::setDirection(const String& directionString) | 675 void CanvasRenderingContext2D::setDirection(const String& directionString) |
| 676 { | 676 { |
| 677 CanvasRenderingContext2DState::Direction direction; | 677 CanvasRenderingContext2DState::Direction direction; |
| 678 if (directionString == inherit) | 678 if (directionString == inherit) |
| 679 direction = CanvasRenderingContext2DState::DirectionInherit; | 679 direction = CanvasRenderingContext2DState::DirectionInherit; |
| 680 else if (directionString == rtl) | 680 else if (directionString == rtl) |
| 681 direction = CanvasRenderingContext2DState::DirectionRTL; | 681 direction = CanvasRenderingContext2DState::DirectionRTL; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 711 } | 711 } |
| 712 | 712 |
| 713 TextMetrics* CanvasRenderingContext2D::measureText(const String& text) | 713 TextMetrics* CanvasRenderingContext2D::measureText(const String& text) |
| 714 { | 714 { |
| 715 TextMetrics* metrics = TextMetrics::create(); | 715 TextMetrics* metrics = TextMetrics::create(); |
| 716 | 716 |
| 717 // The style resolution required for rendering text is not available in fram
e-less documents. | 717 // The style resolution required for rendering text is not available in fram
e-less documents. |
| 718 if (!canvas()->document().frame()) | 718 if (!canvas()->document().frame()) |
| 719 return metrics; | 719 return metrics; |
| 720 | 720 |
| 721 canvas()->document().updateLayoutTreeForNode(canvas()); | 721 canvas()->document().updateStyleAndLayoutTreeForNode(canvas()); |
| 722 const Font& font = accessFont(); | 722 const Font& font = accessFont(); |
| 723 | 723 |
| 724 TextDirection direction; | 724 TextDirection direction; |
| 725 if (state().getDirection() == CanvasRenderingContext2DState::DirectionInheri
t) | 725 if (state().getDirection() == CanvasRenderingContext2DState::DirectionInheri
t) |
| 726 direction = determineDirectionality(text); | 726 direction = determineDirectionality(text); |
| 727 else | 727 else |
| 728 direction = toTextDirection(state().getDirection(), canvas()); | 728 direction = toTextDirection(state().getDirection(), canvas()); |
| 729 TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion | TextRun::Forbi
dLeadingExpansion, direction, false); | 729 TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion | TextRun::Forbi
dLeadingExpansion, direction, false); |
| 730 textRun.setNormalizeSpace(true); | 730 textRun.setNormalizeSpace(true); |
| 731 FloatRect textBounds = font.selectionRectForText(textRun, FloatPoint(), font
.getFontDescription().computedSize(), 0, -1, true); | 731 FloatRect textBounds = font.selectionRectForText(textRun, FloatPoint(), font
.getFontDescription().computedSize(), 0, -1, true); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 759 | 759 |
| 760 void CanvasRenderingContext2D::drawTextInternal(const String& text, double x, do
uble y, CanvasRenderingContext2DState::PaintType paintType, double* maxWidth) | 760 void CanvasRenderingContext2D::drawTextInternal(const String& text, double x, do
uble y, CanvasRenderingContext2DState::PaintType paintType, double* maxWidth) |
| 761 { | 761 { |
| 762 // The style resolution required for rendering text is not available in fram
e-less documents. | 762 // The style resolution required for rendering text is not available in fram
e-less documents. |
| 763 if (!canvas()->document().frame()) | 763 if (!canvas()->document().frame()) |
| 764 return; | 764 return; |
| 765 | 765 |
| 766 // accessFont needs the style to be up to date, but updating style can cause
script to run, | 766 // accessFont needs the style to be up to date, but updating style can cause
script to run, |
| 767 // (e.g. due to autofocus) which can free the canvas (set size to 0, for exa
mple), so update | 767 // (e.g. due to autofocus) which can free the canvas (set size to 0, for exa
mple), so update |
| 768 // style before grabbing the drawingCanvas. | 768 // style before grabbing the drawingCanvas. |
| 769 canvas()->document().updateLayoutTreeForNode(canvas()); | 769 canvas()->document().updateStyleAndLayoutTreeForNode(canvas()); |
| 770 | 770 |
| 771 SkCanvas* c = drawingCanvas(); | 771 SkCanvas* c = drawingCanvas(); |
| 772 if (!c) | 772 if (!c) |
| 773 return; | 773 return; |
| 774 | 774 |
| 775 if (!std::isfinite(x) || !std::isfinite(y)) | 775 if (!std::isfinite(x) || !std::isfinite(y)) |
| 776 return; | 776 return; |
| 777 if (maxWidth && (!std::isfinite(*maxWidth) || *maxWidth <= 0)) | 777 if (maxWidth && (!std::isfinite(*maxWidth) || *maxWidth <= 0)) |
| 778 return; | 778 return; |
| 779 | 779 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 963 |
| 964 SkIRect dirtyRect; | 964 SkIRect dirtyRect; |
| 965 if (!computeDirtyRect(path.strokeBoundingRect(strokeData), &dirtyRect)) | 965 if (!computeDirtyRect(path.strokeBoundingRect(strokeData), &dirtyRect)) |
| 966 return; | 966 return; |
| 967 | 967 |
| 968 didDraw(dirtyRect); | 968 didDraw(dirtyRect); |
| 969 } | 969 } |
| 970 | 970 |
| 971 void CanvasRenderingContext2D::updateElementAccessibility(const Path& path, Elem
ent* element) | 971 void CanvasRenderingContext2D::updateElementAccessibility(const Path& path, Elem
ent* element) |
| 972 { | 972 { |
| 973 element->document().updateLayoutIgnorePendingStylesheets(); | 973 element->document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 974 AXObjectCache* axObjectCache = element->document().existingAXObjectCache(); | 974 AXObjectCache* axObjectCache = element->document().existingAXObjectCache(); |
| 975 LayoutBoxModelObject* lbmo = canvas()->layoutBoxModelObject(); | 975 LayoutBoxModelObject* lbmo = canvas()->layoutBoxModelObject(); |
| 976 LayoutObject* renderer = canvas()->layoutObject(); | 976 LayoutObject* renderer = canvas()->layoutObject(); |
| 977 if (!axObjectCache || !lbmo || !renderer) | 977 if (!axObjectCache || !lbmo || !renderer) |
| 978 return; | 978 return; |
| 979 | 979 |
| 980 // Get the transformed path. | 980 // Get the transformed path. |
| 981 Path transformedPath = path; | 981 Path transformedPath = path; |
| 982 transformedPath.transform(state().transform()); | 982 transformedPath.transform(state().transform()); |
| 983 | 983 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 | 1055 |
| 1056 unsigned CanvasRenderingContext2D::hitRegionsCount() const | 1056 unsigned CanvasRenderingContext2D::hitRegionsCount() const |
| 1057 { | 1057 { |
| 1058 if (m_hitRegionManager) | 1058 if (m_hitRegionManager) |
| 1059 return m_hitRegionManager->getHitRegionsCount(); | 1059 return m_hitRegionManager->getHitRegionsCount(); |
| 1060 | 1060 |
| 1061 return 0; | 1061 return 0; |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 } // namespace blink | 1064 } // namespace blink |
| OLD | NEW |