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