Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…e into timob-7416
  • Loading branch information...
commit 3ce2498c674167b4ac2c6f9663dc513264f735cd 2 parents 72b4670 + d696d9c
pingwang2011 pingwang2011 authored
2  android/runtime/v8/src/native/JavaObject.cpp
@@ -108,7 +108,7 @@ void JavaObject::deleteGlobalRef()
108 108 // Clear from the global object list
109 109 if (objectMap) {
110 110 jobject longObject = env->NewObject(JNIUtil::longClass, JNIUtil::longInitMethod, (jlong) this);
111   - env->CallObjectMethod(objectMap, JNIUtil::hashMapRemoveMethod, (jint) refIndex);
  111 + env->CallObjectMethod(objectMap, JNIUtil::hashMapRemoveMethod, longObject);
112 112 env->DeleteLocalRef(longObject);
113 113 }
114 114 }
100 android/runtime/v8/src/native/modules/ScriptsModule.cpp
@@ -21,39 +21,30 @@ namespace titanium {
21 21 using namespace v8;
22 22
23 23 Persistent<FunctionTemplate> WrappedScript::constructor_template;
24   -Persistent<FunctionTemplate> WrappedContext::constructor_template;
  24 +Persistent<ObjectTemplate> WrappedContext::global_template;
25 25
26 26 void WrappedContext::Initialize(Handle<Object> target)
27 27 {
28 28 HandleScope scope;
29 29
30   - constructor_template = Persistent<FunctionTemplate>::New(FunctionTemplate::New(WrappedContext::New));
31   - constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
32   - constructor_template->SetClassName(String::NewSymbol("Context"));
33   -
34   - target->Set(String::NewSymbol("Context"), constructor_template->GetFunction());
  30 + global_template = Persistent<ObjectTemplate>::New(ObjectTemplate::New());
  31 + global_template->SetInternalFieldCount(1);
35 32 }
36 33
37   -Handle<Value> WrappedContext::New(const Arguments& args)
  34 +WrappedContext* WrappedContext::Unwrap(Handle<Object> global)
38 35 {
39 36 HandleScope scope;
40   -
41   - WrappedContext *t = new WrappedContext();
42   - t->Wrap(args.This());
43   -
44   - return args.This();
45   -}
46   -
47   -WrappedContext::WrappedContext()
48   - : NativeObject()
49   -{
50   - context_ = Context::New();
  37 + return NativeObject::Unwrap<WrappedContext>(global->GetPrototype().As<Object>());
51 38 }
52 39
53 40 WrappedContext::WrappedContext(Persistent<Context> context)
54   - : NativeObject()
  41 + : context_(context)
55 42 {
56   - context_ = context;
  43 + HandleScope scope;
  44 +
  45 + Local<Object> globalProxy = context->Global();
  46 + Local<Object> global = globalProxy->GetPrototype().As<Object>();
  47 + Wrap(global);
57 48 }
58 49
59 50 WrappedContext::~WrappedContext()
@@ -64,12 +55,6 @@ WrappedContext::~WrappedContext()
64 55 }
65 56 }
66 57
67   -Local<Object> WrappedContext::NewInstance()
68   -{
69   - Local<Object> context = constructor_template->GetFunction()->NewInstance();
70   - return context;
71   -}
72   -
73 58 Persistent<Context> WrappedContext::GetV8Context()
74 59 {
75 60 return context_;
@@ -85,15 +70,6 @@ void WrappedContext::SetInitCallback(Persistent<Function> initCallback)
85 70 initCallback_ = initCallback;
86 71 }
87 72
88   -Handle<Object> WrappedContext::WrapContext(Persistent<Context> context)
89   -{
90   - HandleScope scope;
91   - WrappedContext *t = new WrappedContext(context);
92   - Local<Object> wrappedContext = WrappedContext::NewInstance();
93   - t->Wrap(wrappedContext);
94   - return scope.Close(wrappedContext);
95   -}
96   -
97 73 void WrappedScript::Initialize(Handle<Object> target)
98 74 {
99 75 HandleScope scope;
@@ -135,9 +111,15 @@ WrappedScript::~WrappedScript()
135 111 Handle<Value> WrappedScript::CreateContext(const Arguments& args)
136 112 {
137 113 HandleScope scope;
138   - Local<Object> context = WrappedContext::NewInstance();
139   - WrappedContext *wrappedContext = NativeObject::Unwrap<WrappedContext>(context);
140 114
  115 + Persistent<Context> context = Context::New(NULL, WrappedContext::global_template);
  116 + WrappedContext *wrappedContext = new WrappedContext(context);
  117 + Local<Object> global = context->Global();
  118 +
  119 + // Allow current context access to newly created context's objects.
  120 + context->SetSecurityToken(Context::GetCurrent()->GetSecurityToken());
  121 +
  122 + // If a sandbox is provided initial the new context's global with it.
141 123 if (args.Length() > 0) {
142 124 Local<Object> sandbox = args[0]->ToObject();
143 125 Local<Array> keys = sandbox->GetPropertyNames();
@@ -146,9 +128,9 @@ Handle<Value> WrappedScript::CreateContext(const Arguments& args)
146 128 Handle<String> key = keys->Get(Integer::New(i))->ToString();
147 129 Handle<Value> value = sandbox->Get(key);
148 130 if (value == sandbox) {
149   - value = context;
  131 + value = global;
150 132 }
151   - context->Set(key, value);
  133 + global->Set(key, value);
152 134 }
153 135
154 136 if (args.Length() > 1 && args[1]->IsFunction()) {
@@ -156,10 +138,7 @@ Handle<Value> WrappedScript::CreateContext(const Arguments& args)
156 138 }
157 139 }
158 140
159   - wrappedContext->GetV8Context()->SetSecurityToken(
160   - Context::GetCurrent()->GetSecurityToken());
161   -
162   - return scope.Close(context);
  141 + return scope.Close(global);
163 142 }
164 143
165 144 Handle<Value> WrappedScript::RunInContext(const Arguments& args)
@@ -247,7 +226,7 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args)
247 226 } else if (context_flag == userContext) {
248 227 // Use the passed in context
249 228 contextArg = args[sandbox_index]->ToObject();
250   - nContext = NativeObject::Unwrap<WrappedContext>(contextArg);
  229 + nContext = WrappedContext::Unwrap(contextArg);
251 230 context = nContext->GetV8Context();
252 231 }
253 232
@@ -265,19 +244,6 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args)
265 244 initCallback->Call(contextArg, 2, callbackArgs);
266 245 }
267 246 }
268   -
269   - // Copy everything from the passed in sandbox (either the persistent
270   - // context for runInContext(), or the sandbox arg to runInNewContext()).
271   - keys = sandbox->GetPropertyNames();
272   -
273   - for (i = 0; i < keys->Length(); i++) {
274   - Handle<String> key = keys->Get(Integer::New(i))->ToString();
275   - Handle<Value> value = sandbox->Get(key);
276   - if (value == sandbox) {
277   - value = context->Global();
278   - }
279   - context->Global()->Set(key, value);
280   - }
281 247 }
282 248
283 249 Handle<Value> result;
@@ -322,19 +288,6 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args)
322 288 result = args.This();
323 289 }
324 290
325   - if (context_flag == userContext || context_flag == newContext) {
326   - // success! copy changes back onto the sandbox object.
327   - keys = context->Global()->GetPropertyNames();
328   - for (i = 0; i < keys->Length(); i++) {
329   - Handle<String> key = keys->Get(Integer::New(i))->ToString();
330   - Handle<Value> value = context->Global()->Get(key);
331   - if (value == context->Global()) {
332   - value = sandbox;
333   - }
334   - sandbox->Set(key, value);
335   - }
336   - }
337   -
338 291 if (context_flag == newContext) {
339 292 // Clean up, clean up, everybody everywhere!
340 293 context->DetachGlobal();
@@ -362,12 +315,7 @@ void ScriptsModule::Initialize(Handle<Object> target)
362 315 void ScriptsModule::Dispose()
363 316 {
364 317 WrappedScript::constructor_template.Dispose();
365   - WrappedContext::constructor_template.Dispose();
366   -}
367   -
368   -Handle<Object> ScriptsModule::WrapContext(Persistent<Context> context)
369   -{
370   - return WrappedContext::WrapContext(context);
  318 + WrappedContext::global_template.Dispose();
371 319 }
372 320
373 321 }
16 android/runtime/v8/src/native/modules/ScriptsModule.h
@@ -17,29 +17,25 @@ class ScriptsModule
17 17 public:
18 18 static void Initialize(v8::Handle<v8::Object> target);
19 19 static void Dispose();
20   -
21   - static v8::Handle<v8::Object> WrapContext(v8::Persistent<v8::Context> context);
22 20 };
23 21
24 22 class WrappedContext: NativeObject
25 23 {
26 24 public:
  25 + WrappedContext(v8::Persistent<v8::Context> context);
  26 +
27 27 static void Initialize(v8::Handle<v8::Object> target);
28   - static v8::Handle<v8::Value> New(const v8::Arguments& args);
  28 +
  29 + // Unwrap a context from the given global proxy object.
  30 + static WrappedContext* Unwrap(v8::Handle<v8::Object> global);
29 31
30 32 v8::Persistent<v8::Context> GetV8Context();
31 33 v8::Persistent<v8::Function> GetInitCallback();
32 34 void SetInitCallback(v8::Persistent<v8::Function> initCallback);
33 35
34   - static v8::Local<v8::Object> NewInstance();
35   - static v8::Handle<v8::Object> WrapContext(v8::Persistent<v8::Context> context);
36   -
37   - static v8::Persistent<v8::FunctionTemplate> constructor_template;
  36 + static v8::Persistent<v8::ObjectTemplate> global_template;
38 37
39 38 protected:
40   -
41   - WrappedContext();
42   - WrappedContext(v8::Persistent<v8::Context> context);
43 39 virtual ~WrappedContext();
44 40
45 41 v8::Persistent<v8::Context> context_;
8 iphone/Classes/TiUIScrollableView.m
@@ -220,6 +220,12 @@ -(void)refreshScrollView:(CGRect)visibleBounds readd:(BOOL)readd
220 220 }
221 221
222 222 int viewsCount = [[self proxy] viewCount];
  223 + /*
  224 + Reset readd here since refreshScrollView is called from
  225 + frameSizeChanged with readd false and the views might
  226 + not yet have been added on first launch
  227 + */
  228 + readd = ([[sv subviews] count] == 0);
