Ejemplo n.º 1
0
    records.forEach((record) => {
      var endEvent = null;
      var type = record['type'];
      var data = record['data'];
      var startTime = record['startTime'];
      var endTime = record['endTime'];

      if (StringWrapper.equals(type, 'FunctionCall') &&
          (isBlank(data) || !StringWrapper.equals(data['scriptName'], 'InjectedScript'))) {
        events.push(createStartEvent('script', startTime));
        endEvent = createEndEvent('script', endTime);
      } else if (StringWrapper.equals(type, 'Time')) {
        events.push(createMarkStartEvent(data['message'], startTime));
      } else if (StringWrapper.equals(type, 'TimeEnd')) {
        events.push(createMarkEndEvent(data['message'], startTime));
      } else if (StringWrapper.equals(type, 'RecalculateStyles') ||
                 StringWrapper.equals(type, 'Layout') ||
                 StringWrapper.equals(type, 'UpdateLayerTree') ||
                 StringWrapper.equals(type, 'Paint') || StringWrapper.equals(type, 'Rasterize') ||
                 StringWrapper.equals(type, 'CompositeLayers')) {
        events.push(createStartEvent('render', startTime));
        endEvent = createEndEvent('render', endTime);
      }
      // Note: ios used to support GCEvent up until iOS 6 :-(
      if (isPresent(record['children'])) {
        this._convertPerfRecordsToEvents(record['children'], events);
      }
      if (isPresent(endEvent)) {
        events.push(endEvent);
      }
    });
Ejemplo n.º 2
0
 function createMetric(perfLogs, microMetrics = null, perfLogFeatures = null, forceGc = null,
                       captureFrames = null) {
   commandLog = [];
   if (isBlank(perfLogFeatures)) {
     perfLogFeatures = new PerfLogFeatures({render: true, gc: true, frameCapture: true});
   }
   if (isBlank(microMetrics)) {
     microMetrics = StringMapWrapper.create();
   }
   var bindings = [
     Options.DEFAULT_PROVIDERS,
     PerflogMetric.BINDINGS,
     bind(Options.MICRO_METRICS).toValue(microMetrics),
     bind(PerflogMetric.SET_TIMEOUT)
         .toValue((fn, millis) => {
           commandLog.push(['setTimeout', millis]);
           fn();
         }),
     bind(WebDriverExtension)
         .toValue(new MockDriverExtension(perfLogs, commandLog, perfLogFeatures))
   ];
   if (isPresent(forceGc)) {
     bindings.push(bind(Options.FORCE_GC).toValue(forceGc));
   }
   if (isPresent(captureFrames)) {
     bindings.push(bind(Options.CAPTURE_FRAMES).toValue(captureFrames));
   }
   return Injector.resolveAndCreate(bindings).get(PerflogMetric);
 }
Ejemplo n.º 3
0
 static _format(value: number, style: NumberFormatStyle, digits: string, currency: string = null,
                currencyAsSymbol: boolean = false): string {
   if (isBlank(value)) return null;
   if (!isNumber(value)) {
     throw new InvalidPipeArgumentException(NumberPipe, value);
   }
   var minInt = 1, minFraction = 0, maxFraction = 3;
   if (isPresent(digits)) {
     var parts = RegExpWrapper.firstMatch(_re, digits);
     if (isBlank(parts)) {
       throw new BaseException(`${digits} is not a valid digit info for number pipes`);
     }
     if (isPresent(parts[1])) {  // min integer digits
       minInt = NumberWrapper.parseIntAutoRadix(parts[1]);
     }
     if (isPresent(parts[3])) {  // min fraction digits
       minFraction = NumberWrapper.parseIntAutoRadix(parts[3]);
     }
     if (isPresent(parts[5])) {  // max fraction digits
       maxFraction = NumberWrapper.parseIntAutoRadix(parts[5]);
     }
   }
   return NumberFormatter.format(value, defaultLocale, style, {
     minimumIntegerDigits: minInt,
     minimumFractionDigits: minFraction,
     maximumFractionDigits: maxFraction,
     currency: currency,
     currencyAsSymbol: currencyAsSymbol
   });
 }
Ejemplo n.º 4
0
 transform(value: any, args: any[]): string {
   var currencyCode: string = isPresent(args) && args.length > 0 ? args[0] : 'USD';
   var symbolDisplay: boolean = isPresent(args) && args.length > 1 ? args[1] : false;
   var digits: string = isPresent(args) && args.length > 2 ? args[2] : null;
   return NumberPipe._format(value, NumberFormatStyle.Currency, digits, currencyCode,
                             symbolDisplay);
 }
Ejemplo n.º 5
0
export function selectValueAccessor(dir: NgControl, valueAccessors: ControlValueAccessor[]):
    ControlValueAccessor {
  if (isBlank(valueAccessors)) return null;

  var defaultAccessor;
  var builtinAccessor;
  var customAccessor;

  valueAccessors.forEach(v => {
    if (v instanceof DefaultValueAccessor) {
      defaultAccessor = v;

    } else if (v instanceof CheckboxControlValueAccessor ||
               v instanceof SelectControlValueAccessor) {
      if (isPresent(builtinAccessor))
        _throwError(dir, "More than one built-in value accessor matches");
      builtinAccessor = v;

    } else {
      if (isPresent(customAccessor))
        _throwError(dir, "More than one custom value accessor matches");
      customAccessor = v;
    }
  });

  if (isPresent(customAccessor)) return customAccessor;
  if (isPresent(builtinAccessor)) return builtinAccessor;
  if (isPresent(defaultAccessor)) return defaultAccessor;

  _throwError(dir, "No valid value accessor for");
  return null;
}
Ejemplo n.º 6
0
 private _processAsPostChrome44Event(event, categories) {
   var name = event['name'];
   var args = event['args'];
   if (this._isEvent(categories, name, ['devtools.timeline', 'v8'], 'MajorGC')) {
     var normArgs = {
       'majorGc': true,
       'usedHeapSize': isPresent(args['usedHeapSizeAfter']) ? args['usedHeapSizeAfter'] :
                                                              args['usedHeapSizeBefore']
     };
     return normalizeEvent(event, {'name': 'gc', 'args': normArgs});
   } else if (this._isEvent(categories, name, ['devtools.timeline', 'v8'], 'MinorGC')) {
     var normArgs = {
       'majorGc': false,
       'usedHeapSize': isPresent(args['usedHeapSizeAfter']) ? args['usedHeapSizeAfter'] :
                                                              args['usedHeapSizeBefore']
     };
     return normalizeEvent(event, {'name': 'gc', 'args': normArgs});
   } else if (this._isEvent(categories, name, ['devtools.timeline', 'v8'], 'FunctionCall') &&
              (isBlank(args) || isBlank(args['data']) ||
               (!StringWrapper.equals(args['data']['scriptName'], 'InjectedScript') &&
                !StringWrapper.equals(args['data']['scriptName'], '')))) {
     return normalizeEvent(event, {'name': 'script'});
   } else if (this._isEvent(categories, name, ['devtools.timeline', 'blink'],
                            'UpdateLayoutTree')) {
     return normalizeEvent(event, {'name': 'render'});
   } else if (this._isEvent(categories, name, ['devtools.timeline'], 'UpdateLayerTree') ||
              this._isEvent(categories, name, ['devtools.timeline'], 'Layout') ||
              this._isEvent(categories, name, ['devtools.timeline'], 'Paint')) {
     return normalizeEvent(event, {'name': 'render'});
   }
   return null;  // nothing useful in this event
 }
Ejemplo n.º 7
0
export function coalesce(records: ProtoRecord[]): ProtoRecord[] {
  var res: ProtoRecord[] = [];
  var indexMap: Map<number, number> = new Map<number, number>();

  for (var i = 0; i < records.length; ++i) {
    var r = records[i];
    var record = _replaceIndices(r, res.length + 1, indexMap);
    var matchingRecord = _findMatching(record, res);

    if (isPresent(matchingRecord) && record.lastInBinding) {
      res.push(_selfRecord(record, matchingRecord.selfIndex, res.length + 1));
      indexMap.set(r.selfIndex, matchingRecord.selfIndex);
      matchingRecord.referencedBySelf = true;

    } else if (isPresent(matchingRecord) && !record.lastInBinding) {
      if (record.argumentToPureFunction) {
        matchingRecord.argumentToPureFunction = true;
      }

      indexMap.set(r.selfIndex, matchingRecord.selfIndex);

    } else {
      res.push(record);
      indexMap.set(r.selfIndex, record.selfIndex);
    }
  }

  return res;
}
Ejemplo n.º 8
0
 /**
  * Return {@link PipeMetadata} for a given `Type`.
  */
 resolve(type: Type): PipeMetadata {
   var metas = reflector.annotations(resolveForwardRef(type));
   if (isPresent(metas)) {
     var annotation = ListWrapper.find(metas, _isPipeMetadata);
     if (isPresent(annotation)) {
       return annotation;
     }
   }
   throw new BaseException(`No Pipe decorator found on ${stringify(type)}`);
 }
export function inspectNativeElement(element): DebugElement {
  var elId = _getElementId(element);
  if (isPresent(elId)) {
    var view = _allViewsById.get(elId[0]);
    if (isPresent(view)) {
      return new DebugElement_(view, elId[1]);
    }
  }
  return null;
}
 return StringWrapper.replaceAllMapped(cssText, _cssImportRe, (m) => {
   var url = isPresent(m[1]) ? m[1] : m[2];
   var schemeMatch = RegExpWrapper.firstMatch(_urlWithSchemaRe, url);
   if (isPresent(schemeMatch) && schemeMatch[1] != 'package') {
     // Do not attempt to resolve non-package absolute URLs with URI scheme
     return m[0];
   }
   foundUrls.push(resolver.resolve(baseUrl, url));
   return '';
 });