Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Unified Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp

Issue 2370283002: Revert of Rendering text to a canvas in a frame-less document. (Closed)
Patch Set: Manual patch revert. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698