// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
// limitations under the License.

(function(scope, testing) {

  function parseBoxWithCalcLeft(string) {
    var rectangleWithCalcRegExp = /rect\(([^,]+), ([^,]+), ([^,]+), (calc\(.+\))\)/
    match = rectangleWithCalcRegExp.exec(string);
    if (!match) {
      return undefined;
    }
    var out = [
      scope.parseLengthOrPercent(match[1]),
      scope.parseLengthOrPercent(match[2]),
      scope.parseLengthOrPercent(match[3]),
      scope.parseLengthOrPercent(match[4])
      ];
    console.log(out);
    if (out[0] && out[1] && out[2] && out[3]) {
      console.log("returning the other one");
      return out;
    }
    return undefined;
  }

  function parseBox(string) {
    var rectangleRegExp = /rect\(([^,]+),([^,]+),([^,]+),([^)]+)\)/;
    var match = rectangleRegExp.exec(string);
    if (!match) {
      return undefined;
    }
    var out = [
      scope.parseLengthOrPercent(match[1]),
      scope.parseLengthOrPercent(match[2]),
      scope.parseLengthOrPercent(match[3]),
      scope.parseLengthOrPercent(match[4])
      ];
    console.log(out);
    if (out[0] && out[1] && out[2] && out[3]) {
      return out;
    }
    return parseBoxWithCalcLeft(string);
    // return undefined;
  }

  function mergeBoxes(left, right) {
    var mergedTop = scope.mergeDimensions(left[0], right[0]);
    var mergedRight = scope.mergeDimensions(left[1], right[1]);
    var mergedBottom = scope.mergeDimensions(left[2], right[2]);
    var mergedLeft = scope.mergeDimensions(left[3], right[3]);
    return [
      [mergedTop[0], mergedRight[0], mergedBottom[0], mergedLeft[0]],
      [mergedTop[1], mergedRight[1], mergedBottom[1], mergedLeft[1]],
      function(rectValue) {
        return 'rect(' + mergedTop[2](rectValue[0]) + ', '
          + mergedRight[2](rectValue[1]) + ', '
          + mergedBottom[2](rectValue[2]) + ', '
          + mergedLeft[2](rectValue[3]) + ')'
      }
    ];
  }

  scope.addPropertiesHandler(parseBox, mergeBoxes, ['clip']);

  scope.parseBox = parseBox;
  scope.mergeBoxes = mergeBoxes;

})(webAnimationsMinifill, webAnimationsTesting);
@@ -633,16 +633,19 @@
 ng) %7B%0A%0A 
+ //
  functio
@@ -670,32 +670,35 @@
 Left(string) %7B%0A 
+ //
    var rectangle
@@ -765,16 +765,19 @@
 %5C))%5C)/%0A 
+ //
    match
@@ -810,32 +810,35 @@
 .exec(string);%0A 
+ //
    if (!match) %7B
@@ -831,32 +831,35 @@
  if (!match) %7B%0A 
+ //
      return unde
@@ -858,38 +858,44 @@
 urn undefined;%0A 
+ //
    %7D%0A 
+ //
    var out = %5B%0A 
@@ -886,32 +886,35 @@
    var out = %5B%0A 
+ //
      scope.parse
@@ -933,32 +933,35 @@
 ent(match%5B1%5D),%0A 
+ //
      scope.parse
@@ -980,32 +980,35 @@
 ent(match%5B2%5D),%0A 
+ //
      scope.parse
@@ -1027,32 +1027,35 @@
 ent(match%5B3%5D),%0A 
+ //
      scope.parse
@@ -1073,32 +1073,35 @@
 cent(match%5B4%5D)%0A 
+ //
      %5D;%0A    cons
@@ -1085,32 +1085,35 @@
 %5D)%0A  //     %5D;%0A 
+ //
    console.log(o
@@ -1110,32 +1110,35 @@
 sole.log(out);%0A 
+ //
    if (out%5B0%5D &&
@@ -1165,24 +1165,27 @@
  out%5B3%5D) %7B%0A 
+ //
      console
@@ -1218,16 +1218,19 @@
 one%22);%0A 
+ //
      ret
@@ -1231,38 +1231,44 @@
    return out;%0A 
+ //
    %7D%0A 
+ //
    return undefi
@@ -1265,32 +1265,35 @@
 urn undefined;%0A 
+ //
  %7D%0A%0A  function p
@@ -1309,24 +1309,27 @@
 tring) %7B%0A   
+ //
  var rectang
@@ -1382,16 +1382,146 @@
 %5D+)%5C)/;%0A
+    // var rectangleRegExp = /rect%5C((%5B%5E,%5D+), (%5B%5E,%5D+), (%5B%5E,%5D+), (.+)%5C)/%0A    var rectangleRegExp = /rect%5C((.+), (.+), (.+), (.+)%5C)/%0A
     var 
@@ -1899,24 +1899,27 @@
 t;%0A    %7D%0A   
+ //
  return pars
@@ -1943,27 +1943,24 @@
 string);%0A   
- //
  return unde

Combined two regexps