[Webkit-unassigned] [Bug 35486] canvas fillText with @font-face crashes

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jun 24 20:09:45 PDT 2010


--- Comment #3 from Robin Cao <robin.cao at torchmobile.com.cn>  2010-06-24 20:09:45 PST ---
This issue is a little tricky. Normally we get font objects from RenderStyle, and font objects get updated automatically after calling recalcStyle. But the font object in CanvasRenderingContext2D seems to be an exception, so it may become invalid at some point.

We can override recalcStyle() in HTMLCanvasElement, and update the font object from there if needed. The patch will look like this:

Index: WebCore/html/HTMLCanvasElement.h
+    virtual void recalcStyle(StyleChange);

Index: WebCore/html/HTMLCanvasElement.cpp
+void HTMLCanvasElement::recalcStyle(StyleChange change)
+    HTMLElement::recalcStyle(change);
+    // Update font if needed.
+    if (change == Force && m_context && m_context->is2d()) {
+        CanvasRenderingContext2D* ctx = static_cast<CanvasRenderingContext2D*>(m_context.get());
+        ctx->setFont(ctx->font());
+    }

Jakob, do you think this is a viable solution?

Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

More information about the webkit-unassigned mailing list