mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 487d16b80087 (bug 812638) for mochitest orange.
This commit is contained in:
parent
a15d79a6d5
commit
4fb6d21629
@ -183,6 +183,45 @@ void ProcessMarginRightValue(const nsAString * aInputString, nsAString & aOutput
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void ProcessFontSizeValue(const nsAString* aInputString, nsAString& aOutputString,
|
||||
const char* aDefaultValueString,
|
||||
const char* aPrependString, const char* aAppendString)
|
||||
{
|
||||
aOutputString.Truncate();
|
||||
if (aInputString) {
|
||||
int32_t size = nsContentUtils::ParseLegacyFontSize(*aInputString);
|
||||
switch (size) {
|
||||
case 0:
|
||||
// Didn't parse
|
||||
return;
|
||||
case 1:
|
||||
aOutputString.AssignLiteral("x-small");
|
||||
return;
|
||||
case 2:
|
||||
aOutputString.AssignLiteral("small");
|
||||
return;
|
||||
case 3:
|
||||
aOutputString.AssignLiteral("medium");
|
||||
return;
|
||||
case 4:
|
||||
aOutputString.AssignLiteral("large");
|
||||
return;
|
||||
case 5:
|
||||
aOutputString.AssignLiteral("x-large");
|
||||
return;
|
||||
case 6:
|
||||
aOutputString.AssignLiteral("xx-large");
|
||||
return;
|
||||
case 7:
|
||||
// No corresponding CSS size
|
||||
return;
|
||||
default:
|
||||
NS_NOTREACHED("Unexpected return value from ParseLegacyFontSize");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable boldEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_font_weight, ProcessBValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
@ -218,6 +257,11 @@ const nsHTMLCSSUtils::CSSEquivTable fontFaceEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable fontSizeEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_font_size, ProcessFontSizeValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
};
|
||||
|
||||
const nsHTMLCSSUtils::CSSEquivTable bgcolorEquivTable[] = {
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_background_color, ProcessSameValue, nullptr, nullptr, nullptr, true, false },
|
||||
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
|
||||
@ -303,19 +347,21 @@ nsHTMLCSSUtils::~nsHTMLCSSUtils()
|
||||
bool
|
||||
nsHTMLCSSUtils::IsCSSEditableProperty(nsIDOMNode* aNode,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute)
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue)
|
||||
{
|
||||
NS_ASSERTION(aNode, "Shouldn't you pass aNode? - Bug 214025");
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(content, false);
|
||||
return IsCSSEditableProperty(content, aProperty, aAttribute);
|
||||
return IsCSSEditableProperty(content, aProperty, aAttribute, aValue);
|
||||
}
|
||||
|
||||
bool
|
||||
nsHTMLCSSUtils::IsCSSEditableProperty(nsIContent* aNode,
|
||||
nsIAtom* aProperty,
|
||||
const nsAString* aAttribute)
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
|
||||
@ -341,6 +387,16 @@ nsHTMLCSSUtils::IsCSSEditableProperty(nsIContent* aNode,
|
||||
return true;
|
||||
}
|
||||
|
||||
// FONT SIZE doesn't work if the value is 7
|
||||
if (nsEditProperty::font == aProperty && aAttribute &&
|
||||
aAttribute->EqualsLiteral("size")) {
|
||||
if (!aValue || aValue->IsEmpty()) {
|
||||
return true;
|
||||
}
|
||||
int32_t size = nsContentUtils::ParseLegacyFontSize(*aValue);
|
||||
return size && size != 7;
|
||||
}
|
||||
|
||||
// ALIGN attribute on elements supporting it
|
||||
if (aAttribute && (aAttribute->EqualsLiteral("align")) &&
|
||||
(nsEditProperty::div == tagName
|
||||
@ -852,6 +908,9 @@ nsHTMLCSSUtils::GenerateCSSDeclarationsFromHTMLStyle(dom::Element* aElement,
|
||||
} else if (nsEditProperty::font == aHTMLProperty &&
|
||||
aAttribute->EqualsLiteral("face")) {
|
||||
equivTable = fontFaceEquivTable;
|
||||
} else if (nsEditProperty::font == aHTMLProperty &&
|
||||
aAttribute->EqualsLiteral("size")) {
|
||||
equivTable = fontSizeEquivTable;
|
||||
} else if (aAttribute->EqualsLiteral("bgcolor")) {
|
||||
equivTable = bgcolorEquivTable;
|
||||
} else if (aAttribute->EqualsLiteral("background")) {
|
||||
@ -930,7 +989,8 @@ nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
||||
{
|
||||
nsCOMPtr<dom::Element> element = do_QueryInterface(aNode);
|
||||
*aCount = 0;
|
||||
if (!element || !IsCSSEditableProperty(element, aHTMLProperty, aAttribute)) {
|
||||
if (!element || !IsCSSEditableProperty(element, aHTMLProperty,
|
||||
aAttribute, aValue)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1006,7 +1066,8 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsINode* aNode,
|
||||
nsCOMPtr<dom::Element> theElement = GetElementContainerOrSelf(aNode);
|
||||
NS_ENSURE_TRUE(theElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
if (!theElement || !IsCSSEditableProperty(theElement, aHTMLProperty, aAttribute)) {
|
||||
if (!theElement || !IsCSSEditableProperty(theElement, aHTMLProperty,
|
||||
aAttribute, &aValueString)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1183,6 +1244,19 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode *aNode,
|
||||
!valueStringLower.EqualsLiteral("serif");
|
||||
}
|
||||
return NS_OK;
|
||||
} else if (nsEditProperty::font == aHTMLProperty && aHTMLAttribute &&
|
||||
aHTMLAttribute->EqualsLiteral("size")) {
|
||||
if (htmlValueString.IsEmpty()) {
|
||||
aIsSet = true;
|
||||
} else {
|
||||
int32_t size = nsContentUtils::ParseLegacyFontSize(htmlValueString);
|
||||
aIsSet = (size == 1 && valueString.EqualsLiteral("x-small")) ||
|
||||
(size == 2 && valueString.EqualsLiteral("small")) ||
|
||||
(size == 3 && valueString.EqualsLiteral("medium")) ||
|
||||
(size == 4 && valueString.EqualsLiteral("large")) ||
|
||||
(size == 5 && valueString.EqualsLiteral("x-large")) ||
|
||||
(size == 6 && valueString.EqualsLiteral("xx-large"));
|
||||
}
|
||||
} else if (aHTMLAttribute && aHTMLAttribute->EqualsLiteral("align")) {
|
||||
aIsSet = true;
|
||||
} else {
|
||||
|
@ -82,9 +82,18 @@ public:
|
||||
* @param aProperty [IN] an atom containing a HTML tag name
|
||||
* @param aAttribute [IN] a string containing the name of a HTML
|
||||
* attribute carried by the element above
|
||||
* @param aValue [IN] an optional string containing the attribute's
|
||||
* HTML value -- this matters for <font size>,
|
||||
* since size=7 has no CSS equivalent. Make sure
|
||||
* you pass the HTML value (e.g. "4"), not the
|
||||
* CSS value (e.g. "large").
|
||||
*/
|
||||
bool IsCSSEditableProperty(nsIContent* aNode, nsIAtom* aProperty, const nsAString* aAttribute);
|
||||
bool IsCSSEditableProperty(nsIDOMNode* aNode, nsIAtom* aProperty, const nsAString* aAttribute);
|
||||
bool IsCSSEditableProperty(nsIContent* aNode, nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue = nullptr);
|
||||
bool IsCSSEditableProperty(nsIDOMNode* aNode, nsIAtom* aProperty,
|
||||
const nsAString* aAttribute,
|
||||
const nsAString* aValue = nullptr);
|
||||
|
||||
/** adds/remove a CSS declaration to the STYLE atrribute carried by a given element
|
||||
*
|
||||
|
@ -312,7 +312,8 @@ nsHTMLEditor::IsSimpleModifiableNode(nsIContent* aContent,
|
||||
// No luck so far. Now we check for a <span> with a single style=""
|
||||
// attribute that sets only the style we're looking for, if this type of
|
||||
// style supports it
|
||||
if (!mHTMLCSSUtils->IsCSSEditableProperty(element, aProperty, aAttribute) ||
|
||||
if (!mHTMLCSSUtils->IsCSSEditableProperty(element, aProperty,
|
||||
aAttribute, aValue) ||
|
||||
!element->IsHTML(nsGkAtoms::span) || element->GetAttrCount() != 1 ||
|
||||
!element->HasAttr(kNameSpaceID_None, nsGkAtoms::style)) {
|
||||
return false;
|
||||
@ -360,7 +361,8 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
|
||||
|
||||
// don't need to do anything if property already set on node
|
||||
bool bHasProp;
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty, aAttribute)) {
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty,
|
||||
aAttribute, aValue)) {
|
||||
// the HTML styles defined by aProperty/aAttribute has a CSS equivalence
|
||||
// in this implementation for node; let's check if it carries those css styles
|
||||
nsAutoString value(*aValue);
|
||||
@ -469,7 +471,8 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent* aNode,
|
||||
}
|
||||
|
||||
// don't need to do anything if property already set on node
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(aNode, aProperty, aAttribute)) {
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(aNode, aProperty,
|
||||
aAttribute, aValue)) {
|
||||
if (mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(
|
||||
aNode, aProperty, aAttribute, *aValue, nsHTMLCSSUtils::eComputed)) {
|
||||
return NS_OK;
|
||||
@ -480,7 +483,8 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent* aNode,
|
||||
}
|
||||
|
||||
bool useCSS = (IsCSSEnabled() &&
|
||||
mHTMLCSSUtils->IsCSSEditableProperty(aNode, aProperty, aAttribute)) ||
|
||||
mHTMLCSSUtils->IsCSSEditableProperty(aNode, aProperty,
|
||||
aAttribute, aValue)) ||
|
||||
// bgcolor is always done using CSS
|
||||
aAttribute->EqualsLiteral("bgcolor");
|
||||
|
||||
@ -1153,7 +1157,11 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(collapsedNode, aProperty, aAttribute)) {
|
||||
// Bug 747889: we don't support CSS for fontSize values
|
||||
if ((aProperty != nsEditProperty::font ||
|
||||
!aAttribute->EqualsLiteral("size")) &&
|
||||
mHTMLCSSUtils->IsCSSEditableProperty(collapsedNode, aProperty,
|
||||
aAttribute)) {
|
||||
mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(
|
||||
collapsedNode, aProperty, aAttribute, isSet, tOutString,
|
||||
nsHTMLCSSUtils::eComputed);
|
||||
@ -1237,7 +1245,11 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
|
||||
|
||||
bool isSet = false;
|
||||
if (first) {
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty, aAttribute)){
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty,
|
||||
aAttribute) &&
|
||||
// Bug 747889: we don't support CSS for fontSize values
|
||||
(aProperty != nsEditProperty::font ||
|
||||
!aAttribute->EqualsLiteral("size"))) {
|
||||
// the HTML styles defined by aProperty/aAttribute has a CSS
|
||||
// equivalence in this implementation for node; let's check if it
|
||||
// carries those css styles
|
||||
@ -1256,7 +1268,11 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
|
||||
*outValue = firstValue;
|
||||
}
|
||||
} else {
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty, aAttribute)){
|
||||
if (mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty,
|
||||
aAttribute) &&
|
||||
// Bug 747889: we don't support CSS for fontSize values
|
||||
(aProperty != nsEditProperty::font ||
|
||||
!aAttribute->EqualsLiteral("size"))) {
|
||||
// the HTML styles defined by aProperty/aAttribute has a CSS equivalence
|
||||
// in this implementation for node; let's check if it carries those css styles
|
||||
if (aValue) {
|
||||
|
@ -19,7 +19,6 @@ var knownFailures = {
|
||||
},
|
||||
'a' : {
|
||||
'createbookmark-0' : true,
|
||||
'fontsize-1' : true,
|
||||
'subscript-1' : true,
|
||||
'superscript-1' : true,
|
||||
},
|
||||
@ -35,10 +34,6 @@ var knownFailures = {
|
||||
'fontsize-1' : true,
|
||||
'fontsize-2' : true,
|
||||
},
|
||||
'c': {
|
||||
'fontsize-1' : true,
|
||||
'fontsize-2' : true,
|
||||
},
|
||||
};
|
||||
|
||||
function isKnownFailure(type, test, param) {
|
||||
|
@ -20,9 +20,6 @@ const knownFailures = {
|
||||
"AC-Proposed-SUP_TEXT-1_SI-dM": true,
|
||||
"AC-Proposed-SUP_TEXT-1_SI-body": true,
|
||||
"AC-Proposed-SUP_TEXT-1_SI-div": true,
|
||||
"AC-Proposed-FS:2_TEXT-1_SI-dM": true,
|
||||
"AC-Proposed-FS:2_TEXT-1_SI-body": true,
|
||||
"AC-Proposed-FS:2_TEXT-1_SI-div": true,
|
||||
"AC-Proposed-FS:18px_TEXT-1_SI-dM": true,
|
||||
"AC-Proposed-FS:18px_TEXT-1_SI-body": true,
|
||||
"AC-Proposed-FS:18px_TEXT-1_SI-div": true,
|
||||
@ -44,9 +41,6 @@ const knownFailures = {
|
||||
"C-Proposed-FS:1_SPAN.ass.s:fs:large-1_SW-dM": true,
|
||||
"C-Proposed-FS:1_SPAN.ass.s:fs:large-1_SW-body": true,
|
||||
"C-Proposed-FS:1_SPAN.ass.s:fs:large-1_SW-div": true,
|
||||
"C-Proposed-FS:5_FONTsz:1.s:fs:xs-1_SW-dM": true,
|
||||
"C-Proposed-FS:5_FONTsz:1.s:fs:xs-1_SW-body": true,
|
||||
"C-Proposed-FS:5_FONTsz:1.s:fs:xs-1_SW-div": true,
|
||||
"C-Proposed-FS:larger_FONTsz:4-dM": true,
|
||||
"C-Proposed-FS:larger_FONTsz:4-body": true,
|
||||
"C-Proposed-FS:larger_FONTsz:4-div": true,
|
||||
@ -83,18 +77,9 @@ const knownFailures = {
|
||||
"CC-Proposed-FN:c_FONTf:a-2_SL-dM": true,
|
||||
"CC-Proposed-FN:c_FONTf:a-2_SL-body": true,
|
||||
"CC-Proposed-FN:c_FONTf:a-2_SL-div": true,
|
||||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-div": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-div": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:l-1_SW-div": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:18px-1_SW-dM": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:18px-1_SW-body": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:18px-1_SW-div": true,
|
||||
"CC-Proposed-FS:larger_SPANs:fs:l-1_SI-dM": true,
|
||||
"CC-Proposed-FS:larger_SPANs:fs:l-1_SI-body": true,
|
||||
"CC-Proposed-FS:larger_SPANs:fs:l-1_SI-div": true,
|
||||
@ -678,9 +663,6 @@ const knownFailures = {
|
||||
"C-Proposed-FS:1_SPAN.ass.s:fs:large-1_SW-dM": true,
|
||||
"C-Proposed-FS:1_SPAN.ass.s:fs:large-1_SW-body": true,
|
||||
"C-Proposed-FS:1_SPAN.ass.s:fs:large-1_SW-div": true,
|
||||
"C-Proposed-FS:5_FONTsz:1.s:fs:xs-1_SW-dM": true,
|
||||
"C-Proposed-FS:5_FONTsz:1.s:fs:xs-1_SW-body": true,
|
||||
"C-Proposed-FS:5_FONTsz:1.s:fs:xs-1_SW-div": true,
|
||||
"C-Proposed-FS:2_FONTc:b.sz:6-1_SI-dM": true,
|
||||
"C-Proposed-FS:2_FONTc:b.sz:6-1_SI-body": true,
|
||||
"C-Proposed-FS:2_FONTc:b.sz:6-1_SI-div": true,
|
||||
@ -726,18 +708,9 @@ const knownFailures = {
|
||||
"CC-Proposed-FN:c_FONTf:a-2_SL-dM": true,
|
||||
"CC-Proposed-FN:c_FONTf:a-2_SL-body": true,
|
||||
"CC-Proposed-FN:c_FONTf:a-2_SL-div": true,
|
||||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-div": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-div": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:l-1_SW-div": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:18px-1_SW-dM": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:18px-1_SW-body": true,
|
||||
"CC-Proposed-FS:4_SPANs:fs:18px-1_SW-div": true,
|
||||
"CC-Proposed-FS:larger_SPANs:fs:l-1_SI-dM": true,
|
||||
"CC-Proposed-FS:larger_SPANs:fs:l-1_SI-body": true,
|
||||
"CC-Proposed-FS:larger_SPANs:fs:l-1_SI-div": true,
|
||||
|
@ -21,16 +21,47 @@ function parseFontSizeTodo(input, expected) {
|
||||
}
|
||||
|
||||
function parseFontSizeInner(input, expected, fn) {
|
||||
// First test non-CSS
|
||||
document.execCommand("styleWithCSS", false, false);
|
||||
div.innerHTML = "foo";
|
||||
getSelection().selectAllChildren(div);
|
||||
document.execCommand("fontSize", false, input);
|
||||
if (expected === null) {
|
||||
fn(div.innerHTML, "foo",
|
||||
'execCommand("fontSize", false, "' + input + '") should be no-op');
|
||||
'execCommand("fontSize", false, "' + input + '") should be no-op ' +
|
||||
'(non-CSS)');
|
||||
} else {
|
||||
fn(div.innerHTML, '<font size="' + expected + '">foo</font>',
|
||||
'execCommand("fontSize", false, "' + input + '") should parse to ' +
|
||||
expected);
|
||||
expected + ' (non-CSS)');
|
||||
}
|
||||
|
||||
// Now test CSS
|
||||
document.execCommand("styleWithCSS", false, true);
|
||||
div.innerHTML = "foo";
|
||||
getSelection().selectAllChildren(div);
|
||||
document.execCommand("fontSize", false, input);
|
||||
if (expected === null) {
|
||||
fn(div.innerHTML, "foo",
|
||||
'execCommand("fontSize", false, "' + input + '") should be no-op ' +
|
||||
'(CSS)');
|
||||
} else if (expected === 7) {
|
||||
// No CSS support for <font size=7>
|
||||
fn(div.innerHTML, '<font size="' + expected + '">foo</font>',
|
||||
'execCommand("fontSize", false, "' + input + '") should parse to ' +
|
||||
expected + ' (CSS)');
|
||||
} else {
|
||||
var cssVal = {
|
||||
1: "x-small",
|
||||
2: "small",
|
||||
3: "medium",
|
||||
4: "large",
|
||||
5: "x-large",
|
||||
6: "xx-large",
|
||||
}[expected];
|
||||
fn(div.innerHTML, '<span style="font-size: ' + cssVal + ';">foo</span>',
|
||||
'execCommand("fontSize", false, "' + input + '") should parse to ' +
|
||||
expected + ' (CSS)');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user