223 229
224 230 for (int c=0;c<viewsCount;c++)
225 231 {
@@ -275,7 +281,7 @@ -(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)visibleBounds
275 281 {
276 282 if (!CGRectIsEmpty(visibleBounds))
277 283 {
278   - [self refreshScrollView:visibleBounds readd:YES];
  284 + [self refreshScrollView:visibleBounds readd:NO];
279 285 [scrollview setContentOffset:CGPointMake(lastPage*visibleBounds.size.width,0)];
280 286 [self manageCache:[self currentPage]];
281 287 }
17 iphone/Classes/TiUITableView.m
@@ -867,8 +867,21 @@ - (void)triggerActionForIndexPath:(NSIndexPath *)indexPath
867 867 [target fireEvent:name withObject:eventObject];
868 868 }
869 869
870   - if (viaSearch && hideOnSearch) {
871   - [self hideSearchScreen:nil];
  870 + if (viaSearch) {
  871 + if (hideOnSearch) {
  872 + [self hideSearchScreen:nil];
  873 + }
  874 + else {
  875 + /*
  876 + TIMOB-7397. Observed that `searchBarTextDidBeginEditing` delegate
  877 + method was being called on screen transition which was causing a
  878 + visual glitch. Checking for isFirstResponder at this point always
  879 + returns false. Calling blur here so that the UISearchBar resigns
  880 + as first responder on main thread
  881 + */
  882 + [searchField performSelector:@selector(blur:) withObject:nil];
  883 + }
  884 +
872 885 }
873 886 }
874 887
3  mobileweb/src/Ti/Network/HTTPClient.js
@@ -28,9 +28,8 @@ define("Ti/Network/HTTPClient", ["Ti/_", "Ti/_/declare", "Ti/_/lang", "Ti/_/Even
28 28 this._completed = 1;
29 29 c.readyState = this.DONE;
30 30 if (xhr.status == 200) {
31   - c.responseText = xhr.responseText;
  31 + c.responseText = c.responseData = xhr.responseText;
32 32 c.responseXML = xhr.responseXML;
33   - c.responseData = xhr.responseHeader;
34 33 is(this.onload, "Function") && this.onload.call(this);
35 34 } else {
36 35 xhr.status / 100 | 0 > 3 && this._onError();
55 mobileweb/src/Ti/UI/View.js
@@ -35,40 +35,48 @@ define("Ti/UI/View",
35 35 view._parent = this;
36 36 this.containerNode.insertBefore(view.domNode,this.children[index].domNode);
37 37 this.children.splice(index,0,view);
38   - this._triggerLayout();
  38 + this._triggerLayout();
39 39 }
40 40 },
41 41
42 42 remove: function(view) {
43   - var i = 0,
44   - l = this.children.length;
45   - for (; i < l; i++) {
46   - if (this.children[i] === view) {
47   - l = this.children.splice(i, 1);
48   - l[0]._setParent();
49   - break;
  43 + var p = this.children.indexOf(view);
  44 + if (p !== -1) {
  45 + this.children.splice(p, 1);
  46 + view._setParent();
  47 + dom.detach(view.domNode);
  48 + this._triggerLayout();
  49 + }
  50 + },
  51 +
  52 + destroy: function() {
  53 + if (!this._destroyed) {
  54 + var c;
  55 + while (this.children.length) {
  56 + c = this.children.splice(0, 1);
  57 + c[0].destroy();
50 58 }
  59 + this._parent && this._parent.remove(this);
  60 + Element.prototype.destroy.apply(this, arguments);
51 61 }
52   - dom.detach(view.domNode);
53   - this._triggerLayout();
54 62 },
55   -
  63 +
56 64 _removeAllChildren: function(view) {
57 65 var children = this.children;
58   - while(children.length > 0) {
  66 + while (children.length) {
59 67 this.remove(children[0]);
60 68 }
61 69 this._triggerLayout();
62 70 },
63   -
  71 +
64 72 _getScrollableContentWidth: function() {
65 73 return 600;
66 74 },
67   -
  75 +
68 76 _getScrollablePosition: function() {
69 77 return {x: 0, y: 0};
70 78 },
71   -
  79 +
72 80 _createHorizontalScrollBar: function() {
73 81 var scrollBar = this._horizontalScrollBar = dom.create("div", {
74 82 className: "TiUIScrollBar",
@@ -83,12 +91,12 @@ define("Ti/UI/View",
83 91 }
84 92 }, this.domNode);
85 93 },
86   -
  94 +
87 95 _destroyHorizontalScrollBar: function() {
88 96 this._cancelPreviousAnimation();
89 97 dom.destroy(this._horizontalScrollBar);
90 98 },
91   -
  99 +
92 100 _createVerticalScrollBar: function() {
93 101 var scrollBar = this._verticalScrollBar = dom.create("div", {
94 102 className: "TiUIScrollBar",
@@ -210,19 +218,6 @@ define("Ti/UI/View",
210 218 }
211 219 },
212 220
213   - destroy: function() {
214   - if (!this._destroyed) {
215   - var i = 0,
216   - l = this.children.length;
217   - for (; i < l; i++) {
218   - this.children[i].destroy();
219   - this.children[i] = null;
220   - }
221   - this.children = null;
222   - Element.prototype.destroy.apply(this, arguments);
223   - }
224   - },
225   -
226 221 _defaultWidth: "100%",
227 222
228 223 _defaultHeight: "100%",
4 mobileweb/src/titanium.css
@@ -118,10 +118,6 @@ textarea {
118 118 background-color: gray;
119 119 }
120 120
121   -.TiMediaVideoPlayer {
122   - position: relative;
123   -}
124   -
125 121 .TiMediaVideoPlayer video {
126 122 left: 0;
127 123 position: absolute;

0 comments on commit 3ce2498

Please sign in to comment.
Something went wrong with that request. Please try again.