mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 22:05:44 +00:00
more inline style feedback fixes (24574). r=sfraser
This commit is contained in:
parent
a06aa3ece0
commit
395f325b0c
@ -738,6 +738,7 @@ nsEditorShell::SetAttribute(nsIDOMElement *element, const PRUnichar *attr, const
|
||||
nsAutoString valueStr(value);
|
||||
result = editor->SetAttribute(element, attributeStr, valueStr);
|
||||
}
|
||||
UpdateInterfaceState();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -753,6 +754,7 @@ nsEditorShell::RemoveAttribute(nsIDOMElement *element, const PRUnichar *attr)
|
||||
nsAutoString attributeStr(attr);
|
||||
result = editor->RemoveAttribute(element, attributeStr);
|
||||
}
|
||||
UpdateInterfaceState();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -817,6 +819,7 @@ nsEditorShell::RemoveOneProperty(const nsString& aProp, const nsString &aAttr)
|
||||
err = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
UpdateInterfaceState();
|
||||
NS_RELEASE(styleAtom);
|
||||
return err;
|
||||
}
|
||||
|
@ -1084,24 +1084,45 @@ NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty,
|
||||
if (!collapsedNode) return NS_ERROR_FAILURE;
|
||||
// refresh the cache if we need to
|
||||
if (collapsedNode != mCachedNode) CacheInlineStyles(collapsedNode);
|
||||
// cache now current, use it! But *or* it with typeInState results...
|
||||
PRBool isSet;
|
||||
// cache now current, use it! But override it with typeInState results if any...
|
||||
PRBool isSet, theSetting;
|
||||
if (aProperty == mBoldAtom.get())
|
||||
{
|
||||
GetTypingState(aProperty, isSet);
|
||||
aFirst = aAny = aAll = (mCachedBoldStyle || isSet);
|
||||
GetTypingState(aProperty, isSet, theSetting);
|
||||
if (isSet)
|
||||
{
|
||||
aFirst = aAny = aAll = theSetting;
|
||||
}
|
||||
else
|
||||
{
|
||||
aFirst = aAny = aAll = mCachedBoldStyle;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aProperty == mItalicAtom.get())
|
||||
{
|
||||
GetTypingState(aProperty, isSet);
|
||||
aFirst = aAny = aAll = (mCachedItalicStyle || isSet);
|
||||
GetTypingState(aProperty, isSet, theSetting);
|
||||
if (isSet)
|
||||
{
|
||||
aFirst = aAny = aAll = theSetting;
|
||||
}
|
||||
else
|
||||
{
|
||||
aFirst = aAny = aAll = mCachedItalicStyle;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aProperty == mUnderlineAtom.get())
|
||||
{
|
||||
GetTypingState(aProperty, isSet);
|
||||
aFirst = aAny = aAll = (mCachedUnderlineStyle || isSet);
|
||||
GetTypingState(aProperty, isSet, theSetting);
|
||||
if (isSet)
|
||||
{
|
||||
aFirst = aAny = aAll = theSetting;
|
||||
}
|
||||
else
|
||||
{
|
||||
aFirst = aAny = aAll = mCachedUnderlineStyle;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aProperty == mFontAtom.get())
|
||||
@ -1330,7 +1351,7 @@ NS_IMETHODIMP nsHTMLEditor::DecreaseFontSize()
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::GetTypingState(nsIAtom *aProperty, PRBool &aSet)
|
||||
NS_IMETHODIMP nsHTMLEditor::GetTypingState(nsIAtom *aProperty, PRBool &aPropIsSet, PRBool &aSetting)
|
||||
{
|
||||
if (!aProperty)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
@ -1343,13 +1364,14 @@ NS_IMETHODIMP nsHTMLEditor::GetTypingState(nsIAtom *aProperty, PRBool &aSet)
|
||||
if (styleEnum == NS_TYPEINSTATE_UNKNOWN)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
mTypeInState->GetProp(styleEnum, aSet);
|
||||
aPropIsSet = mTypeInState->IsSet(styleEnum);
|
||||
if (aPropIsSet) mTypeInState->GetProp(styleEnum, aSetting);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::GetTypingStateValue(nsIAtom *aProperty, nsString &aValue)
|
||||
NS_IMETHODIMP nsHTMLEditor::GetTypingStateValue(nsIAtom *aProperty, PRBool &aPropIsSet, nsString &aValue)
|
||||
{
|
||||
if (!aProperty)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
@ -1362,7 +1384,8 @@ NS_IMETHODIMP nsHTMLEditor::GetTypingStateValue(nsIAtom *aProperty, nsString &aV
|
||||
if (styleEnum == NS_TYPEINSTATE_UNKNOWN)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
mTypeInState->GetPropValue(styleEnum, aValue);
|
||||
aPropIsSet = mTypeInState->IsSet(styleEnum);
|
||||
if (aPropIsSet) mTypeInState->GetPropValue(styleEnum, aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -103,8 +103,6 @@ public:
|
||||
NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute);
|
||||
NS_IMETHOD IncreaseFontSize();
|
||||
NS_IMETHOD DecreaseFontSize();
|
||||
NS_IMETHOD GetTypingState(nsIAtom *aProperty, PRBool &aSet);
|
||||
NS_IMETHOD GetTypingStateValue(nsIAtom *aProperty, nsString &aValue);
|
||||
|
||||
NS_IMETHOD InsertBreak();
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
||||
@ -310,6 +308,10 @@ protected:
|
||||
void CacheInlineStyles(nsIDOMNode *aNode);
|
||||
void ClearInlineStylesCache();
|
||||
|
||||
// typing state getters
|
||||
NS_IMETHOD GetTypingState(nsIAtom *aProperty, PRBool &aPropIsSet, PRBool &aSetting);
|
||||
NS_IMETHOD GetTypingStateValue(nsIAtom *aProperty, PRBool &aPropIsSet, nsString &aValue);
|
||||
|
||||
// key event helpers
|
||||
NS_IMETHOD TabInTable(PRBool inIsShift, PRBool *outHandled);
|
||||
NS_IMETHOD CreateBR(nsIDOMNode *aNode, PRInt32 aOffset, nsCOMPtr<nsIDOMNode> *outBRNode);
|
||||
|
@ -738,6 +738,7 @@ nsEditorShell::SetAttribute(nsIDOMElement *element, const PRUnichar *attr, const
|
||||
nsAutoString valueStr(value);
|
||||
result = editor->SetAttribute(element, attributeStr, valueStr);
|
||||
}
|
||||
UpdateInterfaceState();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -753,6 +754,7 @@ nsEditorShell::RemoveAttribute(nsIDOMElement *element, const PRUnichar *attr)
|
||||
nsAutoString attributeStr(attr);
|
||||
result = editor->RemoveAttribute(element, attributeStr);
|
||||
}
|
||||
UpdateInterfaceState();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -817,6 +819,7 @@ nsEditorShell::RemoveOneProperty(const nsString& aProp, const nsString &aAttr)
|
||||
err = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
UpdateInterfaceState();
|
||||
NS_RELEASE(styleAtom);
|
||||
return err;
|
||||
}
|
||||
|
@ -1084,24 +1084,45 @@ NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty,
|
||||
if (!collapsedNode) return NS_ERROR_FAILURE;
|
||||
// refresh the cache if we need to
|
||||
if (collapsedNode != mCachedNode) CacheInlineStyles(collapsedNode);
|
||||
// cache now current, use it! But *or* it with typeInState results...
|
||||
PRBool isSet;
|
||||
// cache now current, use it! But override it with typeInState results if any...
|
||||
PRBool isSet, theSetting;
|
||||
if (aProperty == mBoldAtom.get())
|
||||
{
|
||||
GetTypingState(aProperty, isSet);
|
||||
aFirst = aAny = aAll = (mCachedBoldStyle || isSet);
|
||||
GetTypingState(aProperty, isSet, theSetting);
|
||||
if (isSet)
|
||||
{
|
||||
aFirst = aAny = aAll = theSetting;
|
||||
}
|
||||
else
|
||||
{
|
||||
aFirst = aAny = aAll = mCachedBoldStyle;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aProperty == mItalicAtom.get())
|
||||
{
|
||||
GetTypingState(aProperty, isSet);
|
||||
aFirst = aAny = aAll = (mCachedItalicStyle || isSet);
|
||||
GetTypingState(aProperty, isSet, theSetting);
|
||||
if (isSet)
|
||||
{
|
||||
aFirst = aAny = aAll = theSetting;
|
||||
}
|
||||
else
|
||||
{
|
||||
aFirst = aAny = aAll = mCachedItalicStyle;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aProperty == mUnderlineAtom.get())
|
||||
{
|
||||
GetTypingState(aProperty, isSet);
|
||||
aFirst = aAny = aAll = (mCachedUnderlineStyle || isSet);
|
||||
GetTypingState(aProperty, isSet, theSetting);
|
||||
if (isSet)
|
||||
{
|
||||
aFirst = aAny = aAll = theSetting;
|
||||
}
|
||||
else
|
||||
{
|
||||
aFirst = aAny = aAll = mCachedUnderlineStyle;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aProperty == mFontAtom.get())
|
||||
@ -1330,7 +1351,7 @@ NS_IMETHODIMP nsHTMLEditor::DecreaseFontSize()
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::GetTypingState(nsIAtom *aProperty, PRBool &aSet)
|
||||
NS_IMETHODIMP nsHTMLEditor::GetTypingState(nsIAtom *aProperty, PRBool &aPropIsSet, PRBool &aSetting)
|
||||
{
|
||||
if (!aProperty)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
@ -1343,13 +1364,14 @@ NS_IMETHODIMP nsHTMLEditor::GetTypingState(nsIAtom *aProperty, PRBool &aSet)
|
||||
if (styleEnum == NS_TYPEINSTATE_UNKNOWN)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
mTypeInState->GetProp(styleEnum, aSet);
|
||||
aPropIsSet = mTypeInState->IsSet(styleEnum);
|
||||
if (aPropIsSet) mTypeInState->GetProp(styleEnum, aSetting);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::GetTypingStateValue(nsIAtom *aProperty, nsString &aValue)
|
||||
NS_IMETHODIMP nsHTMLEditor::GetTypingStateValue(nsIAtom *aProperty, PRBool &aPropIsSet, nsString &aValue)
|
||||
{
|
||||
if (!aProperty)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
@ -1362,7 +1384,8 @@ NS_IMETHODIMP nsHTMLEditor::GetTypingStateValue(nsIAtom *aProperty, nsString &aV
|
||||
if (styleEnum == NS_TYPEINSTATE_UNKNOWN)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
mTypeInState->GetPropValue(styleEnum, aValue);
|
||||
aPropIsSet = mTypeInState->IsSet(styleEnum);
|
||||
if (aPropIsSet) mTypeInState->GetPropValue(styleEnum, aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -103,8 +103,6 @@ public:
|
||||
NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute);
|
||||
NS_IMETHOD IncreaseFontSize();
|
||||
NS_IMETHOD DecreaseFontSize();
|
||||
NS_IMETHOD GetTypingState(nsIAtom *aProperty, PRBool &aSet);
|
||||
NS_IMETHOD GetTypingStateValue(nsIAtom *aProperty, nsString &aValue);
|
||||
|
||||
NS_IMETHOD InsertBreak();
|
||||
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
||||
@ -310,6 +308,10 @@ protected:
|
||||
void CacheInlineStyles(nsIDOMNode *aNode);
|
||||
void ClearInlineStylesCache();
|
||||
|
||||
// typing state getters
|
||||
NS_IMETHOD GetTypingState(nsIAtom *aProperty, PRBool &aPropIsSet, PRBool &aSetting);
|
||||
NS_IMETHOD GetTypingStateValue(nsIAtom *aProperty, PRBool &aPropIsSet, nsString &aValue);
|
||||
|
||||
// key event helpers
|
||||
NS_IMETHOD TabInTable(PRBool inIsShift, PRBool *outHandled);
|
||||
NS_IMETHOD CreateBR(nsIDOMNode *aNode, PRInt32 aOffset, nsCOMPtr<nsIDOMNode> *outBRNode);
|
||||
|
@ -145,23 +145,6 @@ public:
|
||||
*/
|
||||
NS_IMETHOD DecreaseFontSize()=0;
|
||||
|
||||
/**
|
||||
* GetTypingState() gets the state for typing (which may differ from that of
|
||||
* the current selection).
|
||||
*
|
||||
* @param aProperty the property to get state for
|
||||
* @param aFirst [OUT] PR_TRUE if the state is set on the current type-in state
|
||||
*/
|
||||
NS_IMETHOD GetTypingState(nsIAtom *aProperty, PRBool &aSet)=0;
|
||||
|
||||
/**
|
||||
* GetTypingStateValue() gets the state for typing (which may differ from that of
|
||||
* the current selection).
|
||||
*
|
||||
* @param aValue the property to get state for
|
||||
* @param aFirst [OUT] the value of the current state
|
||||
*/
|
||||
NS_IMETHOD GetTypingStateValue(nsIAtom *aProperty, nsString &aValue)=0;
|
||||
|
||||
/* ------------ HTML content methods -------------- */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user