Bug 442228, add -moz-resize property to indicate that elements are resizable, r=dbaron
authorNeil Deakin <neil@mozilla.com>
Fri, 19 Mar 2010 07:49:33 -0400
changeset 39638 98f0a163b0fe11657b5f5ced72cd85a8df64f93d
parent 39637 e2c79d3c12f7ef2c695ec6f89e0b8948c37e5976
child 39639 c7e2dc67f36b3f59bc78cc776cce001568b3fe1f
push idunknown
push userunknown
push dateunknown
reviewersdbaron
bugs442228
milestone1.9.3a4pre
Bug 442228, add -moz-resize property to indicate that elements are resizable, r=dbaron
dom/interfaces/css/nsIDOMNSCSS2Properties.idl
layout/base/nsStyleConsts.h
layout/style/nsCSSParser.cpp
layout/style/nsCSSPropList.h
layout/style/nsCSSProps.cpp
layout/style/nsCSSProps.h
layout/style/nsCSSStruct.h
layout/style/nsComputedDOMStyle.cpp
layout/style/nsComputedDOMStyle.h
layout/style/nsRuleNode.cpp
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/style/test/property_database.js
--- a/dom/interfaces/css/nsIDOMNSCSS2Properties.idl
+++ b/dom/interfaces/css/nsIDOMNSCSS2Properties.idl
@@ -35,17 +35,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIDOMSVGCSS2Properties.idl"
 
-[scriptable, uuid(be39bc6d-3b24-4421-9599-8fdf3ad33baf)]
+[scriptable, uuid(649B0B41-C5F7-4EA2-B6DF-CFFF6B6DD30A)]
 interface nsIDOMNSCSS2Properties : nsIDOMSVGCSS2Properties
 {
            /* Non-DOM 2 extensions */
 
            /* Mozilla extension CSS properties */
            attribute DOMString        MozAppearance;
                                         // raises(DOMException) on setting
 
@@ -276,9 +276,12 @@ interface nsIDOMNSCSS2Properties : nsIDO
            attribute DOMString        MozTransition;
                                         // raises(DOMException) on setting
 
            attribute DOMString        pointerEvents;
                                         // raises(DOMException) on setting
 
            attribute DOMString        MozTabSize;
                                         // raises(DOMException) on setting
+
+           attribute DOMString        MozResize;
+                                        // raises(DOMException) on setting
 };
--- a/layout/base/nsStyleConsts.h
+++ b/layout/base/nsStyleConsts.h
@@ -588,16 +588,22 @@
 #define NS_STYLE_POINTER_EVENTS_VISIBLESTROKE   3
 #define NS_STYLE_POINTER_EVENTS_VISIBLE         4
 #define NS_STYLE_POINTER_EVENTS_PAINTED         5
 #define NS_STYLE_POINTER_EVENTS_FILL            6
 #define NS_STYLE_POINTER_EVENTS_STROKE          7
 #define NS_STYLE_POINTER_EVENTS_ALL             8
 #define NS_STYLE_POINTER_EVENTS_AUTO            9
 
