зеркало из https://github.com/mozilla/pjs.git
Bug 279246 Implement 'ime-mode' property (WinIE CSS) r+sr=dbaron
This commit is contained in:
Родитель
fb831eea84
Коммит
e728f6004b
|
@ -406,7 +406,7 @@ interface nsIDOMCSS2Properties : nsISupports
|
|||
// raises(DOMException) on setting
|
||||
};
|
||||
|
||||
[scriptable, uuid(06b42e9d-61b5-400d-9561-b43f0e9883c0)]
|
||||
[scriptable, uuid(8c2e3658-1fe4-452a-92be-b0afaf76f897)]
|
||||
interface nsIDOMNSCSS2Properties : nsIDOMCSS2Properties
|
||||
{
|
||||
/* Non-DOM 2 extensions */
|
||||
|
@ -564,4 +564,7 @@ interface nsIDOMNSCSS2Properties : nsIDOMCSS2Properties
|
|||
attribute DOMString overflowY;
|
||||
// raises(DOMException) on setting
|
||||
|
||||
attribute DOMString imeMode;
|
||||
// raises(DOMException) on setting
|
||||
|
||||
};
|
||||
|
|
|
@ -2206,16 +2206,45 @@ NS_IMETHODIMP
|
|||
nsEditor::GetPreferredIMEState(PRUint32 *aState)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aState);
|
||||
*aState = nsIContent::IME_STATUS_ENABLE;
|
||||
|
||||
PRUint32 flags;
|
||||
if (NS_SUCCEEDED(GetFlags(&flags)) &&
|
||||
flags & (nsIPlaintextEditor::eEditorReadonlyMask |
|
||||
nsIPlaintextEditor::eEditorDisabledMask))
|
||||
nsresult rv = GetFlags(&flags);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (flags & (nsIPlaintextEditor::eEditorReadonlyMask |
|
||||
nsIPlaintextEditor::eEditorDisabledMask)) {
|
||||
*aState = nsIContent::IME_STATUS_DISABLE;
|
||||
else if (flags & nsIPlaintextEditor::eEditorPasswordMask)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
rv = GetPresShell(getter_AddRefs(presShell));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
|
||||
|
||||
nsIFrame* frame = presShell->GetPrimaryFrameFor(content);
|
||||
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
|
||||
|
||||
switch (frame->GetStyleUIReset()->mIMEMode) {
|
||||
case NS_STYLE_IME_MODE_AUTO:
|
||||
if (flags & (nsIPlaintextEditor::eEditorPasswordMask))
|
||||
*aState = nsIContent::IME_STATUS_PASSWORD;
|
||||
else
|
||||
*aState = nsIContent::IME_STATUS_ENABLE;
|
||||
break;
|
||||
case NS_STYLE_IME_MODE_DISABLED:
|
||||
// we should use password state for |ime-mode: disabled;|.
|
||||
*aState = nsIContent::IME_STATUS_PASSWORD;
|
||||
break;
|
||||
case NS_STYLE_IME_MODE_ACTIVE:
|
||||
*aState |= nsIContent::IME_STATUS_OPEN;
|
||||
break;
|
||||
case NS_STYLE_IME_MODE_INACTIVE:
|
||||
*aState |= nsIContent::IME_STATUS_CLOSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -653,6 +653,13 @@
|
|||
#define NS_STYLE_COLUMN_COUNT_AUTO 0
|
||||
#define NS_STYLE_COLUMN_COUNT_UNLIMITED (-1)
|
||||
|
||||
// See nsStyleUIReset
|
||||
#define NS_STYLE_IME_MODE_AUTO 0
|
||||
#define NS_STYLE_IME_MODE_NORMAL 1
|
||||
#define NS_STYLE_IME_MODE_ACTIVE 2
|
||||
#define NS_STYLE_IME_MODE_DISABLED 3
|
||||
#define NS_STYLE_IME_MODE_INACTIVE 4
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// See nsStyleSVG
|
||||
|
||||
|
|
|
@ -131,6 +131,7 @@ input > .anonymous-div {
|
|||
/* XXXldb I'm not sure if we really want the 'text-decoration: inherit',
|
||||
but it's needed to make 'text-decoration' "work" on text inputs. */
|
||||
text-decoration: inherit;
|
||||
ime-mode: inherit;
|
||||
}
|
||||
|
||||
select {
|
||||
|
|
|
@ -181,6 +181,7 @@ CSS_KEY(-moz-zoom-in, _moz_zoom_in)
|
|||
CSS_KEY(-moz-zoom-out, _moz_zoom_out)
|
||||
CSS_KEY(above, above)
|
||||
CSS_KEY(absolute, absolute)
|
||||
CSS_KEY(active, active)
|
||||
CSS_KEY(activeborder, activeborder)
|
||||
CSS_KEY(activecaption, activecaption)
|
||||
CSS_KEY(alias, alias)
|
||||
|
@ -284,6 +285,7 @@ CSS_KEY(hz, hz)
|
|||
CSS_KEY(icon, icon)
|
||||
CSS_KEY(ignore, ignore)
|
||||
CSS_KEY(in, in)
|
||||
CSS_KEY(inactive, inactive)
|
||||
CSS_KEY(inactiveborder, inactiveborder)
|
||||
CSS_KEY(inactivecaption, inactivecaption)
|
||||
CSS_KEY(inactivecaptiontext, inactivecaptiontext)
|
||||
|
|
|
@ -4694,6 +4694,9 @@ PRBool CSSParserImpl::ParseSingleValueProperty(nsresult& aErrorCode,
|
|||
nsCSSProps::kFontVariantKTable);
|
||||
case eCSSProperty_font_weight:
|
||||
return ParseFontWeight(aErrorCode, aValue);
|
||||
case eCSSProperty_ime_mode:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_AHK | VARIANT_NORMAL,
|
||||
nsCSSProps::kIMEModeKTable);
|
||||
case eCSSProperty_letter_spacing:
|
||||
case eCSSProperty_word_spacing:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HL | VARIANT_NORMAL, nsnull);
|
||||
|
|
|
@ -339,6 +339,7 @@ CSS_PROP_FONT(font-weight, font_weight, FontWeight, Font, mWeight, eCSSType_Valu
|
|||
CSS_PROP_UIRESET(-moz-force-broken-image-icon, force_broken_image_icon, MozForceBrokenImageIcon, UserInterface, mForceBrokenImageIcon, eCSSType_Value, nsnull) // bug 58646
|
||||
CSS_PROP_POSITION(height, height, Height, Position, mHeight, eCSSType_Value, nsnull)
|
||||
CSS_PROP_LIST(-moz-image-region, image_region, MozImageRegion, List, mImageRegion, eCSSType_Rect, nsnull)
|
||||
CSS_PROP_UIRESET(ime-mode, ime_mode, ImeMode, UserInterface, mIMEMode, eCSSType_Value, kIMEModeKTable)
|
||||
CSS_PROP_POSITION(left, left, Left, Position, mOffset.mLeft, eCSSType_Value, nsnull)
|
||||
CSS_PROP_TEXT(letter-spacing, letter_spacing, LetterSpacing, Text, mLetterSpacing, eCSSType_Value, nsnull)
|
||||
CSS_PROP_TEXT(line-height, line_height, LineHeight, Text, mLineHeight, eCSSType_Value, nsnull)
|
||||
|
|
|
@ -646,6 +646,13 @@ const PRInt32 nsCSSProps::kFontWeightKTable[] = {
|
|||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kIMEModeKTable[] = {
|
||||
eCSSKeyword_active, NS_STYLE_IME_MODE_ACTIVE,
|
||||
eCSSKeyword_disabled, NS_STYLE_IME_MODE_DISABLED,
|
||||
eCSSKeyword_inactive, NS_STYLE_IME_MODE_INACTIVE,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
// XXX What's the point?
|
||||
const PRInt32 nsCSSProps::kKeyEquivalentKTable[] = {
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
|
|
|
@ -159,6 +159,7 @@ public:
|
|||
static const PRInt32 kFontVariantKTable[];
|
||||
static const PRInt32 kFontWeightKTable[];
|
||||
static const PRInt32 kKeyEquivalentKTable[];
|
||||
static const PRInt32 kIMEModeKTable[];
|
||||
static const PRInt32 kListStylePositionKTable[];
|
||||
static const PRInt32 kListStyleKTable[];
|
||||
static const PRInt32 kOutlineStyleKTable[];
|
||||
|
|
|
@ -565,7 +565,8 @@ nsCSSUserInterface::nsCSSUserInterface(const nsCSSUserInterface& aCopy)
|
|||
mUserSelect(aCopy.mUserSelect),
|
||||
mUserFocus(aCopy.mUserFocus),
|
||||
mCursor(nsnull),
|
||||
mForceBrokenImageIcon(aCopy.mForceBrokenImageIcon)
|
||||
mForceBrokenImageIcon(aCopy.mForceBrokenImageIcon),
|
||||
mIMEMode(aCopy.mIMEMode)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCSSUserInterface);
|
||||
CSS_IF_COPY(mCursor, nsCSSValueList);
|
||||
|
|
|
@ -427,6 +427,7 @@ struct nsCSSUserInterface : public nsCSSStruct { // NEW
|
|||
|
||||
nsCSSValueList* mCursor;
|
||||
nsCSSValue mForceBrokenImageIcon;
|
||||
nsCSSValue mIMEMode;
|
||||
};
|
||||
|
||||
struct nsRuleDataUserInterface : public nsCSSUserInterface {
|
||||
|
|
|
@ -1896,6 +1896,27 @@ nsComputedDOMStyle::GetFloatEdge(nsIDOMCSSValue** aValue)
|
|||
return CallQueryInterface(val, aValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComputedDOMStyle::GetIMEMode(nsIDOMCSSValue** aValue)
|
||||
{
|
||||
nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
|
||||
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
const nsStyleUIReset *uiData = GetStyleUIReset();
|
||||
|
||||
nsCSSKeyword keyword;
|
||||
if (uiData->mIMEMode == NS_STYLE_IME_MODE_AUTO) {
|
||||
keyword = eCSSKeyword_auto;
|
||||
} else if (uiData->mIMEMode == NS_STYLE_IME_MODE_NORMAL) {
|
||||
keyword = eCSSKeyword_normal;
|
||||
} else {
|
||||
keyword = nsCSSProps::ValueToKeywordEnum(uiData->mIMEMode,
|
||||
nsCSSProps::kIMEModeKTable);
|
||||
}
|
||||
val->SetIdent(nsCSSKeywords::GetStringValue(keyword));
|
||||
|
||||
return CallQueryInterface(val, aValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComputedDOMStyle::GetUserFocus(nsIDOMCSSValue** aValue)
|
||||
|
@ -2960,6 +2981,7 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength)
|
|||
COMPUTED_STYLE_MAP_ENTRY(max_width, MaxWidth),
|
||||
COMPUTED_STYLE_MAP_ENTRY(min_height, MinHeight),
|
||||
COMPUTED_STYLE_MAP_ENTRY(min_width, MinWidth),
|
||||
COMPUTED_STYLE_MAP_ENTRY(ime_mode, IMEMode),
|
||||
COMPUTED_STYLE_MAP_ENTRY(opacity, Opacity),
|
||||
// COMPUTED_STYLE_MAP_ENTRY(orphans, Orphans),
|
||||
//// COMPUTED_STYLE_MAP_ENTRY(outline, Outline),
|
||||
|
|
|
@ -255,6 +255,7 @@ private:
|
|||
|
||||
/* User interface properties */
|
||||
nsresult GetCursor(nsIDOMCSSValue** aValue);
|
||||
nsresult GetIMEMode(nsIDOMCSSValue** aValue);
|
||||
nsresult GetUserFocus(nsIDOMCSSValue** aValue);
|
||||
nsresult GetUserInput(nsIDOMCSSValue** aValue);
|
||||
nsresult GetUserModify(nsIDOMCSSValue** aValue);
|
||||
|
|
|
@ -2616,6 +2616,22 @@ nsRuleNode::ComputeUIResetData(nsStyleStruct* aStartStruct,
|
|||
ui->mUserSelect = parentUI->mUserSelect;
|
||||
}
|
||||
|
||||
// ime-mode: auto, normal, enum, inherit
|
||||
if (eCSSUnit_Auto == uiData.mIMEMode.GetUnit() ||
|
||||
eCSSUnit_Initial == uiData.mIMEMode.GetUnit()) {
|
||||
ui->mIMEMode = NS_STYLE_IME_MODE_AUTO;
|
||||
}
|
||||
else if (eCSSUnit_Normal == uiData.mIMEMode.GetUnit()) {
|
||||
ui->mIMEMode = NS_STYLE_IME_MODE_NORMAL;
|
||||
}
|
||||
else if (eCSSUnit_Enumerated == uiData.mIMEMode.GetUnit()) {
|
||||
ui->mIMEMode = uiData.mIMEMode.GetIntValue();
|
||||
}
|
||||
else if (eCSSUnit_Inherit == uiData.mIMEMode.GetUnit()) {
|
||||
inherited = PR_TRUE;
|
||||
ui->mIMEMode = parentUI->mIMEMode;
|
||||
}
|
||||
|
||||
// force-broken-image-icons: integer
|
||||
if (eCSSUnit_Integer == uiData.mForceBrokenImageIcon.GetUnit()) {
|
||||
ui->mForceBrokenImageIcon = uiData.mForceBrokenImageIcon.GetIntValue();
|
||||
|
|
|
@ -820,8 +820,9 @@ void nsStyleContext::DumpRegressionData(nsPresContext* aPresContext, FILE* out,
|
|||
// UIReset
|
||||
IndentBy(out,aIndent);
|
||||
const nsStyleUIReset* uiReset = GetStyleUIReset();
|
||||
fprintf(out, "<uireset data=\"%d\" />\n",
|
||||
(int)uiReset->mUserSelect);
|
||||
fprintf(out, "<uireset data=\"%d %d\" />\n",
|
||||
(int)uiReset->mUserSelect,
|
||||
(int)uiReset->mIMEMode);
|
||||
|
||||
// Column
|
||||
IndentBy(out,aIndent);
|
||||
|
|
|
@ -1643,12 +1643,14 @@ nsStyleUIReset::nsStyleUIReset(void)
|
|||
{
|
||||
mUserSelect = NS_STYLE_USER_SELECT_AUTO;
|
||||
mForceBrokenImageIcon = 0;
|
||||
mIMEMode = NS_STYLE_IME_MODE_AUTO;
|
||||
}
|
||||
|
||||
nsStyleUIReset::nsStyleUIReset(const nsStyleUIReset& aSource)
|
||||
{
|
||||
mUserSelect = aSource.mUserSelect;
|
||||
mForceBrokenImageIcon = aSource.mForceBrokenImageIcon;
|
||||
mIMEMode = aSource.mIMEMode;
|
||||
}
|
||||
|
||||
nsStyleUIReset::~nsStyleUIReset(void)
|
||||
|
@ -1657,6 +1659,7 @@ nsStyleUIReset::~nsStyleUIReset(void)
|
|||
|
||||
nsChangeHint nsStyleUIReset::CalcDifference(const nsStyleUIReset& aOther) const
|
||||
{
|
||||
// ignore mIMEMode
|
||||
if (mForceBrokenImageIcon == aOther.mForceBrokenImageIcon) {
|
||||
if (mUserSelect == aOther.mUserSelect) {
|
||||
return NS_STYLE_HINT_NONE;
|
||||
|
|
|
@ -1125,6 +1125,7 @@ struct nsStyleUIReset: public nsStyleStruct {
|
|||
|
||||
PRUint8 mUserSelect; // [reset] (selection-style)
|
||||
PRUint8 mForceBrokenImageIcon; // [reset] (0 if not forcing, otherwise forcing)
|
||||
PRUint8 mIMEMode; // [reset]
|
||||
};
|
||||
|
||||
struct nsCursorImage {
|
||||
|
|
|
@ -871,6 +871,14 @@ var gCSSProperties = {
|
|||
other_values: [ "15px", "3em", "15%" ],
|
||||
invalid_values: [ "none", "-moz-intrinsic", "-moz-min-intrinsic", "-moz-shrink-wrap", "-moz-fill" ]
|
||||
},
|
||||
"ime-mode": {
|
||||
domProp: "imeMode",
|
||||
inherited: false,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "auto" ],
|
||||
other_values: [ "normal", "disabled", "active", "inactive" ],
|
||||
invalid_values: [ "none", "enabled", "1px" ]
|
||||
},
|
||||
"left": {
|
||||
domProp: "left",
|
||||
inherited: false,
|
||||
|
|
Загрузка…
Ссылка в новой задаче