Browse files

Merge branch 'master' of git://github.com/appcelerator/titanium_mobil…

…e into timob-7416
  • Loading branch information...
2 parents 72b4670 + d696d9c commit 3ce2498c674167b4ac2c6f9663dc513264f735cd @pingwang2011 pingwang2011 committed Feb 4, 2012
View
2 android/runtime/v8/src/native/JavaObject.cpp
@@ -108,7 +108,7 @@ void JavaObject::deleteGlobalRef()
// Clear from the global object list
if (objectMap) {
jobject longObject = env->NewObject(JNIUtil::longClass, JNIUtil::longInitMethod, (jlong) this);
- env->CallObjectMethod(objectMap, JNIUtil::hashMapRemoveMethod, (jint) refIndex);
+ env->CallObjectMethod(objectMap, JNIUtil::hashMapRemoveMethod, longObject);
env->DeleteLocalRef(longObject);
}
}
View
100 android/runtime/v8/src/native/modules/ScriptsModule.cpp
@@ -21,39 +21,30 @@ namespace titanium {
using namespace v8;
Persistent<FunctionTemplate> WrappedScript::constructor_template;
-Persistent<FunctionTemplate> WrappedContext::constructor_template;
+Persistent<ObjectTemplate> WrappedContext::global_template;
void WrappedContext::Initialize(Handle<Object> target)
{
HandleScope scope;
- constructor_template = Persistent<FunctionTemplate>::New(FunctionTemplate::New(WrappedContext::New));
- constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
- constructor_template->SetClassName(String::NewSymbol("Context"));
-
- target->Set(String::NewSymbol("Context"), constructor_template->GetFunction());
+ global_template = Persistent<ObjectTemplate>::New(ObjectTemplate::New());
+ global_template->SetInternalFieldCount(1);
}
-Handle<Value> WrappedContext::New(const Arguments& args)
+WrappedContext* WrappedContext::Unwrap(Handle<Object> global)
{
HandleScope scope;
-
- WrappedContext *t = new WrappedContext();
- t->Wrap(args.This());
-
- return args.This();
-}
-
-WrappedContext::WrappedContext()
- : NativeObject()
-{
- context_ = Context::New();
+ return NativeObject::Unwrap<WrappedContext>(global->GetPrototype().As<Object>());
}
WrappedContext::WrappedContext(Persistent<Context> context)
- : NativeObject()
+ : context_(context)
{
- context_ = context;
+ HandleScope scope;
+
+ Local<Object> globalProxy = context->Global();
+ Local<Object> global = globalProxy->GetPrototype().As<Object>();
+ Wrap(global);
}
WrappedContext::~WrappedContext()
@@ -64,12 +55,6 @@ WrappedContext::~WrappedContext()
}
}
-Local<Object> WrappedContext::NewInstance()
-{
- Local<Object> context = constructor_template->GetFunction()->NewInstance();
- return context;
-}
-
Persistent<Context> WrappedContext::GetV8Context()
{
return context_;
@@ -85,15 +70,6 @@ void WrappedContext::SetInitCallback(Persistent<Function> initCallback)
initCallback_ = initCallback;
}
-Handle<Object> WrappedContext::WrapContext(Persistent<Context> context)
-{
- HandleScope scope;
- WrappedContext *t = new WrappedContext(context);
- Local<Object> wrappedContext = WrappedContext::NewInstance();
- t->Wrap(wrappedContext);
- return scope.Close(wrappedContext);
-}
-
void WrappedScript::Initialize(Handle<Object> target)
{
HandleScope scope;
@@ -135,9 +111,15 @@ WrappedScript::~WrappedScript()
Handle<Value> WrappedScript::CreateContext(const Arguments& args)
{
HandleScope scope;
- Local<Object> context = WrappedContext::NewInstance();
- WrappedContext *wrappedContext = NativeObject::Unwrap<WrappedContext>(context);
+ Persistent<Context> context = Context::New(NULL, WrappedContext::global_template);
+ WrappedContext *wrappedContext = new WrappedContext(context);
+ Local<Object> global = context->Global();
+
+ // Allow current context access to newly created context's objects.
+ context->SetSecurityToken(Context::GetCurrent()->GetSecurityToken());
+
+ // If a sandbox is provided initial the new context's global with it.
if (args.Length() > 0) {
Local<Object> sandbox = args[0]->ToObject();
Local<Array> keys = sandbox->GetPropertyNames();
@@ -146,20 +128,17 @@ Handle<Value> WrappedScript::CreateContext(const Arguments& args)
Handle<String> key = keys->Get(Integer::New(i))->ToString();
Handle<Value> value = sandbox->Get(key);
if (value == sandbox) {
- value = context;
+ value = global;
}
- context->Set(key, value);
+ global->Set(key, value);
}
if (args.Length() > 1 && args[1]->IsFunction()) {
wrappedContext->SetInitCallback(Persistent<Function>::New(Handle<Function>::Cast(args[1])));
}
}
- wrappedContext->GetV8Context()->SetSecurityToken(
- Context::GetCurrent()->GetSecurityToken());
-
- return scope.Close(context);
+ return scope.Close(global);
}
Handle<Value> WrappedScript::RunInContext(const Arguments& args)
@@ -247,7 +226,7 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args)
} else if (context_flag == userContext) {
// Use the passed in context
contextArg = args[sandbox_index]->ToObject();
- nContext = NativeObject::Unwrap<WrappedContext>(contextArg);
+ nContext = WrappedContext::Unwrap(contextArg);
context = nContext->GetV8Context();
}
@@ -265,19 +244,6 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args)
initCallback->Call(contextArg, 2, callbackArgs);
}
}
-
- // Copy everything from the passed in sandbox (either the persistent
- // context for runInContext(), or the sandbox arg to runInNewContext()).
- keys = sandbox->GetPropertyNames();
-
- for (i = 0; i < keys->Length(); i++) {
- Handle<String> key = keys->Get(Integer::New(i))->ToString();
- Handle<Value> value = sandbox->Get(key);
- if (value == sandbox) {
- value = context->Global();
- }
- context->Global()->Set(key, value);
- }
}
Handle<Value> result;
@@ -322,19 +288,6 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args)
result = args.This();
}
- if (context_flag == userContext || context_flag == newContext) {
- // success! copy changes back onto the sandbox object.
- keys = context->Global()->GetPropertyNames();
- for (i = 0; i < keys->Length(); i++) {
- Handle<String> key = keys->Get(Integer::New(i))->ToString();
- Handle<Value> value = context->Global()->Get(key);
- if (value == context->Global()) {
- value = sandbox;
- }
- sandbox->Set(key, value);
- }
- }
-
if (context_flag == newContext) {
// Clean up, clean up, everybody everywhere!
context->DetachGlobal();
@@ -362,12 +315,7 @@ void ScriptsModule::Initialize(Handle<Object> target)
void ScriptsModule::Dispose()
{
WrappedScript::constructor_template.Dispose();
- WrappedContext::constructor_template.Dispose();
-}
-
-Handle<Object> ScriptsModule::WrapContext(Persistent<Context> context)
-{
- return WrappedContext::WrapContext(context);
+ WrappedContext::global_template.Dispose();
}
}
View
16 android/runtime/v8/src/native/modules/ScriptsModule.h
@@ -17,29 +17,25 @@ class ScriptsModule
public:
static void Initialize(v8::Handle<v8::Object> target);
static void Dispose();
-
- static v8::Handle<v8::Object> WrapContext(v8::Persistent<v8::Context> context);
};
class WrappedContext: NativeObject
{
public:
+ WrappedContext(v8::Persistent<v8::Context> context);
+
static void Initialize(v8::Handle<v8::Object> target);
- static v8::Handle<v8::Value> New(const v8::Arguments& args);
+
+ // Unwrap a context from the given global proxy object.
+ static WrappedContext* Unwrap(v8::Handle<v8::Object> global);
v8::Persistent<v8::Context> GetV8Context();
v8::Persistent<v8::Function> GetInitCallback();
void SetInitCallback(v8::Persistent<v8::Function> initCallback);
- static v8::Local<v8::Object> NewInstance();
- static v8::Handle<v8::Object> WrapContext(v8::Persistent<v8::Context> context);
-
- static v8::Persistent<v8::FunctionTemplate> constructor_template;
+ static v8::Persistent<v8::ObjectTemplate> global_template;
protected:
-
- WrappedContext();
- WrappedContext(v8::Persistent<v8::Context> context);
virtual ~WrappedContext();
v8::Persistent<v8::Context> context_;
View
8 iphone/Classes/TiUIScrollableView.m
@@ -220,6 +220,12 @@ -(void)refreshScrollView:(CGRect)visibleBounds readd:(BOOL)readd
}
int viewsCount = [[self proxy] viewCount];
+ /*
+ Reset readd here since refreshScrollView is called from
+ frameSizeChanged with readd false and the views might
+ not yet have been added on first launch
+ */
+ readd = ([[sv subviews] count] == 0);
for (int c=0;c<viewsCount;c++)
{
@@ -275,7 +281,7 @@ -(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)visibleBounds
{
if (!CGRectIsEmpty(visibleBounds))
{
- [self refreshScrollView:visibleBounds readd:YES];
+ [self refreshScrollView:visibleBounds readd:NO];
[scrollview setContentOffset:CGPointMake(lastPage*visibleBounds.size.width,0)];
[self manageCache:[self currentPage]];
}
View
17 iphone/Classes/TiUITableView.m
@@ -867,8 +867,21 @@ - (void)triggerActionForIndexPath:(NSIndexPath *)indexPath
[target fireEvent:name withObject:eventObject];
}
- if (viaSearch && hideOnSearch) {
- [self hideSearchScreen:nil];
+ if (viaSearch) {
+ if (hideOnSearch) {
+ [self hideSearchScreen:nil];
+ }
+ else {
+ /*
+ TIMOB-7397. Observed that `searchBarTextDidBeginEditing` delegate
+ method was being called on screen transition which was causing a
+ visual glitch. Checking for isFirstResponder at this point always
+ returns false. Calling blur here so that the UISearchBar resigns
+ as first responder on main thread
+ */
+ [searchField performSelector:@selector(blur:) withObject:nil];
+ }
+
}
}
View
3 mobileweb/src/Ti/Network/HTTPClient.js
@@ -28,9 +28,8 @@ define("Ti/Network/HTTPClient", ["Ti/_", "Ti/_/declare", "Ti/_/lang", "Ti/_/Even
this._completed = 1;
c.readyState = this.DONE;
if (xhr.status == 200) {
- c.responseText = xhr.responseText;
+ c.responseText = c.responseData = xhr.responseText;
c.responseXML = xhr.responseXML;
- c.responseData = xhr.responseHeader;
is(this.onload, "Function") && this.onload.call(this);
} else {
xhr.status / 100 | 0 > 3 && this._onError();
View
55 mobileweb/src/Ti/UI/View.js
@@ -35,40 +35,48 @@ define("Ti/UI/View",
view._parent = this;
this.containerNode.insertBefore(view.domNode,this.children[index].domNode);
this.children.splice(index,0,view);
- this._triggerLayout();
+ this._triggerLayout();
}
},
remove: function(view) {
- var i = 0,
- l = this.children.length;
- for (; i < l; i++) {
- if (this.children[i] === view) {
- l = this.children.splice(i, 1);
- l[0]._setParent();
- break;
+ var p = this.children.indexOf(view);
+ if (p !== -1) {
+ this.children.splice(p, 1);
+ view._setParent();
+ dom.detach(view.domNode);
+ this._triggerLayout();
+ }
+ },
+
+ destroy: function() {
+ if (!this._destroyed) {
+ var c;
+ while (this.children.length) {
+ c = this.children.splice(0, 1);
+ c[0].destroy();
}
+ this._parent && this._parent.remove(this);
+ Element.prototype.destroy.apply(this, arguments);
}
- dom.detach(view.domNode);
- this._triggerLayout();
},
-
+
_removeAllChildren: function(view) {
var children = this.children;
- while(children.length > 0) {
+ while (children.length) {
this.remove(children[0]);
}
this._triggerLayout();
},
-
+
_getScrollableContentWidth: function() {
return 600;
},
-
+
_getScrollablePosition: function() {
return {x: 0, y: 0};
},
-
+
_createHorizontalScrollBar: function() {
var scrollBar = this._horizontalScrollBar = dom.create("div", {
className: "TiUIScrollBar",
@@ -83,12 +91,12 @@ define("Ti/UI/View",
}
}, this.domNode);
},
-
+
_destroyHorizontalScrollBar: function() {
this._cancelPreviousAnimation();
dom.destroy(this._horizontalScrollBar);
},
-
+
_createVerticalScrollBar: function() {
var scrollBar = this._verticalScrollBar = dom.create("div", {
className: "TiUIScrollBar",
@@ -210,19 +218,6 @@ define("Ti/UI/View",
}
},
- destroy: function() {
- if (!this._destroyed) {
- var i = 0,
- l = this.children.length;
- for (; i < l; i++) {
- this.children[i].destroy();
- this.children[i] = null;
- }
- this.children = null;
- Element.prototype.destroy.apply(this, arguments);
- }
- },
-
_defaultWidth: "100%",
_defaultHeight: "100%",
View
4 mobileweb/src/titanium.css
@@ -118,10 +118,6 @@ textarea {
background-color: gray;
}
-.TiMediaVideoPlayer {
- position: relative;
-}
-
.TiMediaVideoPlayer video {
left: 0;
position: absolute;

0 comments on commit 3ce2498

Please sign in to comment.