+// See nsStyleDisplay
+#define NS_STYLE_RESIZE_NONE                    0
+#define NS_STYLE_RESIZE_BOTH                    1
+#define NS_STYLE_RESIZE_HORIZONTAL              2
+#define NS_STYLE_RESIZE_VERTICAL                3
+
 // See nsStyleText
 #define NS_STYLE_TEXT_ALIGN_DEFAULT               0
 #define NS_STYLE_TEXT_ALIGN_LEFT                  1
 #define NS_STYLE_TEXT_ALIGN_RIGHT                 2
 #define NS_STYLE_TEXT_ALIGN_CENTER                3
 #define NS_STYLE_TEXT_ALIGN_JUSTIFY               4
 #define NS_STYLE_TEXT_ALIGN_CHAR                  5   //align based on a certain character, for table cell
 #define NS_STYLE_TEXT_ALIGN_END                   6
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -6014,16 +6014,19 @@ CSSParserImpl::ParseSingleValueProperty(
     return ParseVariant(aValue, VARIANT_HKF, nsCSSProps::kPitchKTable);
   case eCSSProperty_pitch_range:
     return ParseVariant(aValue, VARIANT_HN, nsnull);
   case eCSSProperty_pointer_events:
     return ParseVariant(aValue, VARIANT_HK,
                         nsCSSProps::kPointerEventsKTable);
   case eCSSProperty_position:
     return ParseVariant(aValue, VARIANT_HK, nsCSSProps::kPositionKTable);
+  case eCSSProperty_resize:
+    return ParseVariant(aValue, VARIANT_HK,
+                        nsCSSProps::kResizeKTable);
   case eCSSProperty_richness:
     return ParseVariant(aValue, VARIANT_HN, nsnull);
 #ifdef MOZ_MATHML
   // script-level can take Integer or Number values, but only Integer ("relative")
   // values can be specified in a style sheet. Also we only allow this property
   // when unsafe rules are enabled, because otherwise it could interfere
   // with rulenode optimizations if used in a non-MathML-enabled document.
   case eCSSProperty_script_level:
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -2180,16 +2180,27 @@ CSS_PROP_QUOTES(
     Quotes,
     0,
     Content,
     mQuotes,
     eCSSType_ValuePairList,
     nsnull,
     CSS_PROP_NO_OFFSET,
     eStyleAnimType_None)
+CSS_PROP_DISPLAY(
+    -moz-resize,
+    resize,
+    MozResize,
+    0,
+    Display,
+    mResize,
+    eCSSType_Value,
+    kResizeKTable,
+    CSS_PROP_NO_OFFSET,
+    eStyleAnimType_None)
 CSS_PROP_BACKENDONLY(
     richness,
     richness,
     Richness,
     0,
     Aural,
     mRichness,
     eCSSType_Value,
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -1101,16 +1101,24 @@ const PRInt32 nsCSSProps::kRadialGradien
   eCSSKeyword_farthest_side,   NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE,
   eCSSKeyword_farthest_corner, NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER,
   // synonyms
   eCSSKeyword_contain,         NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE,
   eCSSKeyword_cover,           NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER,
   eCSSKeyword_UNKNOWN,-1
 };
 
+const PRInt32 nsCSSProps::kResizeKTable[] = {
+  eCSSKeyword_none,       NS_STYLE_RESIZE_NONE,
+  eCSSKeyword_both,       NS_STYLE_RESIZE_BOTH,
+  eCSSKeyword_horizontal, NS_STYLE_RESIZE_HORIZONTAL,
+  eCSSKeyword_vertical,   NS_STYLE_RESIZE_VERTICAL,
+  eCSSKeyword_UNKNOWN,-1
+};
+
 const PRInt32 nsCSSProps::kSpeakKTable[] = {
   eCSSKeyword_none,      NS_STYLE_SPEAK_NONE,
   eCSSKeyword_normal,    NS_STYLE_SPEAK_NORMAL,
   eCSSKeyword_spell_out, NS_STYLE_SPEAK_SPELL_OUT,
   eCSSKeyword_UNKNOWN,-1
 };
 
 const PRInt32 nsCSSProps::kSpeakHeaderKTable[] = {
--- a/layout/style/nsCSSProps.h
+++ b/layout/style/nsCSSProps.h
@@ -301,16 +301,17 @@ public:
   static const PRInt32 kPageBreakInsideKTable[];
   static const PRInt32 kPageMarksKTable[];
   static const PRInt32 kPageSizeKTable[];
   static const PRInt32 kPitchKTable[];
   static const PRInt32 kPointerEventsKTable[];
   static const PRInt32 kPositionKTable[];
   static const PRInt32 kRadialGradientShapeKTable[];
   static const PRInt32 kRadialGradientSizeKTable[];
+  static const PRInt32 kResizeKTable[];
   static const PRInt32 kSpeakKTable[];
   static const PRInt32 kSpeakHeaderKTable[];
   static const PRInt32 kSpeakNumeralKTable[];
   static const PRInt32 kSpeakPunctuationKTable[];
   static const PRInt32 kSpeechRateKTable[];
   static const PRInt32 kStackSizingKTable[];
   static const PRInt32 kTableLayoutKTable[];
   static const PRInt32 kTextAlignKTable[];
--- a/layout/style/nsCSSStruct.h
+++ b/layout/style/nsCSSStruct.h
@@ -367,16 +367,17 @@ struct nsCSSDisplay : public nsCSSStruct
   nsCSSValue mBinding;
   nsCSSValue mAppearance;
   nsCSSValue mPosition;
   nsCSSValue mFloat;
   nsCSSValue mClear;
   nsCSSRect  mClip;
   nsCSSValue mOverflowX;
   nsCSSValue mOverflowY;
+  nsCSSValue mResize;
   nsCSSValue mPointerEvents;
   nsCSSValue mVisibility;
   nsCSSValue mOpacity;
   nsCSSValueList *mTransform; // List of Arrays containing transform information
   nsCSSValuePair mTransformOrigin;
   nsCSSValueList* mTransitionProperty;
   nsCSSValueList* mTransitionDuration;
   nsCSSValueList* mTransitionTimingFunction;
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -3070,16 +3070,29 @@ nsComputedDOMStyle::GetOverflowY(nsIDOMC
   val->SetIdent(
     nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mOverflowY,
                                    nsCSSProps::kOverflowSubKTable));
 
   return CallQueryInterface(val, aValue);
 }
 
 nsresult
+nsComputedDOMStyle::GetResize(nsIDOMCSSValue** aValue)
+{
+  nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
+  NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
+
+  val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleDisplay()->mResize,
+                                               nsCSSProps::kResizeKTable));
+
+  return CallQueryInterface(val, aValue);
+}
+
+
+nsresult
 nsComputedDOMStyle::GetPageBreakAfter(nsIDOMCSSValue** aValue)
 {
   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
   NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
 
   const nsStyleDisplay *display = GetStyleDisplay();
 
   if (display->mBreakAfter) {
@@ -4527,16 +4540,17 @@ nsComputedDOMStyle::GetQueryableProperty
     COMPUTED_STYLE_MAP_ENTRY(_moz_column_rule_style,        ColumnRuleStyle),
     COMPUTED_STYLE_MAP_ENTRY(float_edge,                    FloatEdge),
     COMPUTED_STYLE_MAP_ENTRY(force_broken_image_icon,  ForceBrokenImageIcon),
     COMPUTED_STYLE_MAP_ENTRY(image_region,                  ImageRegion),
     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_outline_radius_bottomLeft, OutlineRadiusBottomLeft),
     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_outline_radius_bottomRight,OutlineRadiusBottomRight),
     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_outline_radius_topLeft,    OutlineRadiusTopLeft),
     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_outline_radius_topRight,   OutlineRadiusTopRight),
+    COMPUTED_STYLE_MAP_ENTRY(resize,                        Resize),
     COMPUTED_STYLE_MAP_ENTRY(stack_sizing,                  StackSizing),
     COMPUTED_STYLE_MAP_ENTRY(_moz_tab_size,                 MozTabSize),
     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_transform,         MozTransform),
     COMPUTED_STYLE_MAP_ENTRY_LAYOUT(_moz_transform_origin,  MozTransformOrigin),
     COMPUTED_STYLE_MAP_ENTRY(user_focus,                    UserFocus),
     COMPUTED_STYLE_MAP_ENTRY(user_input,                    UserInput),
     COMPUTED_STYLE_MAP_ENTRY(user_modify,                   UserModify),
     COMPUTED_STYLE_MAP_ENTRY(user_select,                   UserSelect),
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -303,16 +303,17 @@ private:
   nsresult GetClear(nsIDOMCSSValue** aValue);
   nsresult GetCssFloat(nsIDOMCSSValue** aValue);
   nsresult GetDisplay(nsIDOMCSSValue** aValue);
   nsresult GetPosition(nsIDOMCSSValue** aValue);
   nsresult GetClip(nsIDOMCSSValue** aValue);
   nsresult GetOverflow(nsIDOMCSSValue** aValue);
   nsresult GetOverflowX(nsIDOMCSSValue** aValue);
   nsresult GetOverflowY(nsIDOMCSSValue** aValue);
