Commit dcb20b16 authored by sigbjornf@opera.com's avatar sigbjornf@opera.com

Keep TextMetrics on the Oilpan heap always.

R=haraken
BUG=340522

Review URL: https://codereview.chromium.org/1297383003

git-svn-id: svn://svn.chromium.org/blink/trunk@200969 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c271b718
......@@ -29,15 +29,16 @@
#include "bindings/core/v8/ScriptWrappable.h"
#include "core/CoreExport.h"
#include "platform/heap/Handle.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
namespace blink {
class CORE_EXPORT TextMetrics final : public RefCountedWillBeGarbageCollected<TextMetrics>, public ScriptWrappable {
class CORE_EXPORT TextMetrics final : public GarbageCollected<TextMetrics>, public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
static PassRefPtrWillBeRawPtr<TextMetrics> create() { return adoptRefWillBeNoop(new TextMetrics); }
static TextMetrics* create()
{
return new TextMetrics;
}
float width() const { return m_width; }
void setWidth(float w) { m_width = w; }
......
......@@ -28,7 +28,7 @@
// TODO(philipj): All float types in this interface should be double.
[
// TODO(philipj): Exposed=(Window,Worker)
WillBeGarbageCollected,
GarbageCollected,
] interface TextMetrics {
// x-direction
readonly attribute float width; // advance width
......
......@@ -1893,13 +1893,13 @@ void CanvasRenderingContext2D::strokeText(const String& text, float x, float y,
drawTextInternal(text, x, y, CanvasRenderingContext2DState::StrokePaintType, &maxWidth);
}
PassRefPtrWillBeRawPtr<TextMetrics> CanvasRenderingContext2D::measureText(const String& text)
TextMetrics* CanvasRenderingContext2D::measureText(const String& text)
{
RefPtrWillBeRawPtr<TextMetrics> metrics = TextMetrics::create();
TextMetrics* metrics = TextMetrics::create();
// The style resolution required for rendering text is not available in frame-less documents.
if (!canvas()->document().frame())
return metrics.release();
return metrics;
canvas()->document().updateLayoutTreeForNodeIfNeeded(canvas());
const Font& font = accessFont();
......@@ -1937,7 +1937,7 @@ PassRefPtrWillBeRawPtr<TextMetrics> CanvasRenderingContext2D::measureText(const
metrics->setHangingBaseline(-0.8f * ascent + baselineY);
metrics->setAlphabeticBaseline(baselineY);
metrics->setIdeographicBaseline(descent + baselineY);
return metrics.release();
return metrics;
}
void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, CanvasRenderingContext2DState::PaintType paintType, float* maxWidth)
......
......@@ -197,7 +197,7 @@ public:
void fillText(const String& text, float x, float y, float maxWidth);
void strokeText(const String& text, float x, float y);
void strokeText(const String& text, float x, float y, float maxWidth);
PassRefPtrWillBeRawPtr<TextMetrics> measureText(const String& text);
TextMetrics* measureText(const String& text);
bool imageSmoothingEnabled() const;
void setImageSmoothingEnabled(bool);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment