Merge branch 'dev' of ssh://codereview.qt-project.org/qt/qtdeclarative into wip/v4
authorSimon Hausmann <simon.hausmann@digia.com>
Mon, 22 Jul 2013 11:43:43 +0000 (13:43 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Mon, 22 Jul 2013 11:43:43 +0000 (13:43 +0200)
Conflicts:
src/quick/items/context2d/qquickcontext2d.cpp
tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro

Change-Id: I36a4fd28b3156839aecd70039a3ba566bf19a0bc

17 files changed:
1  2 
src/imports/xmllistmodel/qqmlxmllistmodel.cpp
src/qml/qml/qqmlcomponent.cpp
src/qml/qml/qqmlengine.cpp
src/qml/qml/qqmlglobal.cpp
src/qml/qml/qqmlglobal_p.h
src/qml/types/qqmllistmodel.cpp
src/quick/items/context2d/qquickcanvasitem.cpp
src/quick/items/context2d/qquickcontext2d.cpp
src/quick/items/qquickflickable.cpp
src/quick/items/qquickitem.cpp
src/quick/items/qquickitem.h
src/quick/items/qquickitemview_p_p.h
src/quick/items/qquicktext.cpp
src/quick/items/qquickwindow.cpp
tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro
tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro
tests/auto/quick/touchmouse/touchmouse.pro

Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -791,17 -704,17 +915,17 @@@ QV4::Value QQuickJSContext2DPrototype::
  
      \image qml-item-canvas-math-rotate.png
  
-     where the \c angle of rotation is in radians.
+     where the \a angle of rotation is in radians.
  
  */
 -static v8::Handle<v8::Value> ctx2d_rotate(const v8::Arguments &args)
 +QV4::Value QQuickJSContext2DPrototype::method_rotate(QV4::SimpleCallContext *ctx)
  {
 -    QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
 +    QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
      CHECK_CONTEXT(r)
  
 -    if (args.Length() == 1)
 -        r->context->rotate(args[0]->NumberValue());
 -    return args.This();
 +    if (ctx->argumentCount == 1)
 +        r->context->rotate(ctx->arguments[0].toNumber());
 +    return ctx->thisObject;
  }
  
  /*!
      \code
      ctx.scale(2.0, 0.5);
      \endcode
-     \image qml-item-canvas-scale.png
  
+     \image qml-item-canvas-scale.png
  */
 -static v8::Handle<v8::Value> ctx2d_scale(const v8::Arguments &args)
 +QV4::Value QQuickJSContext2DPrototype::method_scale(QV4::SimpleCallContext *ctx)
  {
 -    QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
 +    QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
      CHECK_CONTEXT(r)
  
  
@@@ -945,44 -864,47 +1075,47 @@@ QV4::Value QQuickJSContext2DPrototype::
  
  
  /*!
-     \qmlmethod object QtQuick2::Context2D::shear(real sh, real sv )
-     Shear the transformation matrix with \a sh in horizontal direction and \a sv in vertical direction.
+     \qmlmethod object QtQuick2::Context2D::shear(real sh, real sv)
+     Shears the transformation matrix by \a sh in the horizontal direction and
+     \a sv in the vertical direction.
  */
 -static v8::Handle<v8::Value> ctx2d_shear(const v8::Arguments &args)
 +QV4::Value QQuickJSContext2DPrototype::method_shear(QV4::SimpleCallContext *ctx)
  {
 -    QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
 +    QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
      CHECK_CONTEXT(r)
  
 -    if (args.Length() == 2)
 -            r->context->shear(args[0]->NumberValue(), args[1]->NumberValue());
 +    if (ctx->argumentCount == 2)
 +            r->context->shear(ctx->arguments[0].toNumber(), ctx->arguments[1].toNumber());
  
 -    return args.This();
 +    return ctx->thisObject;
  }
  // compositing
  
  /*!
      \qmlproperty real QtQuick2::Context2D::globalAlpha
       Holds the current alpha value applied to rendering operations.
-      The value must be in the range from 0.0 (fully transparent) to 1.0 (fully opque).
-      The default value is 1.0.
+      The value must be in the range from \c 0.0 (fully transparent) to \c 1.0 (fully opaque).
+      The default value is \c 1.0.
  */
 -static v8::Handle<v8::Value> ctx2d_globalAlpha(v8::Local<v8::String>, const v8::AccessorInfo &info)
 +QV4::Value QQuickJSContext2D::method_get_globalAlpha(QV4::SimpleCallContext *ctx)
  {
 -    QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
 +    QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
      CHECK_CONTEXT(r)
  
 -    return v8::Number::New(r->context->state.globalAlpha);
 +    return QV4::Value::fromDouble(r->context->state.globalAlpha);
  }
  
 -static void ctx2d_globalAlpha_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
 +QV4::Value QQuickJSContext2D::method_set_globalAlpha(QV4::SimpleCallContext *ctx)
  {
 -    QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
 +    QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
      CHECK_CONTEXT_SETTER(r)
  
 -    qreal globalAlpha = value->NumberValue();
 +    double globalAlpha = ctx->argument(0).toNumber();
  
      if (!qIsFinite(globalAlpha))
 -        return;
 +        return QV4::Value::undefinedValue();
  
      if (globalAlpha >= 0.0 && globalAlpha <= 1.0 && r->context->state.globalAlpha != globalAlpha) {
          r->context->state.globalAlpha = globalAlpha;
@@@ -1826,33 -1764,46 +1959,46 @@@ QV4::Value QQuickJSContext2DPrototype::
  
  // Complex shapes (paths) API
  /*!
-   \qmlmethod object QtQuick2::Context2D::arc(real x, real y, real radius, real startAngle, real endAngle, bool anticlockwise)
-   Adds an arc to the current subpath that lies on the circumference of the circle whose center is at the point (\c x,\cy) and whose radius is \c radius.
-   \image qml-item-canvas-arcTo2.png
-   \sa arcTo,
-       {http://www.w3.org/TR/2dcontext/#dom-context-2d-arc}{W3C 2d context standard for arc}
-   */
+     \qmlmethod object QtQuick2::Context2D::arc(real x, real y, real radius,
+         real startAngle, real endAngle, bool anticlockwise)
+     Adds an arc to the current subpath that lies on the circumference of the
+     circle whose center is at the point (\a x, \a y) and whose radius is
+     \a radius.
+     Both \c startAngle and \c endAngle are measured from the x-axis in radians.
+     \image qml-item-canvas-arc.png
+     \image qml-item-canvas-startAngle.png
+     The \a anticlockwise parameter is \c true for each arc in the figure above
+     because they are all drawn in the anticlockwise direction.
+     \sa arcTo, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arc}{W3C's 2D
+     Context Standard for arc()}
+ */
 -static v8::Handle<v8::Value> ctx2d_arc(const v8::Arguments &args)
 +QV4::Value QQuickJSContext2DPrototype::method_arc(QV4::SimpleCallContext *ctx)
  {
 -    QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
 +    QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
      CHECK_CONTEXT(r)
  
 -    if (args.Length() >= 5) {
 +    if (ctx->argumentCount >= 5) {
          bool antiClockwise = false;
  
 -        if (args.Length() == 6)
 -            antiClockwise = args[5]->BooleanValue();
 +        if (ctx->argumentCount == 6)
 +            antiClockwise = ctx->arguments[5].toBoolean();
  
 -        qreal radius = args[2]->NumberValue();
 +        qreal radius = ctx->arguments[2].toNumber();
  
          if (qIsFinite(radius) && radius < 0)
 -           V8THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
 +           V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
  
 -        r->context->arc(args[0]->NumberValue(),
 -                        args[1]->NumberValue(),
 +        r->context->arc(ctx->arguments[0].toNumber(),
 +                        ctx->arguments[1].toNumber(),
                          radius,
 -                        args[3]->NumberValue(),
 -                        args[4]->NumberValue(),
 +                        ctx->arguments[3].toNumber(),
 +                        ctx->arguments[4].toNumber(),
                          antiClockwise);
      }
  
  }
  
  /*!
-   \qmlmethod object QtQuick2::Context2D::arcTo(real x1, real y1, real x2, real y2, real radius)
+     \qmlmethod object QtQuick2::Context2D::arcTo(real x1, real y1, real x2,
+         real y2, real radius)
+     Adds an arc with the given control points and radius to the current subpath,
+     connected to the previous point by a straight line. To draw an arc, you
+     begin with the same steps you followed to create a line:
  
-    Adds an arc with the given control points and radius to the current subpath, connected to the previous point by a straight line.
-    To draw an arc, you begin with the same steps your followed to create a line:
      \list
-     \li Call the context.beginPath() method to set a new path.
-     \li Call the context.moveTo(\c x, \c y) method to set your starting position on the canvas at the point (\c x,\c y).
-     \li To draw an arc or circle, call the context.arcTo(\c x1, \c y1, \c x2, \c y2,\c radius) method.
-        This adds an arc with starting point (\c x1,\c y1), ending point (\c x2, \c y2), and radius \c radius to the current subpath and connects
-        it to the previous subpath by a straight line.
+     \li Call the beginPath() method to set a new path.
+     \li Call the moveTo(\c x, \c y) method to set your starting position on the
+         canvas at the point (\c x, \c y).
+     \li To draw an arc or circle, call the arcTo(\a x1, \a y1, \a x2, \a y2,
+         \a radius) method. This adds an arc with starting point (\a x1, \a y1),
+         ending point (\a x2, \a y2), and \a radius to the current subpath and
+         connects it to the previous subpath by a straight line.
      \endlist
      \image qml-item-canvas-arcTo.png
-     Both startAngle and endAngle are measured from the x axis in units of radians.
  
-     \image qml-item-canvas-startAngle.png
-     The anticlockwise has the value TRUE for each arc in the figure above because they are all drawn in the counterclockwise direction.
-   \sa arc, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arcto}{W3C 2d
-       context standard for arcTo}
-   */
+     \sa arc, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arcto}{W3C's 2D
+     Context Standard for arcTo()}
+ */
 -static v8::Handle<v8::Value> ctx2d_arcTo(const v8::Arguments &args)
 +QV4::Value QQuickJSContext2DPrototype::method_arcTo(QV4::SimpleCallContext *ctx)
  {
 -    QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
 +    QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
      CHECK_CONTEXT(r)
  
 -    if (args.Length() == 5) {
 -        qreal radius = args[4]->NumberValue();
 +    if (ctx->argumentCount == 5) {
 +        qreal radius = ctx->arguments[4].toNumber();
  
          if (qIsFinite(radius) && radius < 0)
 -           V8THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
 +           V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
  
 -        r->context->arcTo(args[0]->NumberValue(),
 -                          args[1]->NumberValue(),
 -                          args[2]->NumberValue(),
 -                          args[3]->NumberValue(),
 +        r->context->arcTo(ctx->arguments[0].toNumber(),
 +                          ctx->arguments[1].toNumber(),
 +                          ctx->arguments[2].toNumber(),
 +                          ctx->arguments[3].toNumber(),
                            radius);
      }
  
@@@ -2207,54 -2162,72 +2356,69 @@@ QV4::Value QQuickJSContext2DPrototype::
      CHECK_CONTEXT(r)
  
      bool pointInPath = false;
 -    if (args.Length() == 2)
 -        pointInPath = r->context->isPointInPath(args[0]->NumberValue(), args[1]->NumberValue());
 -    return v8::Boolean::New(pointInPath);
 +    if (ctx->argumentCount == 2)
 +        pointInPath = r->context->isPointInPath(ctx->arguments[0].toNumber(), ctx->arguments[1].toNumber());
 +    return QV4::Value::fromBoolean(pointInPath);
  }
  
 -static v8::Handle<v8::Value> ctx2d_drawFocusRing(const v8::Arguments &args)
 +QV4::Value QQuickJSContext2DPrototype::method_drawFocusRing(QV4::SimpleCallContext *ctx)
  {
 -    Q_UNUSED(args);
 +    Q_UNUSED(ctx);
  
 -    V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::drawFocusRing is not supported");
 +    V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::drawFocusRing is not supported");
  }
  
 -static v8::Handle<v8::Value> ctx2d_setCaretSelectionRect(const v8::Arguments &args)
 +QV4::Value QQuickJSContext2DPrototype::method_setCaretSelectionRect(QV4::SimpleCallContext *ctx)
  {
 -    Q_UNUSED(args);
 +    Q_UNUSED(ctx);
  
 -    V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::setCaretSelectionRect is not supported");
 +    V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::setCaretSelectionRect is not supported");
  }
  
 -static v8::Handle<v8::Value> ctx2d_caretBlinkRate(const v8::Arguments &args)
 +QV4::Value QQuickJSContext2DPrototype::method_caretBlinkRate(QV4::SimpleCallContext *ctx)
  {
 -    Q_UNUSED(args);
 +    Q_UNUSED(ctx);
  
 -    V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::caretBlinkRate is not supported");
 +    V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::caretBlinkRate is not supported");
  }
- // text
  /*!
-   \qmlproperty string QtQuick2::Context2D::font
-   Holds the current font settings.
+     \qmlproperty string QtQuick2::Context2D::font
+     Holds the current font settings.
+     A subset of the
+     \l {http://www.w3.org/TR/2dcontext/#dom-context-2d-font}{w3C 2d context standard for font}
+     is supported:
+     \list
+         \li font-style (optional):
+         normal | italic | oblique
+         \li font-variant (optional): normal | small-caps
+         \li font-weight (optional): normal | bold | 0 ... 99
+         \li font-size: Npx | Npt (where N is a positive number)
+         \li font-family: See \l {http://www.w3.org/TR/CSS2/fonts.html#propdef-font-family}
+     \endlist
  
-   The default font value is "10px sans-serif".
-   See \l {http://www.w3.org/TR/2dcontext/#dom-context-2d-font}{w3C 2d context standard for font}
+     Note that font-size and font-family are mandatory and must be in the order
+     they are shown in above.
+     The default font value is "10px sans-serif".
    */
 -v8::Handle<v8::Value> ctx2d_font(v8::Local<v8::String>, const v8::AccessorInfo &info)
 +QV4::Value QQuickJSContext2D::method_get_font(QV4::SimpleCallContext *ctx)
  {
 -    QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
 +    QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
      CHECK_CONTEXT(r)
  
 -    QV8Engine *engine = V8ENGINE_ACCESSOR();
 -
 -    return engine->toString(r->context->state.font.toString());
 +    return QV4::Value::fromString(ctx->engine->newString(r->context->state.font.toString()));
  }
  
 -static void ctx2d_font_set(v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)
 +QV4::Value QQuickJSContext2D::method_set_font(QV4::SimpleCallContext *ctx)
  {
 -    QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(info.This());
 +    QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
      CHECK_CONTEXT_SETTER(r)
  
 -    QV8Engine *engine = V8ENGINE_ACCESSOR();
 -    QString fs = engine->toString(value);
 +    QString fs = ctx->argument(0).toQString();
-     QFont font = qt_font_from_string(fs);
+     QFont font = qt_font_from_string(fs, r->context->state.font);
      if (font != r->context->state.font) {
          r->context->state.font = font;
      }
@@@ -2782,48 -2739,55 +2946,53 @@@ void QQuickJSContext2DPixelData::putInd
              break;
          }
      }
 -    return v8::Undefined();
  }
  /*!
-   \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(real sw, real sh)
-    Creates a CanvasImageData object with the given dimensions(\a sw, \a sh).
-   */
+     \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(real sw, real sh)
+     Creates a CanvasImageData object with the given dimensions(\a sw, \a sh).
+ */
  /*!
-   \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(CanvasImageData imageData)
-    Creates a CanvasImageData object with the same dimensions as the argument.
-   */
+     \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(CanvasImageData imageData)
+     Creates a CanvasImageData object with the same dimensions as the argument.
+ */
  /*!
-   \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(Url imageUrl)
-    Creates a CanvasImageData object with the given image loaded from \a imageUrl.
-    Note:The \a imageUrl must be already loaded before this function call, if not, an empty
-    CanvasImageData obect will be returned.
+     \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(Url imageUrl)
+     Creates a CanvasImageData object with the given image loaded from \a imageUrl.
+     \note The \a imageUrl must be already loaded before this function call,
+     otherwise an empty CanvasImageData obect will be returned.
  
-    \sa Canvas::loadImage(), QtQuick2::Canvas::unloadImage(), QtQuick2::Canvas::isImageLoaded
+     \sa Canvas::loadImage(), QtQuick2::Canvas::unloadImage(),
+         QtQuick2::Canvas::isImageLoaded
    */
 -static v8::Handle<v8::Value> ctx2d_createImageData(const v8::Arguments &args)
 +QV4::Value QQuickJSContext2DPrototype::method_createImageData(QV4::SimpleCallContext *ctx)
  {
 -    QV8Context2DResource *r = v8_resource_cast<QV8Context2DResource>(args.This());
 +    QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
      CHECK_CONTEXT(r)
  
 -    QV8Engine *engine = V8ENGINE();
 +    QV8Engine *engine = ctx->engine->v8Engine;
  
 -    if (args.Length() == 1) {
 -        if (args[0]->IsObject()) {
 -            v8::Local<v8::Object> imgData = args[0]->ToObject();
 -            QV8Context2DPixelArrayResource *pa = v8_resource_cast<QV8Context2DPixelArrayResource>(imgData->GetInternalField(0)->ToObject());
 +    if (ctx->argumentCount == 1) {
 +        if (QQuickJSContext2DImageData *imgData = ctx->arguments[0].as<QQuickJSContext2DImageData>()) {
 +            QQuickJSContext2DPixelData *pa = imgData->pixelData.as<QQuickJSContext2DPixelData>();
              if (pa) {
 -                qreal w = imgData->Get(v8::String::New("width"))->NumberValue();
 -                qreal h = imgData->Get(v8::String::New("height"))->NumberValue();
 +                qreal w = pa->image.width();
 +                qreal h = pa->image.height();
                  return qt_create_image_data(w, h, engine, QImage());
              }
 -        } else if (args[0]->IsString()) {
 -            QImage image = r->context->createPixmap(QUrl(engine->toString(args[0]->ToString())))->image();
 +        } else if (ctx->arguments[0].isString()) {
 +            QImage image = r->context->createPixmap(QUrl(ctx->arguments[0].toQString()))->image();
              return qt_create_image_data(image.width(), image.height(), engine, image);
          }
 -    } else if (args.Length() == 2) {
 -        qreal w = args[0]->NumberValue();
 -        qreal h = args[1]->NumberValue();
 +    } else if (ctx->argumentCount == 2) {
 +        qreal w = ctx->arguments[0].toNumber();
 +        qreal h = ctx->arguments[1].toNumber();
  
          if (!qIsFinite(w) || !qIsFinite(h))
 -            V8THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createImageData(): invalid arguments");
 +            V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createImageData(): invalid arguments");
  
          if (w > 0 && h > 0)
              return qt_create_image_data(w, h, engine, QImage());
Simple merge
Simple merge
@@@ -320,11 -320,11 +320,11 @@@ public
  
      void polish();
  
 -    Q_INVOKABLE void mapFromItem(QQmlV8Function*) const;
 -    Q_INVOKABLE void mapToItem(QQmlV8Function*) const;
 +    Q_INVOKABLE void mapFromItem(QQmlV4Function*) const;
 +    Q_INVOKABLE void mapToItem(QQmlV4Function*) const;
      Q_INVOKABLE void forceActiveFocus();
      Q_INVOKABLE void forceActiveFocus(Qt::FocusReason reason);
-     Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);
+     Q_REVISION(1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);
      Q_INVOKABLE QQuickItem *childAt(qreal x, qreal y) const;
  
  #ifndef QT_NO_IM
Simple merge
Simple merge
Simple merge
@@@ -9,8 -9,6 +9,6 @@@ include (../shared/util.pri
  
  TESTDATA = data/*
  
- CONFIG += parallel_test
- QT += core-private gui-private  qml-private quick-private testlib
 -QT += core-private gui-private v8-private qml-private quick-private testlib
++QT += core-private gui-private qml-private quick-private testlib
  qtHaveModule(widgets): QT += widgets
  DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
@@@ -10,5 -10,8 +10,8 @@@ TESTDATA = data/
  
  CONFIG += parallel_test
  
 -QT += core-private gui-private v8-private qml-private network testlib xmlpatterns
 +QT += core-private gui-private  qml-private network testlib xmlpatterns
  DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+ OTHER_FILES += \
+     data/groups.qml