| Index: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
|
| diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
|
| index 0d09607222a5ee357bcdd1a7f2b296686a736620..57dc2017ba53dfcc12be6ce2242a0c5be90a55db 100644
|
| --- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
|
| +++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
|
| @@ -376,6 +376,10 @@ SkImageFilter* CanvasRenderingContext2D::stateGetFilter()
|
|
|
| void CanvasRenderingContext2D::snapshotStateForFilter()
|
| {
|
| + // The style resolution required for fonts is not available in frame-less documents.
|
| + if (!canvas()->document().frame())
|
| + return;
|
| +
|
| modifiableState().setFontForFilter(accessFont());
|
| }
|
|
|
| @@ -441,6 +445,10 @@ String CanvasRenderingContext2D::font() const
|
|
|
| void CanvasRenderingContext2D::setFont(const String& newFont)
|
| {
|
| + // The style resolution required for fonts is not available in frame-less documents.
|
| + if (!canvas()->document().frame())
|
| + return;
|
| +
|
| canvas()->document().updateStyleAndLayoutTreeForNode(canvas());
|
|
|
| // The following early exit is dependent on the cache not being empty
|
| @@ -721,6 +729,10 @@ TextMetrics* CanvasRenderingContext2D::measureText(const String& text)
|
| {
|
| TextMetrics* metrics = TextMetrics::create();
|
|
|
| + // The style resolution required for fonts is not available in frame-less documents.
|
| + if (!canvas()->document().frame())
|
| + return metrics;
|
| +
|
| canvas()->document().updateStyleAndLayoutTreeForNode(canvas());
|
| const Font& font = accessFont();
|
|
|
| @@ -762,6 +774,10 @@ TextMetrics* CanvasRenderingContext2D::measureText(const String& text)
|
|
|
| void CanvasRenderingContext2D::drawTextInternal(const String& text, double x, double y, CanvasRenderingContext2DState::PaintType paintType, double* maxWidth)
|
| {
|
| + // The style resolution required for fonts is not available in frame-less documents.
|
| + if (!canvas()->document().frame())
|
| + return;
|
| +
|
| // accessFont needs the style to be up to date, but updating style can cause script to run,
|
| // (e.g. due to autofocus) which can free the canvas (set size to 0, for example), so update
|
| // style before grabbing the drawingCanvas.
|
|
|