From 7396ca7f01ca884564b1dd86a8847d28364f1a96 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 22 Jun 2012 23:48:53 -0700 Subject: Fixing bug with gradient stop limits It seems that from-to stops are omitted if using objects with no 0 and/or 100 percent stops, seems like browser induced, but can't confirmed, bug never reported, but this should fix it. --- js/controllers/color-controller.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js index 3165988d..2a6fe9bd 100755 --- a/js/controllers/color-controller.js +++ b/js/controllers/color-controller.js @@ -254,7 +254,12 @@ exports.ColorController = Montage.create(Component, { gradient.css = css; // arr = css.split('from('); - arr = arr[1].split('),'); + // + if (arr.length > 1) { + arr = arr[1].split('),'); + } else { + arr = (css.split(css.split('color-stop(')[0])[1]).split('),'); + } // for (i=0; arr[i]; i++) { arr[i] = arr[i].replace(/ color-stop\(/i, ""); @@ -264,14 +269,20 @@ exports.ColorController = Montage.create(Component, { arr[i] = arr[i].replace(/\)\)/i, ""); } // - if (i === 0) { + if (i === 0 && arr[i].indexOf('color-stop') === -1) { arr[i] = {css: arr[i], percent: 0}; } else if (i === arr.length-1) { - arr[i] = {css: arr[i], percent: 100}; + temp = arr[i].split(', rgb'); + if (temp.length > 1) { + arr[i] = {css: 'rgb'+temp[1].replace(/\)\)/i, ""), percent: Math.round(parseFloat(temp[0])*100)}; + } else { + arr[i] = {css: arr[i], percent: 100}; + } } else { // if (arr[i].indexOf('rgb') >= 0 && arr[i].indexOf('rgba') < 0) { temp = arr[i].split(', rgb'); + temp[0] = temp[0].replace(/color\-stop\(/gi, ''); arr[i] = {css: 'rgb'+temp[1], percent: Math.round(parseFloat(temp[0])*100)}; } else if (arr[i].indexOf('rgba') >= 0) { temp = arr[i].split(', rgba'); -- cgit v1.2.3 From 32c41a56fd870f28be70c9b9cfb4fe6dfbb16654 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Sat, 23 Jun 2012 19:22:53 -0700 Subject: Adding support for gradients on chips Need to handle other color modes, currently only handling HSV and gradients. Working on getting other modes supported. Also, will need clean up color popup manager after completion. --- js/controllers/elements/body-controller.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 0ca6c417..0b6a5bad 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js @@ -31,6 +31,8 @@ exports.BodyController = Montage.create(ElementController, { value: function(el, p) { switch(p) { case "background" : + case "background-image": + return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-image")); case "background-color": return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color")); case "border": @@ -50,6 +52,9 @@ exports.BodyController = Montage.create(ElementController, { value: function(el, p, value) { switch(p) { case "background": + case "background-image": + this.application.ninja.stylesController.setElementStyle(el, "background-image", value); + break; case "background-color": this.application.ninja.stylesController.setElementStyle(el, "background-color", value); break; -- cgit v1.2.3 From 2f0a29c2cc9fd399e392abfd6770caffb99fdbb5 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 26 Jun 2012 10:41:20 -0700 Subject: Support pre-flighting of gradients for shape tools - rect, line, oval, brush and pen. Note that WebGL shapes are not supported yet. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index e62af921..74353454 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -278,7 +278,7 @@ exports.ShapesController = Montage.create(CanvasController, { } else { - return "FlatMaterial"; + return "Flat"; } case "fillMaterial": var fm = el.elementModel.shapeModel.GLGeomObj.getFillMaterial(); @@ -288,7 +288,7 @@ exports.ShapesController = Montage.create(CanvasController, { } else { - return "FlatMaterial"; + return "Flat"; } default: return CanvasController.getProperty(el, p); @@ -430,16 +430,16 @@ exports.ShapesController = Montage.create(CanvasController, { if(gradientMode === "radial") { - if( !m || (m.getName() !== "RadialGradientMaterial") ) + if( !m || (m.getName() !== "Radial Gradient") ) { - gradientM = Object.create(MaterialsModel.getMaterial("RadialGradientMaterial")); + gradientM = Object.create(MaterialsModel.getMaterial("Radial Gradient")); } } else { - if( !m || (m.getName() !== "LinearGradientMaterial") ) + if( !m || (m.getName() !== "Linear Gradient") ) { - gradientM = Object.create(MaterialsModel.getMaterial("LinearGradientMaterial")); + gradientM = Object.create(MaterialsModel.getMaterial("Linear Gradient")); } } @@ -471,9 +471,9 @@ exports.ShapesController = Montage.create(CanvasController, { m = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial(); } - if(!m || ((m.getName() === "LinearGradientMaterial") || m.getName() === "RadialGradientMaterial") ) + if(!m || ((m.getName() === "Linear Gradient") || m.getName() === "Radial Gradient") ) { - flatM = Object.create(MaterialsModel.getMaterial("FlatMaterial")); + flatM = Object.create(MaterialsModel.getMaterial("Flat")); if(flatM) { if(isFill) @@ -764,18 +764,18 @@ exports.ShapesController = Montage.create(CanvasController, { // Set Linear/Radial Gradient Material for children geometry if color in canvas 2d has gradient if(child.strokeColor.gradientMode === "radial") { - child.strokeMat = "RadialGradientMaterial"; + child.strokeMat = "Radial Gradient"; } else { - child.strokeMat = "LinearGradientMaterial"; + child.strokeMat = "Linear Gradient"; } } - else if( (child.strokeMat === "RadialGradientMaterial") || - (child.strokeMat === "LinearGradientMaterial") ) + else if( (child.strokeMat === "Radial Gradient") || + (child.strokeMat === "Linear Gradient") ) { // Set Flat Material for children geometry if color has been changed to solid - child.strokeMat = "FlatMaterial"; + child.strokeMat = "Flat"; } } @@ -786,18 +786,18 @@ exports.ShapesController = Montage.create(CanvasController, { // Set Linear/Radial Gradient Material for children geometry if color in canvas 2d has gradient if(child.fillColor.gradientMode === "radial") { - child.fillMat = "RadialGradientMaterial"; + child.fillMat = "Radial Gradient"; } else { - child.fillMat = "LinearGradientMaterial"; + child.fillMat = "Linear Gradient"; } } - else if( (child.fillMat === "RadialGradientMaterial") || - (child.fillMat === "LinearGradientMaterial") ) + else if( (child.fillMat === "Radial Gradient") || + (child.fillMat === "Linear Gradient") ) { // Set Flat Material for children geometry if color has been changed to solid - child.fillMat = "FlatMaterial"; + child.fillMat = "Flat"; } } } @@ -814,11 +814,11 @@ exports.ShapesController = Montage.create(CanvasController, { { var css, colorObj; - if(m === "LinearGradientMaterial") + if(m === "Linear Gradient") { css = "-webkit-gradient(linear, left top, right top, from(rgb(255, 0, 0)), color-stop(0.3, rgb(0, 255, 0)), color-stop(0.6, rgb(0, 0, 255)), to(rgb(0, 255, 255)))"; } - else if(m === "RadialGradientMaterial") + else if(m === "Radial Gradient") { css = "-webkit-radial-gradient(50% 50%, ellipse cover, rgb(255, 0, 0) 0%, rgb(0, 255, 0) 30%, rgb(0, 0, 255) 60%, rgb(0, 255, 255) 100%)"; } -- cgit v1.2.3 From 6823abb8024060eee6a4f8eaace288ed9dd58e65 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 27 Jun 2012 17:21:17 -0700 Subject: Styles Controller - Fix specificity comparison in hasGreaterSpecificity() --- js/controllers/styles-controller.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 0f847653..47c63c09 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -213,6 +213,9 @@ var stylesController = exports.StylesController = Montage.create(Component, { stylesheet.insertRule(ruleText, index); + ///// Invalidate cache because rule dominance is affected + this._clearCache(); + this.styleSheetModified(stylesheet); rule = stylesheet.rules[index]; @@ -775,7 +778,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { var a = this._getMostSpecificSelectorForElement(element, rule1[this.CONST.SPECIFICITY_KEY]), b = this._getMostSpecificSelectorForElement(element, rule2[this.CONST.SPECIFICITY_KEY]), win = element.ownerDocument.defaultView, - order; + order, sheetAIndex, sheetBIndex, ruleAIndex, ruleBIndex; order = this.compareSpecificity(a.specificity, b.specificity); @@ -786,9 +789,9 @@ var stylesController = exports.StylesController = Montage.create(Component, { /// If tied again (same sheet), determine which is further down in the sheet if(sheetAIndex === sheetBIndex) { ruleAIndex = this.getRuleIndex(rule1); ruleBIndex = this.getRuleIndex(rule2); - return ruleAIndex < ruleBIndex ? 1 : (ruleAIndex > ruleBIndex) ? -1 : 0; + return ruleAIndex < ruleBIndex ? false : (ruleAIndex > ruleBIndex) ? true : false; } else { - return sheetAIndex < sheetBIndex ? 1 : (sheetAIndex > sheetBIndex) ? -1 : 0; + return sheetAIndex < sheetBIndex ? false : (sheetAIndex > sheetBIndex) ? true : false; } } @@ -1552,6 +1555,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { value: function(el, property, rule) { if(!el.elementModel) { return false; } /// return null if there is no element model + console.log("Setting cache for property: ", property); this._cacheHistory.push({ rule: rule, element: el, @@ -1614,6 +1618,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { if(!element) { this._cacheHistory = null; this._cacheHistory = []; + console.log("Removing cache: ", this._cacheHistory); } } -- cgit v1.2.3 From cd563af62e937f49406caca55549cd72b13ee228 Mon Sep 17 00:00:00 2001 From: Armen Kesablyan Date: Thu, 28 Jun 2012 15:48:31 -0700 Subject: Binding View - Multi document bug : cleared object bindings when current document is changed Signed-off-by: Armen Kesablyan --- js/controllers/objects-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/objects-controller.js b/js/controllers/objects-controller.js index f6d400f4..6ca869ba 100644 --- a/js/controllers/objects-controller.js +++ b/js/controllers/objects-controller.js @@ -27,7 +27,7 @@ var objectsController = exports.ObjectsController = Montage.create(Montage, { setTimeout(function() { this.bindToModelObjects(); }.bind(this), 1000); - + this.currentObjectBindings = []; this._currentDocument = doc; }, enumerable : false -- cgit v1.2.3 From d6c7aa97651c259612636df6ae9063229a56d48f Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Thu, 28 Jun 2012 16:52:01 -0700 Subject: Presets/CSS Panel - Update css panel with preset class. --- js/controllers/presets-controller.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/presets-controller.js b/js/controllers/presets-controller.js index 4c177189..65a56a74 100644 --- a/js/controllers/presets-controller.js +++ b/js/controllers/presets-controller.js @@ -53,6 +53,8 @@ exports.PresetsController = Montage.create(Component, { //// TODO: replace this hack when webkit supports transitionStart event (see above) window.clearTimeout(el.njTimeout); + this._dispatchChange(); + el.classList.remove(this.transitionClass); el.removeEventListener("webkitTransitionEnd", this, true); } @@ -107,6 +109,10 @@ exports.PresetsController = Montage.create(Component, { } }, this); + if(!useTransition) { + this._dispatchChange(); + } + } }, @@ -126,5 +132,19 @@ exports.PresetsController = Montage.create(Component, { return keysString; } + }, + + _dispatchChange : { + value: function(property, value) { + this.application.ninja.stage.updatedStage = true; + NJevent('elementChange', { + type : 'presetChange', + data: { + "prop": property, + "value": value + }, + redraw: null + }); + } } }); \ No newline at end of file -- cgit v1.2.3 From e3eb68c3a0b911acd873ee6211931b8f4e620030 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 28 Jun 2012 17:54:15 -0700 Subject: Fixed not being able to draw linear and radial gradients. Also fixed IKNINJA-1721 - File dirty marker does not show when modifying elements and IKNinja-1581 and IKNinja-1758 - Paint bucket fill bugs with lines and brush objects. Squashed commit of the following: commit 7cad082c89911d34a99feeef8e91d22b89cae8f1 Author: Nivesh Rajbhandari Date: Thu Jun 28 17:52:07 2012 -0700 Fix for not being able to draw linear and radial gradient materials. I'm turning off pre-flight support of gradients for WebGL since it conflicts with the materials' color support. Signed-off-by: Nivesh Rajbhandari commit d0df8a2bff052d855bafb7885792b1dfff8eab7d Merge: 2c67d26 b4b54f6 Author: Nivesh Rajbhandari Date: Thu Jun 28 17:50:11 2012 -0700 Merge branch 'refs/heads/ninja-internal' into ToolFixes commit 2c67d264851f0897fdca8ca887c1c82d0e434217 Author: Nivesh Rajbhandari Date: Thu Jun 28 15:06:13 2012 -0700 IKNINJA-1721 - File dirty marker does not show when modifying elements. Signed-off-by: Nivesh Rajbhandari commit bb4b6a52eb75efb2f435cdb53f810ae3bc1f1fc3 Author: Nivesh Rajbhandari Date: Thu Jun 28 11:15:34 2012 -0700 IKNinja-1581 and IKNinja-1758 - Paint bucket fill bugs with lines and brush objects. Signed-off-by: Nivesh Rajbhandari Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 8 ++++++++ js/controllers/styles-controller.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 74353454..5920d51a 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -138,6 +138,10 @@ exports.ShapesController = Montage.create(CanvasController, { this.application.ninja.elementMediator.replaceElement(canvas, el); break; case "strokeMaterial": + // skip shape types that don't support WebGL + if(!el.elementModel.shapeModel.GLGeomObj.useWebGl) { + return; + } m = Object.create(MaterialsModel.getMaterial(value)); if(m) { @@ -152,6 +156,10 @@ exports.ShapesController = Montage.create(CanvasController, { } break; case "fillMaterial": + // skip shape types that don't support WebGL or fill color + if(!el.elementModel.shapeModel.GLGeomObj.canFill || !el.elementModel.shapeModel.GLGeomObj.useWebGl) { + return; + } m = Object.create(MaterialsModel.getMaterial(value)); if(m) { diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 0f847653..e7f95335 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -1437,11 +1437,11 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// Dispatch modified event NJevent('styleSheetModified', eventData); + this.currentDocument.model.needsSave = true; ///// If the sheet doesn't already exist in the list of modified ///// sheets, dispatch dirty event and add the sheet to the list if(sheetSearch.length === 0) { - this.currentDocument.model.needsSave = true; this.dirtyStyleSheets.push({ document : sheet.ownerNode.ownerDocument, stylesheet : sheet -- cgit v1.2.3 From 44903a3b55b4343f26de7cc4c60a2723e3131793 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 29 Jun 2012 09:09:56 -0700 Subject: Styles Controller Patch to ignore unfound rules from getMatchedCSSRules --- js/controllers/styles-controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 0f847653..2282794c 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -629,7 +629,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { if(!rule) { ///// This should never be hit if providing cssText from existing rule (like those ///// returned from getMatchedCSSRules() - console.warn('StylesController::_getRuleWithCSSText - No rule found with given cssText.'); + //console.warn('StylesController::_getRuleWithCSSText - No rule found with given cssText.'); } return rule; @@ -653,6 +653,8 @@ var stylesController = exports.StylesController = Montage.create(Component, { }, this); rules = mappedRules.filter(function(rule) { + if(!rule) { return false; } + //// useStageStyleSheet flag indicates whether to only return rules from the stylesheet, //// or only use rules for other stylesheets -- cgit v1.2.3 From 72a236ce7af6711f9d30762c2409d0ebd5ecf7aa Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 29 Jun 2012 09:14:30 -0700 Subject: Styles Controller - removing console logs --- js/controllers/styles-controller.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 47c63c09..e25ed20c 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -1555,7 +1555,6 @@ var stylesController = exports.StylesController = Montage.create(Component, { value: function(el, property, rule) { if(!el.elementModel) { return false; } /// return null if there is no element model - console.log("Setting cache for property: ", property); this._cacheHistory.push({ rule: rule, element: el, @@ -1618,7 +1617,6 @@ var stylesController = exports.StylesController = Montage.create(Component, { if(!element) { this._cacheHistory = null; this._cacheHistory = []; - console.log("Removing cache: ", this._cacheHistory); } } -- cgit v1.2.3 From ae9a947b7019a57d399823142775c6b61ee69546 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 29 Jun 2012 11:49:11 -0700 Subject: Styles controller - adding check for attached element in getMatchedCSSRules --- js/controllers/styles-controller.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 2282794c..64efdb19 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -629,7 +629,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { if(!rule) { ///// This should never be hit if providing cssText from existing rule (like those ///// returned from getMatchedCSSRules() - //console.warn('StylesController::_getRuleWithCSSText - No rule found with given cssText.'); + console.warn('StylesController::_getRuleWithCSSText - No rule found with given cssText.'); } return rule; @@ -647,6 +647,10 @@ var stylesController = exports.StylesController = Montage.create(Component, { doc = element.ownerDocument, win = doc.defaultView; + if(!element.parentNode) { + console.warn('StylesController::getMatchingRules - Un-attached element queried'); + } + try { mappedRules = nj.toArray(win.getMatchedCSSRules(element)).map(function(rule) { return this._getRuleWithCSSText(rule.cssText, doc); @@ -675,7 +679,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { }, this); } catch(ERROR) { - console.warn('StylesController::getMatchingRules - Un-attached element queried.'); + console.warn('StylesController::getMatchingRules - getMatchedCSSRules Exception.'); } ///// Function for sorting by specificity values function sorter(ruleA, ruleB) { -- cgit v1.2.3 From 01783536d2245b474eb1f89df673bfabb006cbdd Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 29 Jun 2012 11:49:51 -0700 Subject: Need to special case linear gradient, radial gradient and uber materials when applying fill and stroke colors. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 75 +++++++++++++++++++++------- 1 file changed, 56 insertions(+), 19 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 5920d51a..c3099459 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -139,7 +139,7 @@ exports.ShapesController = Montage.create(CanvasController, { break; case "strokeMaterial": // skip shape types that don't support WebGL - if(!el.elementModel.shapeModel.GLGeomObj.useWebGl) { + if(!el.elementModel.shapeModel.useWebGl) { return; } m = Object.create(MaterialsModel.getMaterial(value)); @@ -157,7 +157,7 @@ exports.ShapesController = Montage.create(CanvasController, { break; case "fillMaterial": // skip shape types that don't support WebGL or fill color - if(!el.elementModel.shapeModel.GLGeomObj.canFill || !el.elementModel.shapeModel.GLGeomObj.useWebGl) { + if(!el.elementModel.shapeModel.GLGeomObj.canFill || !el.elementModel.shapeModel.useWebGl) { return; } m = Object.create(MaterialsModel.getMaterial(value)); @@ -453,17 +453,17 @@ exports.ShapesController = Montage.create(CanvasController, { if(gradientM) { - if(isFill) - { + if(isFill) + { el.elementModel.shapeModel.GLGeomObj.setFillMaterial(gradientM); } else { el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(gradientM); } - el.elementModel.shapeModel.GLGeomObj.buildBuffers(); - } - } + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); + } + } }, _setFlatMaterial: { @@ -480,10 +480,13 @@ exports.ShapesController = Montage.create(CanvasController, { } if(!m || ((m.getName() === "Linear Gradient") || m.getName() === "Radial Gradient") ) - { + { + // Uber Material also supports solid colors, so don't change from Uber to Flat Material + if(m && (m.getName() === "Uber")) { return; } + flatM = Object.create(MaterialsModel.getMaterial("Flat")); if(flatM) - { + { if(isFill) { el.elementModel.shapeModel.GLGeomObj.setFillMaterial(flatM); @@ -492,10 +495,10 @@ exports.ShapesController = Montage.create(CanvasController, { { el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(flatM); } - el.elementModel.shapeModel.GLGeomObj.buildBuffers(); - } + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); } } + } }, setColor: { @@ -605,14 +608,31 @@ exports.ShapesController = Montage.create(CanvasController, { setStroke: { value: function(el, stroke, eventType, source) { - if(stroke.colorInfo) { - this.setColor(el, stroke.colorInfo, false); - } if(stroke.shapeInfo) { this.setProperty(el, "strokeSize", stroke.shapeInfo.strokeSize + " " + stroke.shapeInfo.strokeUnits, eventType, source); } + var m; if(stroke.webGLInfo) { - this.setProperty(el, "strokeMaterial", stroke.webGLInfo.material); + m = stroke.webGLInfo.material; + this.setProperty(el, "strokeMaterial", m); + if((m === "Linear Gradient") || (m === "Radial Gradient")) { + // Just use the default gradient material values + return; + } + } + if(stroke.colorInfo) { + if(el.elementModel.shapeModel.useWebGl) { + m = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial().getName(); + if( ((stroke.colorInfo.mode === "gradient") && (m !== "Linear Gradient") && (m !== "Radial Gradient")) || + ((stroke.colorInfo.mode !== "gradient") && ((m === "Linear Gradient") || (m === "Radial Gradient")))) + { + return; + } else { + this.setColor(el, stroke.colorInfo, false); + } + } else { + this.setColor(el, stroke.colorInfo, false); + } } } }, @@ -646,11 +666,28 @@ exports.ShapesController = Montage.create(CanvasController, { setFill: { value: function(el, fill) { - if(fill.colorInfo) { - this.setColor(el, fill.colorInfo, true); - } + var m; if(fill.webGLInfo) { - this.setProperty(el, "fillMaterial", fill.webGLInfo.material); + m = fill.webGLInfo.material; + this.setProperty(el, "fillMaterial", m); + if((m === "Linear Gradient") || (m === "Radial Gradient")) { + // Just use the default gradient material values + return; + } + } + if(fill.colorInfo) { + if(el.elementModel.shapeModel.useWebGl) { + m = el.elementModel.shapeModel.GLGeomObj.getFillMaterial().getName(); + if( ((fill.colorInfo.mode === "gradient") && (m !== "Linear Gradient") && (m !== "Radial Gradient")) || + ((fill.colorInfo.mode !== "gradient") && ((m === "Linear Gradient") || (m === "Radial Gradient")))) + { + return; + } else { + this.setColor(el, fill.colorInfo, true); + } + } else { + this.setColor(el, fill.colorInfo, true); + } } } }, -- cgit v1.2.3 From 4db51449c829f34c1875e7c5ec91343c511da729 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 29 Jun 2012 11:51:46 -0700 Subject: Styles Controller - getMatchingRules - Add forgotten return statement --- js/controllers/styles-controller.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 64efdb19..aca86ec5 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -649,6 +649,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { if(!element.parentNode) { console.warn('StylesController::getMatchingRules - Un-attached element queried'); + return []; } try { -- cgit v1.2.3 From 06ac6fcdde5b1f9a00e4c966ce165af0a4c3c1da Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 29 Jun 2012 12:25:50 -0700 Subject: Null check on results from getMatchedCSSRules --- js/controllers/styles-controller.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index aca86ec5..39deeaa8 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -643,6 +643,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { getMatchingRules : { //TODO: Remove omitPseudos from here and usages value: function(element, omitPseudos, useStageStyleSheet) { var rules, + matchedRules, mappedRules, doc = element.ownerDocument, win = doc.defaultView; @@ -653,7 +654,14 @@ var stylesController = exports.StylesController = Montage.create(Component, { } try { - mappedRules = nj.toArray(win.getMatchedCSSRules(element)).map(function(rule) { + matchedRules = win.getMatchedCSSRules(element); + + if(!matchedRules) { + console.warn('StylesController::getMatchingRules - matched rules are null'); + return []; + } + + mappedRules = nj.toArray(matchedRules).map(function(rule) { return this._getRuleWithCSSText(rule.cssText, doc); }, this); -- cgit v1.2.3 From 25890906f10e4530f0245632d028a646ece563c1 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 29 Jun 2012 14:31:19 -0700 Subject: Another null check on results from getMatchedCSSRules --- js/controllers/styles-controller.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 39deeaa8..b50f43cc 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -629,7 +629,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { if(!rule) { ///// This should never be hit if providing cssText from existing rule (like those ///// returned from getMatchedCSSRules() - console.warn('StylesController::_getRuleWithCSSText - No rule found with given cssText.'); + //console.warn('StylesController::_getRuleWithCSSText - No rule found with given cssText.'); } return rule; @@ -649,7 +649,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { win = doc.defaultView; if(!element.parentNode) { - console.warn('StylesController::getMatchingRules - Un-attached element queried'); + //console.warn('StylesController::getMatchingRules - Un-attached element queried'); return []; } @@ -657,7 +657,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { matchedRules = win.getMatchedCSSRules(element); if(!matchedRules) { - console.warn('StylesController::getMatchingRules - matched rules are null'); + //console.warn('StylesController::getMatchingRules - matched rules are null'); return []; } @@ -688,7 +688,8 @@ var stylesController = exports.StylesController = Montage.create(Component, { }, this); } catch(ERROR) { - console.warn('StylesController::getMatchingRules - getMatchedCSSRules Exception.'); + //console.warn('StylesController::getMatchingRules - getMatchedCSSRules Exception.'); + return []; } ///// Function for sorting by specificity values function sorter(ruleA, ruleB) { -- cgit v1.2.3