+  nsresult GetResize(nsIDOMCSSValue** aValue);
   nsresult GetPageBreakAfter(nsIDOMCSSValue** aValue);
   nsresult GetPageBreakBefore(nsIDOMCSSValue** aValue);
   nsresult GetMozTransform(nsIDOMCSSValue** aValue);
   nsresult GetMozTransformOrigin(nsIDOMCSSValue **aValue);
 
   /* User interface properties */
   nsresult GetCursor(nsIDOMCSSValue** aValue);
   nsresult GetForceBrokenImageIcon(nsIDOMCSSValue** aValue);
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -3979,16 +3979,20 @@ nsRuleNode::ComputeDisplayData(void* aSt
     // If 'visible' is specified but doesn't match the other dimension, it
     // turns into 'auto'.
     if (display->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE)
       display->mOverflowX = NS_STYLE_OVERFLOW_AUTO;
     if (display->mOverflowY == NS_STYLE_OVERFLOW_VISIBLE)
       display->mOverflowY = NS_STYLE_OVERFLOW_AUTO;
   }
 
+  SetDiscrete(displayData.mResize, display->mResize, canStoreInRuleTree,
+              SETDSC_ENUMERATED, parentDisplay->mResize,
+              NS_STYLE_RESIZE_NONE, 0, 0, 0, 0);
+
   // clip property: length, auto, inherit
   if (eCSSUnit_Inherit == displayData.mClip.mTop.GetUnit()) { // if one is inherit, they all are
     canStoreInRuleTree = PR_FALSE;
     display->mClipFlags = parentDisplay->mClipFlags;
     display->mClip = parentDisplay->mClip;
   }
   // if one is initial or auto (rect), they all are
   else if (eCSSUnit_Initial == displayData.mClip.mTop.GetUnit() ||
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1801,16 +1801,17 @@ nsStyleDisplay::nsStyleDisplay()
   mOriginalDisplay = NS_STYLE_DISPLAY_NONE;
   mPosition = NS_STYLE_POSITION_STATIC;
   mFloats = NS_STYLE_FLOAT_NONE;
   mBreakType = NS_STYLE_CLEAR_NONE;
   mBreakBefore = PR_FALSE;
   mBreakAfter = PR_FALSE;
   mOverflowX = NS_STYLE_OVERFLOW_VISIBLE;
   mOverflowY = NS_STYLE_OVERFLOW_VISIBLE;
+  mResize = NS_STYLE_RESIZE_NONE;
   mClipFlags = NS_STYLE_CLIP_AUTO;
   mClip.SetRect(0,0,0,0);
   mOpacity = 1.0f;
   mTransformPresent = PR_FALSE; // No transform
   mTransformOrigin[0].SetPercentValue(0.5f); // Transform is centered on origin
   mTransformOrigin[1].SetPercentValue(0.5f); 
   mTransitions.AppendElement();
   NS_ABORT_IF_FALSE(mTransitions.Length() == 1,
@@ -1836,16 +1837,17 @@ nsStyleDisplay::nsStyleDisplay(const nsS
   mBinding = aSource.mBinding;
   mPosition = aSource.mPosition;
   mFloats = aSource.mFloats;
   mBreakType = aSource.mBreakType;
   mBreakBefore = aSource.mBreakBefore;
   mBreakAfter = aSource.mBreakAfter;
   mOverflowX = aSource.mOverflowX;
   mOverflowY = aSource.mOverflowY;
+  mResize = aSource.mResize;
   mClipFlags = aSource.mClipFlags;
   mClip = aSource.mClip;
   mOpacity = aSource.mOpacity;
 
   /* Copy over the transformation information. */
   mTransformPresent = aSource.mTransformPresent;
   if (mTransformPresent)
     mTransform = aSource.mTransform;
@@ -1859,17 +1861,18 @@ nsChangeHint nsStyleDisplay::CalcDiffere
 {
   nsChangeHint hint = nsChangeHint(0);
 
   if (!EqualURIs(mBinding, aOther.mBinding)
       || mPosition != aOther.mPosition
       || mDisplay != aOther.mDisplay
       || (mFloats == NS_STYLE_FLOAT_NONE) != (aOther.mFloats == NS_STYLE_FLOAT_NONE)
       || mOverflowX != aOther.mOverflowX
-      || mOverflowY != aOther.mOverflowY)
+      || mOverflowY != aOther.mOverflowY
+      || mResize != aOther.mResize)
     NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
 
   if (mFloats != aOther.mFloats) {
     // Changing which side we float on doesn't affect descendants directly
     NS_UpdateHint(hint,
        NS_SubtractHint(nsChangeHint_ReflowFrame,
                        NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
                                       nsChangeHint_NeedDirtyReflow)));
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -1309,16 +1309,17 @@ struct nsStyleDisplay {
   PRUint8 mAppearance;          // [reset]
   PRUint8 mPosition;            // [reset] see nsStyleConsts.h
   PRUint8 mFloats;              // [reset] see nsStyleConsts.h NS_STYLE_FLOAT_*
   PRUint8 mBreakType;           // [reset] see nsStyleConsts.h NS_STYLE_CLEAR_*
   PRPackedBool mBreakBefore;    // [reset] 
   PRPackedBool mBreakAfter;     // [reset] 
   PRUint8 mOverflowX;           // [reset] see nsStyleConsts.h
   PRUint8 mOverflowY;           // [reset] see nsStyleConsts.h
+  PRUint8 mResize;              // [reset] see nsStyleConsts.h
   PRUint8   mClipFlags;         // [reset] see nsStyleConsts.h
   PRPackedBool mTransformPresent;  // [reset] Whether there is a -moz-transform.
   nsStyleTransformMatrix mTransform; // [reset] The stored transform matrix
   nsStyleCoord mTransformOrigin[2]; // [reset] percent, coord.
   nsAutoTArray<nsTransition, 1> mTransitions; // [reset]
   // The number of elements in mTransitions that are not from repeating
   // a list due to another property being longer.
   PRUint32 mTransitionTimingFunctionCount,
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -530,16 +530,25 @@ var gCSSProperties = {
 		inherited: false,
 		type: CSS_TYPE_SHORTHAND_AND_LONGHAND,
 		get_computed: logical_box_prop_get_computed,
 		/* no subproperties */
 		initial_values: [ "0", "0px", "0%", "0em", "0ex" ],
 		other_values: [ "1px", "3em" ],
 		invalid_values: []
 	},
+	"-moz-resize": {
+		domProp: "MozResize",
+		inherited: false,
+		type: CSS_TYPE_LONGHAND,
+		prerequisites: { "display": "block", "overflow": "auto" },
+		initial_values: [ "none" ],
+		other_values: [ "both", "horizontal", "vertical" ],
+		invalid_values: []
+	},
 	"-moz-tab-size": {
 		domProp: "MozTabSize",
 		inherited: true,
 		type: CSS_TYPE_LONGHAND,
 		initial_values: [ "8" ],
 		other_values: [ "0", "3", "99", "12000" ],
 		invalid_values: [ "-1", "-808", "3.0", "17.5" ]
 	},