+2010-09-09 Dirk Pranke <dpranke@chromium.org>
+
+ Unreviewed, rolling out r67145.
+ http://trac.webkit.org/changeset/67145
+ https://bugs.webkit.org/show_bug.cgi?id=45431
+
+ broke editing/inserting/5994480-2.html on Chromium Linux
+
+ * editing/deleting/delete-br-012-expected.txt:
+ * editing/deleting/delete-select-all-001-expected.txt:
+ * editing/execCommand/query-font-size-expected.txt:
+ * editing/execCommand/query-font-size.html:
+ * editing/inserting/5994480-2-expected.txt:
+ * editing/style/block-style-004-expected.txt:
+ * editing/style/block-style-005-expected.txt:
+ * editing/style/block-style-006-expected.txt:
+ * editing/style/fontsize-1-expected.txt:
+ * editing/style/push-down-font-styles-expected.txt: Removed.
+ * editing/style/push-down-font-styles.html: Removed.
+ * editing/style/script-tests/push-down-font-styles.js: Removed.
+
2010-09-09 Dirk Pranke <dpranke@chromium.org>
Unreviewed, expectations update.
| style="border-style:solid; border-color:blue;"
| <font>
| class="Apple-style-span"
-| size="5"
-| <#selection-caret>
-| <br>
+| size="6"
+| <span>
+| class="Apple-style-span"
+| style="font-size: 24px;"
+| <#selection-caret>
+| <br>
| "
"
| "
-execDeleteCommand: <font class="Apple-style-span" size="3"><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br></span></font>
+execDeleteCommand: <span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-size: medium;"><br></span>
test html queryCommandValue result
-execCommand('FontSize', -2) <font class="Apple-style-span" size="1">test</font> 1
-execCommand('FontSize', -1) <font class="Apple-style-span" size="2">test</font> 2
-execCommand('FontSize', 0) test 3
-execCommand('FontSize', 1) <font class="Apple-style-span" size="1">test</font> 1
-execCommand('FontSize', 2) <font class="Apple-style-span" size="2">test</font> 2
-execCommand('FontSize', 3) test 3
-execCommand('FontSize', 4) <font class="Apple-style-span" size="4">test</font> 4
-execCommand('FontSize', 5) <font class="Apple-style-span" size="5">test</font> 5
-execCommand('FontSize', 6) <font class="Apple-style-span" size="6">test</font> 6
-execCommand('FontSize', 7) <font class="Apple-style-span" size="7">test</font> 7
-execCommand('FontSize', '8px') <font class="Apple-style-span" size="7">test</font> 7
-execCommand('FontSize', '2px') <font class="Apple-style-span" size="2">test</font> 2
+execCommand('FontSize', -2) <span class="Apple-style-span" style="font-size: x-small;">test</span> 1
+execCommand('FontSize', -1) <span class="Apple-style-span" style="font-size: small;">test</span> 2
+execCommand('FontSize', 0) <span>test</span> 3
+execCommand('FontSize', 1) <span class="Apple-style-span" style="font-size: x-small;">test</span> 1
+execCommand('FontSize', 2) <span class="Apple-style-span" style="font-size: small;">test</span> 2
+execCommand('FontSize', 3) <span>test</span> 3
+execCommand('FontSize', 4) <span class="Apple-style-span" style="font-size: large;">test</span> 4
+execCommand('FontSize', 5) <span class="Apple-style-span" style="font-size: x-large;">test</span> 5
+execCommand('FontSize', 6) <span class="Apple-style-span" style="font-size: xx-large;">test</span> 6
+execCommand('FontSize', 7) <span class="Apple-style-span" style="font-size: -webkit-xxx-large;">test</span> 7
+execCommand('FontSize', '8px') <span class="Apple-style-span" style="font-size: -webkit-xxx-large;">test</span> 7
+execCommand('FontSize', '2px') <span class="Apple-style-span" style="font-size: small;">test</span> 2
manual CSS font-size: 3px <span style="font-size: 3px">test</span> 1
manual CSS font-size: 0.2em <span style="font-size: 0.2em">test</span> 1
manual CSS font-size: 17px <span style="font-size: 17px">test</span> 4
manual CSS font-size: 5em <span style="font-size: 5em">test</span> 7
manual CSS font-size: 10px <span style="font-size: 10px">test</span> 1
monospace tests to ensure the bug 19161 does not affect queryCommandValue's values
-execCommand('FontSize', -2) <font class="Apple-style-span" size="1"><font class="Apple-style-span" face="monospace">test</font></font> 1
-execCommand('FontSize', -1) <font class="Apple-style-span" size="2"><font class="Apple-style-span" face="monospace">test</font></font> 2
-execCommand('FontSize', 0) <font class="Apple-style-span" face="monospace">test</font> 3
-execCommand('FontSize', 1) <font class="Apple-style-span" size="1"><font class="Apple-style-span" face="monospace">test</font></font> 1
-execCommand('FontSize', 2) <font class="Apple-style-span" size="2"><font class="Apple-style-span" face="monospace">test</font></font> 2
-execCommand('FontSize', 3) <font class="Apple-style-span" face="monospace">test</font> 3
-execCommand('FontSize', 4) <font class="Apple-style-span" size="4"><font class="Apple-style-span" face="monospace">test</font></font> 4
-execCommand('FontSize', 5) <font class="Apple-style-span" size="5"><font class="Apple-style-span" face="monospace">test</font></font> 5
-execCommand('FontSize', 6) <font class="Apple-style-span" size="6"><font class="Apple-style-span" face="monospace">test</font></font> 6
-execCommand('FontSize', 7) <font class="Apple-style-span" size="7"><font class="Apple-style-span" face="monospace">test</font></font> 7
+execCommand('FontSize', -2) <span class="Apple-style-span" style="font-size: x-small;"><font class="Apple-style-span" face="monospace">test</font></span> 1
+execCommand('FontSize', -1) <span class="Apple-style-span" style="font-size: small;"><font class="Apple-style-span" face="monospace">test</font></span> 2
+execCommand('FontSize', 0) <span><font class="Apple-style-span" face="monospace">test</font></span> 3
+execCommand('FontSize', 1) <span class="Apple-style-span" style="font-size: x-small;"><font class="Apple-style-span" face="monospace">test</font></span> 1
+execCommand('FontSize', 2) <span class="Apple-style-span" style="font-size: small;"><font class="Apple-style-span" face="monospace">test</font></span> 2
+execCommand('FontSize', 3) <span><font class="Apple-style-span" face="monospace">test</font></span> 3
+execCommand('FontSize', 4) <span class="Apple-style-span" style="font-size: large;"><font class="Apple-style-span" face="monospace">test</font></span> 4
+execCommand('FontSize', 5) <span class="Apple-style-span" style="font-size: x-large;"><font class="Apple-style-span" face="monospace">test</font></span> 5
+execCommand('FontSize', 6) <span class="Apple-style-span" style="font-size: xx-large;"><font class="Apple-style-span" face="monospace">test</font></span> 6
+execCommand('FontSize', 7) <span class="Apple-style-span" style="font-size: -webkit-xxx-large;"><font class="Apple-style-span" face="monospace">test</font></span> 7
return editableDiv.firstChild;
}
+function wrapInSpanIfNeeded(shouldBeSpan)
+{
+ // Sometimes the result of the ExecCommand will not have a wrapping <span>
+ if (!shouldBeSpan.localName || shouldBeSpan.localName.toLowerCase() != "span") {
+ shouldBeSpan = document.createElement("span");
+ shouldBeSpan.appendChild(editableDiv.firstChild);
+ editableDiv.appendChild(shouldBeSpan);
+ }
+ return shouldBeSpan;
+}
+
function reportSizeForSpan(span, comment)
{
var tableRow = addRow(table);
{
editableDiv.innerHTML = "test";
var sizedContent = setFontSizeOnContent(size);
+ sizedContent = wrapInSpanIfNeeded(sizedContent);
if (fontFamily)
sizedContent = setFontFamilyOnContent(fontFamily);
var sizeString = (typeof(size) == "string") ? ("'" + size + "'") : size;
-<font class="Apple-style-span" face="'Lucida Grande'"><span class="Apple-style-span" style="font-size: 11px;"><br></span></font>
+<font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px;"><br></span></font>
execInsertParagraphCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div>
execInsertParagraphCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div><div id="test" class="editing"><br></div>
execTypeCharacterCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div><div id="test" class="editing">x</div>
-execFontSizeCommand: <div id="test" class="editing"><font class="Apple-style-span" size="7">x</font></div><div id="test" class="editing"><font class="Apple-style-span" size="7"><br></font></div><div id="test" class="editing"><font class="Apple-style-span" size="7">x</font></div>
-execInsertParagraphCommand: <div id="test" class="editing"><font class="Apple-style-span" size="7">x</font></div><div id="test" class="editing"><font class="Apple-style-span" size="7"><br></font></div><div id="test" class="editing"><font class="Apple-style-span" size="7"><br></font></div><div id="test" class="editing"><font class="Apple-style-span" size="7">x</font></div>
+execFontSizeCommand: <div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">x</span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;"><br></span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">x</span></div>
+execInsertParagraphCommand: <div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">x</span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;"><br></span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;"><br></span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">x</span></div>
execInsertParagraphCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div>
execInsertParagraphCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div><div id="test" class="editing"><br></div>
execTypeCharacterCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div><div id="test" class="editing">x</div>
-execFontSizeCommand: <div id="test" class="editing"><font class="Apple-style-span" size="7">x</font></div><div id="test" class="editing"><font class="Apple-style-span" size="7"><br></font></div><div id="test" class="editing"><font class="Apple-style-span" size="7">x</font></div>
-execDeleteCommand: <div id="test" class="editing"><font class="Apple-style-span" size="7">x</font></div><div id="test" class="editing"><font class="Apple-style-span" size="7"><br></font></div><div id="test" class="editing"><font class="Apple-style-span" size="7"><br></font></div>
+execFontSizeCommand: <div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">x</span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;"><br></span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">x</span></div>
+execDeleteCommand: <div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">x</span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;"><br></span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;"><br></span></div>
execInsertParagraphCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div>
execInsertParagraphCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div><div id="test" class="editing"><br></div>
execTypeCharacterCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div><div id="test" class="editing">x</div>
-execFontSizeCommand: <div id="test" class="editing"><font class="Apple-style-span" size="7">x</font></div><div id="test" class="editing"><font class="Apple-style-span" size="7"><br></font></div><div id="test" class="editing"><font class="Apple-style-span" size="7">x</font></div>
-execInsertParagraphCommand: <div id="test" class="editing"><font class="Apple-style-span" size="7">x</font></div><div id="test" class="editing"><font class="Apple-style-span" size="7"><br></font></div><div id="test" class="editing"><font class="Apple-style-span" size="7"><br></font></div><div id="test" class="editing"><font class="Apple-style-span" size="7">x</font></div>
+execFontSizeCommand: <div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">x</span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;"><br></span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">x</span></div>
+execInsertParagraphCommand: <div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">x</span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;"><br></span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;"><br></span></div><div id="test" class="editing"><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">x</span></div>
|
type small:
-| <font>
+| <span>
| class="Apple-style-span"
-| size="2"
+| style="font-size: small;"
| "small<#selection-caret>"
fontsize 4:
-| <font>
+| <span>
| class="Apple-style-span"
-| size="2"
+| style="font-size: small;"
| "small<#selection-caret>"
type medium:
-| <font>
+| <span>
| class="Apple-style-span"
-| size="2"
+| style="font-size: small;"
| "small"
-| <font>
+| <span>
| class="Apple-style-span"
-| size="4"
+| style="font-size: large;"
| "medium<#selection-caret>"
fontsize 6:
-| <font>
+| <span>
| class="Apple-style-span"
-| size="2"
+| style="font-size: small;"
| "small"
-| <font>
+| <span>
| class="Apple-style-span"
-| size="4"
+| style="font-size: large;"
| "medium<#selection-caret>"
type large:
-| <font>
+| <span>
| class="Apple-style-span"
-| size="2"
+| style="font-size: small;"
| "small"
-| <font>
+| <span>
| class="Apple-style-span"
-| size="4"
+| style="font-size: large;"
| "medium"
-| <font>
+| <span>
| class="Apple-style-span"
-| size="6"
+| style="font-size: xx-large;"
| "large<#selection-caret>"
console:
+++ /dev/null
-Test to make sure we push down inline styles properly.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-Font size
-PASS fontsize 2 on all of "hello world" yields "<font class="Apple-style-span" size="2">hello world</font>"
-PASS fontsize 4 on all of "hello world" yields "<font class="Apple-style-span" size="4">hello world</font>"
-PASS fontsize 5 on first word of "hello world" yields "<font class="Apple-style-span" size="5">hello</font> world"
-PASS fontsize 3 on first word of "<font size="7">hello <div>world</div></font>" yields "hello <div style="font-size: -webkit-xxx-large; ">world</div>"
-PASS fontsize 3 on first word of "<font size="7"><div>hello</div><div>world</div></font>" yields "<div>hello</div><div style="font-size: -webkit-xxx-large; ">world</div>"
-PASS fontsize 3 on second word of "<font size="7"><div>hello</div>world</font>" yields "<div style="font-size: -webkit-xxx-large; ">hello</div>world"
-PASS fontsize 7 on all of "<font size="7"><div>hello</div>world</font>" yields "<font size="7"><div>hello</div>world</font>"
-PASS fontsize 7 on all of "<font size="3"><div>hello</div>world</font>" yields "<div><font class="Apple-style-span" size="7">hello</font></div><font class="Apple-style-span" size="7">world</font>"
-PASS fontsize 6 on all of "<font size="7"><div>hello</div>world</font>" yields "<div><font class="Apple-style-span" size="6">hello</font></div><font class="Apple-style-span" size="6">world</font>"
-PASS fontsize 5 on all of "<font size="7"><div>hello</div>world</font>" yields "<div><font class="Apple-style-span" size="5">hello</font></div><font class="Apple-style-span" size="5">world</font>"
-PASS fontsize 3 on all of "<font size="7"><div>hello</div>world</font>" yields "<div>hello</div>world"
-PASS fontsize 3 on all of "<font size="3"><div>hello</div>world</font>" yields "<font size="3"><div>hello</div>world</font>"
-PASS fontsize 1 on all of "<font size="3"><div>hello</div>world</font>" yields "<div><font class="Apple-style-span" size="1">hello</font></div><font class="Apple-style-span" size="1">world</font>"
-
-Font size (with CSS)
-PASS fontsize 7 on all of "<font size="7"><div>hello</div>world</font>" yields "<font size="7"><div>hello</div>world</font>"
-PASS fontsize 7 on all of "<font size="3"><div>hello</div>world</font>" yields "<div><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">hello</span></div><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">world</span>"
-PASS fontsize 6 on all of "<font size="7"><div>hello</div>world</font>" yields "<div><span class="Apple-style-span" style="font-size: xx-large;">hello</span></div><span class="Apple-style-span" style="font-size: xx-large;">world</span>"
-PASS fontsize 5 on all of "<font size="7"><div>hello</div>world</font>" yields "<div><span class="Apple-style-span" style="font-size: x-large;">hello</span></div><span class="Apple-style-span" style="font-size: x-large;">world</span>"
-PASS fontsize 3 on all of "<font size="7"><div>hello</div>world</font>" yields "<div>hello</div>world"
-PASS fontsize 3 on all of "<font size="3"><div>hello</div>world</font>" yields "<font size="3"><div>hello</div>world</font>"
-PASS fontsize 1 on all of "<font size="3"><div>hello</div>world</font>" yields "<div><span class="Apple-style-span" style="font-size: x-small;">hello</span></div><span class="Apple-style-span" style="font-size: x-small;">world</span>"
-
-Font family
-PASS fontname Arial on all of "hello world" yields "<font class="Apple-style-span" face="Arial">hello world</font>"
-PASS fontname Arial on first word of "<font face="sans-serif">hello world</font>" yields "<font class="Apple-style-span" face="Arial">hello</font><font face="sans-serif"> world</font>"
-PASS fontname Arial on first word of "<font face="sans-serif">hello<div>world</div></font>" yields "<font class="Apple-style-span" face="Arial">hello</font><div style="font-family: sans-serif; ">world</div>"
-PASS fontname Arial on second word of "<font face="sans-serif">hello<div>world</div></font>" yields "<font class="Apple-style-span" face="sans-serif">hello</font><div><font class="Apple-style-span" face="Arial">world</font></div>"
-PASS fontname Sans-Serif on all of "<font face="sans-serif"><div>hello</div><div>world</div></font>" yields "<font face="sans-serif"><div>hello</div><div>world</div></font>"
-PASS fontname Arial on all of "<font face="sans-serif"><div>hello</div><div>world</div></font>" yields "<div><font class="Apple-style-span" face="Arial">hello</font></div><div><font class="Apple-style-span" face="Arial">world</font></div>"
-
-Font family (with CSS)
-PASS fontname Arial on all of "hello world" yields "<span class="Apple-style-span" style="font-family: Arial;">hello world</span>"
-PASS fontname Arial on first word of "<font face="sans-serif">hello world</font>" yields "<span class="Apple-style-span" style="font-family: Arial;">hello</span><font face="sans-serif"> world</font>"
-PASS fontname Arial on first word of "<font face="sans-serif">hello<div>world</div></font>" yields "<span class="Apple-style-span" style="font-family: Arial;">hello</span><div style="font-family: sans-serif; ">world</div>"
-PASS fontname Arial on second word of "<font face="sans-serif">hello<div>world</div></font>" yields "<span class="Apple-style-span" style="font-family: sans-serif;">hello</span><div><span class="Apple-style-span" style="font-family: Arial;">world</span></div>"
-PASS fontname Sans-Serif on all of "<font face="sans-serif"><div>hello</div><div>world</div></font>" yields "<font face="sans-serif"><div>hello</div><div>world</div></font>"
-PASS fontname Arial on all of "<font face="sans-serif"><div>hello</div><div>world</div></font>" yields "<div><span class="Apple-style-span" style="font-family: Arial;">hello</span></div><div><span class="Apple-style-span" style="font-family: Arial;">world</span></div>"
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
-<script src="../../fast/js/resources/js-test-pre.js"></script>
-</head>
-<body>
-<p id="description"></p>
-<div id="console"></div>
-<script src="script-tests/push-down-font-styles.js"></script>
-<script src="../../fast/js/resources/js-test-post.js"></script>
-</body>
-</html>
+++ /dev/null
-description('Test to make sure we push down inline styles properly.');
-
-var testContainer = document.createElement("div");
-testContainer.contentEditable = true;
-document.body.appendChild(testContainer);
-
-var styleWithCSS = false;
-
-function testSingleToggle(toggleCommand, value, selector, initialContents, expectedContents)
-{
- testContainer.innerHTML = initialContents;
- var selected = selector(testContainer);
- document.execCommand('styleWithCSS', false, styleWithCSS ? 'true' : 'false');
- document.execCommand(toggleCommand, false, value);
- var action = toggleCommand + ' ' + value + ' on ' + selected + ' of "' + initialContents + '" yields "' + testContainer.innerHTML + '"';
- if (testContainer.innerHTML == expectedContents)
- testPassed(action);
- else
- testFailed(action + ', expected "' + expectedContents + '"');
-}
-
-function selectAll(container) {
- window.getSelection().selectAllChildren(container);
- return 'all';
-}
-
-function selectTest(container) {
- window.getSelection().selectAllChildren(document.getElementById('test'));
- return 'test';
-}
-
-function selectFirstWord(container) {
- window.getSelection().setPosition(container, 0);
- window.getSelection().modify('extend', 'forward', 'word');
- return 'first word';
-}
-
-function selectSecondWord(container) {
- window.getSelection().setPosition(container, 0);
- window.getSelection().modify('move', 'forward', 'word');
- window.getSelection().modify('extend', 'forward', 'word');
- return 'second word';
-}
-
-function selectLastTwoWords(container) {
- window.getSelection().setPosition(container, container.childNodes.length);
- window.getSelection().modify('extend', 'backward', 'word');
- window.getSelection().modify('extend', 'backward', 'word');
- return 'last two words';
-}
-
-
-debug("Font size");
-styleWithCSS = false;
-testSingleToggle("fontsize", 2, selectAll, 'hello world', '<font class="Apple-style-span" size="2">hello world</font>');
-testSingleToggle("fontsize", 4, selectAll, 'hello world', '<font class="Apple-style-span" size="4">hello world</font>');
-testSingleToggle("fontsize", 5, selectFirstWord, 'hello world', '<font class="Apple-style-span" size="5">hello</font> world');
-testSingleToggle("fontsize", 3, selectFirstWord, '<font size="7">hello <div>world</div></font>', 'hello <div style="font-size: -webkit-xxx-large; ">world</div>');
-testSingleToggle("fontsize", 3, selectFirstWord, '<font size="7"><div>hello</div><div>world</div></font>', '<div>hello</div><div style="font-size: -webkit-xxx-large; ">world</div>');
-testSingleToggle("fontsize", 3, selectSecondWord, '<font size="7"><div>hello</div>world</font>', '<div style="font-size: -webkit-xxx-large; ">hello</div>world');
-
-testSingleToggle("fontsize", 7, selectAll, '<font size="7"><div>hello</div>world</font>', '<font size="7"><div>hello</div>world</font>');
-testSingleToggle("fontsize", 7, selectAll, '<font size="3"><div>hello</div>world</font>', '<div><font class="Apple-style-span" size="7">hello</font></div><font class="Apple-style-span" size="7">world</font>');
-testSingleToggle("fontsize", 6, selectAll, '<font size="7"><div>hello</div>world</font>', '<div><font class="Apple-style-span" size="6">hello</font></div><font class="Apple-style-span" size="6">world</font>');
-testSingleToggle("fontsize", 5, selectAll, '<font size="7"><div>hello</div>world</font>', '<div><font class="Apple-style-span" size="5">hello</font></div><font class="Apple-style-span" size="5">world</font>');
-testSingleToggle("fontsize", 3, selectAll, '<font size="7"><div>hello</div>world</font>', '<div>hello</div>world');
-testSingleToggle("fontsize", 3, selectAll, '<font size="3"><div>hello</div>world</font>', '<font size="3"><div>hello</div>world</font>');
-testSingleToggle("fontsize", 1, selectAll, '<font size="3"><div>hello</div>world</font>', '<div><font class="Apple-style-span" size="1">hello</font></div><font class="Apple-style-span" size="1">world</font>');
-
-debug("");
-debug("Font size (with CSS)");
-styleWithCSS = true;
-testSingleToggle("fontsize", 7, selectAll, '<font size="7"><div>hello</div>world</font>', '<font size="7"><div>hello</div>world</font>');
-testSingleToggle("fontsize", 7, selectAll, '<font size="3"><div>hello</div>world</font>', '<div><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">hello</span></div><span class="Apple-style-span" style="font-size: -webkit-xxx-large;">world</span>');
-testSingleToggle("fontsize", 6, selectAll, '<font size="7"><div>hello</div>world</font>', '<div><span class="Apple-style-span" style="font-size: xx-large;">hello</span></div><span class="Apple-style-span" style="font-size: xx-large;">world</span>');
-testSingleToggle("fontsize", 5, selectAll, '<font size="7"><div>hello</div>world</font>', '<div><span class="Apple-style-span" style="font-size: x-large;">hello</span></div><span class="Apple-style-span" style="font-size: x-large;">world</span>');
-testSingleToggle("fontsize", 3, selectAll, '<font size="7"><div>hello</div>world</font>', '<div>hello</div>world');
-testSingleToggle("fontsize", 3, selectAll, '<font size="3"><div>hello</div>world</font>', '<font size="3"><div>hello</div>world</font>');
-testSingleToggle("fontsize", 1, selectAll, '<font size="3"><div>hello</div>world</font>', '<div><span class="Apple-style-span" style="font-size: x-small;">hello</span></div><span class="Apple-style-span" style="font-size: x-small;">world</span>');
-
-debug("");
-debug("Font family");
-styleWithCSS = false;
-testSingleToggle("fontname", "Arial", selectAll, 'hello world', '<font class="Apple-style-span" face="Arial">hello world</font>');
-testSingleToggle("fontname", "Arial", selectFirstWord, '<font face="sans-serif">hello world</font>', '<font class="Apple-style-span" face="Arial">hello</font><font face="sans-serif"> world</font>');
-testSingleToggle("fontname", "Arial", selectFirstWord, '<font face="sans-serif">hello<div>world</div></font>', '<font class="Apple-style-span" face="Arial">hello</font><div style="font-family: sans-serif; ">world</div>');
-testSingleToggle("fontname", "Arial", selectSecondWord, '<font face="sans-serif">hello<div>world</div></font>', '<font class="Apple-style-span" face="sans-serif">hello</font><div><font class="Apple-style-span" face="Arial">world</font></div>');
-testSingleToggle("fontname", "Sans-Serif", selectAll, '<font face="sans-serif"><div>hello</div><div>world</div></font>', '<font face="sans-serif"><div>hello</div><div>world</div></font>');
-testSingleToggle("fontname", "Arial", selectAll, '<font face="sans-serif"><div>hello</div><div>world</div></font>', '<div><font class="Apple-style-span" face="Arial">hello</font></div><div><font class="Apple-style-span" face="Arial">world</font></div>');
-
-debug("");
-debug("Font family (with CSS)");
-styleWithCSS = true;
-testSingleToggle("fontname", "Arial", selectAll, 'hello world', '<span class="Apple-style-span" style="font-family: Arial;">hello world</span>');
-testSingleToggle("fontname", "Arial", selectFirstWord, '<font face="sans-serif">hello world</font>', '<span class="Apple-style-span" style="font-family: Arial;">hello</span><font face="sans-serif"> world</font>');
-testSingleToggle("fontname", "Arial", selectFirstWord, '<font face="sans-serif">hello<div>world</div></font>', '<span class="Apple-style-span" style="font-family: Arial;">hello</span><div style="font-family: sans-serif; ">world</div>');
-testSingleToggle("fontname", "Arial", selectSecondWord, '<font face="sans-serif">hello<div>world</div></font>', '<span class="Apple-style-span" style="font-family: sans-serif;">hello</span><div><span class="Apple-style-span" style="font-family: Arial;">world</span></div>');
-testSingleToggle("fontname", "Sans-Serif", selectAll, '<font face="sans-serif"><div>hello</div><div>world</div></font>', '<font face="sans-serif"><div>hello</div><div>world</div></font>');
-testSingleToggle("fontname", "Arial", selectAll, '<font face="sans-serif"><div>hello</div><div>world</div></font>', '<div><span class="Apple-style-span" style="font-family: Arial;">hello</span></div><div><span class="Apple-style-span" style="font-family: Arial;">world</span></div>');
-
-document.body.removeChild(testContainer);
-
-var successfullyParsed = true;
+2010-09-09 Dirk Pranke <dpranke@chromium.org>
+
+ Unreviewed, rolling out r67145.
+ http://trac.webkit.org/changeset/67145
+ https://bugs.webkit.org/show_bug.cgi?id=45431
+
+ broke editing/inserting/5994480-2.html on Chromium Linux
+
+ * css/CSSStyleSelector.h:
+ * editing/ApplyStyleCommand.cpp:
+ (WebCore::StyleChange::init):
+ (WebCore::StyleChange::extractTextStyles):
+ (WebCore::ApplyStyleCommand::removeImplicitlyStyledElement):
+
2010-09-09 Dumitru Daniliuc <dumi@chromium.org>
Reviewed by Alexey Proskuryakov.
PassRefPtr<CSSRuleList> styleRulesForElement(Element*, bool authorOnly);
PassRefPtr<CSSRuleList> pseudoStyleRulesForElement(Element*, PseudoId, bool authorOnly);
- // Given a CSS keyword in the range (xx-small to -webkit-xxx-large), this function will return
- // the correct font size scaled relative to the user's default (medium).
- static float fontSizeForKeyword(Document*, int keyword, bool shouldUseFixedDefaultSize);
-
// Given a font size in pixel, this function will return legacy font size between 1 and 7.
static int legacyFontSize(Document*, int pixelFontSize, bool shouldUseFixedDefaultSize);
private:
+ // Given a CSS keyword in the range (xx-small to -webkit-xxx-large), this function will return
+ // the correct font size scaled relative to the user's default (medium).
+ static float fontSizeForKeyword(Document*, int keyword, bool shouldUseFixedDefaultSize);
// When the CSS keyword "larger" is used, this function will attempt to match within the keyword
// table, and failing that, will simply multiply by 1.2.
#include "CSSParser.h"
#include "CSSProperty.h"
#include "CSSPropertyNames.h"
-#include "CSSStyleSelector.h"
#include "CSSValueKeywords.h"
#include "Document.h"
#include "Editor.h"
#include "Frame.h"
#include "HTMLElement.h"
-#include "HTMLFontElement.h"
#include "HTMLInterchange.h"
#include "HTMLNames.h"
#include "NodeList.h"
private:
void init(PassRefPtr<CSSStyleDeclaration>, const Position&);
void reconcileTextDecorationProperties(CSSMutableStyleDeclaration*);
- void extractTextStyles(Document*, CSSMutableStyleDeclaration*, bool shouldUseFixedFontDefautlSize);
+ void extractTextStyles(CSSMutableStyleDeclaration*);
String m_cssStyle;
bool m_applyBold;
reconcileTextDecorationProperties(mutableStyle.get());
if (!document->frame()->editor()->shouldStyleWithCSS())
- extractTextStyles(document, mutableStyle.get(), computedStyle->useFixedFontDefaultSize());
+ extractTextStyles(mutableStyle.get());
// Changing the whitespace style in a tab span would collapse the tab into a space.
if (isTabSpanTextNode(position.node()) || isTabSpanNode((position.node())))
}
}
-void StyleChange::extractTextStyles(Document* document, CSSMutableStyleDeclaration* style, bool shouldUseFixedFontDefautlSize)
+void StyleChange::extractTextStyles(CSSMutableStyleDeclaration* style)
{
ASSERT(style);
style->removeProperty(CSSPropertyFontSize); // Can't make sense of the number. Put no font size.
else {
CSSPrimitiveValue* value = static_cast<CSSPrimitiveValue*>(fontSize.get());
+
+ // Only accept absolute scale
if (value->primitiveType() >= CSSPrimitiveValue::CSS_PX && value->primitiveType() <= CSSPrimitiveValue::CSS_PC) {
- int pixelFontSize = value->getFloatValue(CSSPrimitiveValue::CSS_PX);
- int legacyFontSize = CSSStyleSelector::legacyFontSize(document, pixelFontSize, shouldUseFixedFontDefautlSize);
- // Use legacy font size only if pixel value matches exactly to that of legacy font size.
- if (CSSStyleSelector::fontSizeForKeyword(document, legacyFontSize - 1 + CSSValueXSmall, shouldUseFixedFontDefautlSize) == pixelFontSize) {
- m_applyFontSize = String::number(legacyFontSize);
- style->removeProperty(CSSPropertyFontSize);
- }
- } else if (CSSValueXSmall <= value->getIdent() && value->getIdent() <= CSSValueWebkitXxxLarge) {
- m_applyFontSize = String::number(value->getIdent() - CSSValueXSmall + 1);
- style->removeProperty(CSSPropertyFontSize);
+ float number = value->getFloatValue(CSSPrimitiveValue::CSS_PX);
+ if (number <= 9)
+ m_applyFontSize = "1";
+ else if (number <= 10)
+ m_applyFontSize = "2";
+ else if (number <= 13)
+ m_applyFontSize = "3";
+ else if (number <= 16)
+ m_applyFontSize = "4";
+ else if (number <= 18)
+ m_applyFontSize = "5";
+ else if (number <= 24)
+ m_applyFontSize = "6";
+ else
+ m_applyFontSize = "7";
}
+ // Huge quirk in Microsoft Entourage is that they understand CSS font-size, but also write
+ // out legacy 1-7 values in font tags (I guess for mailers that are not CSS-savvy at all,
+ // like Eudora). Yes, they write out *both*. We need to write out both as well.
}
}
}
int primitiveId;
const QualifiedName* element;
const QualifiedName* attribute;
- PassRefPtr<CSSValue> (*attributeToCSSValue)(int propertyID, const String&);
EPushDownType pushDownType;
};
-static PassRefPtr<CSSValue> stringToCSSValue(int propertyID, const String& value)
-{
- RefPtr<CSSMutableStyleDeclaration> dummyStyle;
- dummyStyle = CSSMutableStyleDeclaration::create();
- dummyStyle->setProperty(propertyID, value);
- return dummyStyle->getPropertyCSSValue(propertyID);
-}
-
-static PassRefPtr<CSSValue> fontSizeToCSSValue(int propertyID, const String& value)
-{
- UNUSED_PARAM(propertyID);
- ASSERT(propertyID == CSSPropertyFontSize);
- int size;
- if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size))
- return 0;
- return CSSPrimitiveValue::createIdentifier(size);
-}
-
static const HTMLEquivalent HTMLEquivalents[] = {
- { CSSPropertyFontWeight, false, CSSValueBold, &bTag, 0, 0, ShouldBePushedDown },
- { CSSPropertyFontWeight, false, CSSValueBold, &strongTag, 0, 0, ShouldBePushedDown },
- { CSSPropertyVerticalAlign, false, CSSValueSub, &subTag, 0, 0, ShouldBePushedDown },
- { CSSPropertyVerticalAlign, false, CSSValueSuper, &supTag, 0, 0, ShouldBePushedDown },
- { CSSPropertyFontStyle, false, CSSValueItalic, &iTag, 0, 0, ShouldBePushedDown },
- { CSSPropertyFontStyle, false, CSSValueItalic, &emTag, 0, 0, ShouldBePushedDown },
+ { CSSPropertyFontWeight, false, CSSValueBold, &bTag, 0, ShouldBePushedDown },
+ { CSSPropertyFontWeight, false, CSSValueBold, &strongTag, 0, ShouldBePushedDown },
+ { CSSPropertyVerticalAlign, false, CSSValueSub, &subTag, 0, ShouldBePushedDown },
+ { CSSPropertyVerticalAlign, false, CSSValueSuper, &supTag, 0, ShouldBePushedDown },
+ { CSSPropertyFontStyle, false, CSSValueItalic, &iTag, 0, ShouldBePushedDown },
+ { CSSPropertyFontStyle, false, CSSValueItalic, &emTag, 0, ShouldBePushedDown },
// text-decorations should be CSSValueList
- { CSSPropertyTextDecoration, true, CSSValueUnderline, &uTag, 0, 0, ShouldBePushedDown },
- { CSSPropertyTextDecoration, true, CSSValueLineThrough, &sTag, 0, 0, ShouldBePushedDown },
- { CSSPropertyTextDecoration, true, CSSValueLineThrough, &strikeTag, 0, 0, ShouldBePushedDown },
- { CSSPropertyWebkitTextDecorationsInEffect, true, CSSValueUnderline, &uTag, 0, 0, ShouldBePushedDown },
- { CSSPropertyWebkitTextDecorationsInEffect, true, CSSValueLineThrough, &sTag, 0, 0, ShouldBePushedDown },
- { CSSPropertyWebkitTextDecorationsInEffect, true, CSSValueLineThrough, &strikeTag, 0, 0, ShouldBePushedDown },
+ { CSSPropertyTextDecoration, true, CSSValueUnderline, &uTag, 0, ShouldBePushedDown },
+ { CSSPropertyTextDecoration, true, CSSValueLineThrough, &sTag, 0, ShouldBePushedDown },
+ { CSSPropertyTextDecoration, true, CSSValueLineThrough, &strikeTag, 0, ShouldBePushedDown },
+ { CSSPropertyWebkitTextDecorationsInEffect, true, CSSValueUnderline, &uTag, 0, ShouldBePushedDown },
+ { CSSPropertyWebkitTextDecorationsInEffect, true, CSSValueLineThrough, &sTag, 0, ShouldBePushedDown },
+ { CSSPropertyWebkitTextDecorationsInEffect, true, CSSValueLineThrough, &strikeTag, 0, ShouldBePushedDown },
// FIXME: font attributes should only be removed if values were different
- { CSSPropertyColor, false, CSSValueInvalid, &fontTag, &colorAttr, stringToCSSValue, ShouldBePushedDown },
- { CSSPropertyFontFamily, false, CSSValueInvalid, &fontTag, &faceAttr, stringToCSSValue, ShouldBePushedDown },
- { CSSPropertyFontSize, false, CSSValueInvalid, &fontTag, &sizeAttr, fontSizeToCSSValue, ShouldBePushedDown },
+ { CSSPropertyColor, false, CSSValueInvalid, &fontTag, &colorAttr, ShouldBePushedDown },
+ { CSSPropertyFontFamily, false, CSSValueInvalid, &fontTag, &faceAttr, ShouldBePushedDown },
+ { CSSPropertyFontSize, false, CSSValueInvalid, &fontTag, &sizeAttr, ShouldBePushedDown },
// unicode-bidi and direction are pushed down separately so don't push down with other styles.
- { CSSPropertyDirection, false, CSSValueInvalid, 0, &dirAttr, stringToCSSValue, ShouldNotBePushedDown },
- { CSSPropertyUnicodeBidi, false, CSSValueInvalid, 0, &dirAttr, stringToCSSValue, ShouldNotBePushedDown },
+ { CSSPropertyUnicodeBidi, false, CSSValueInvalid, 0, &dirAttr, ShouldNotBePushedDown },
+ { CSSPropertyDirection, false, CSSValueInvalid, 0, &dirAttr, ShouldNotBePushedDown },
};
bool ApplyStyleCommand::removeImplicitlyStyledElement(CSSMutableStyleDeclaration* style, HTMLElement* element, InlineStyleRemovalMode mode, CSSMutableStyleDeclaration* extractedStyle)
RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(equivalent.propertyID);
if (!styleValue)
continue;
- RefPtr<CSSValue> mapValue;
- if (equivalent.attribute)
- mapValue = equivalent.attributeToCSSValue(equivalent.propertyID, element->getAttribute(*equivalent.attribute));
- else
- mapValue = CSSPrimitiveValue::createIdentifier(equivalent.primitiveId).get();
+ RefPtr<CSSPrimitiveValue> mapValue = CSSPrimitiveValue::createIdentifier(equivalent.primitiveId);
if (equivalent.isValueList && styleValue->isValueList() && static_cast<CSSValueList*>(styleValue.get())->hasValue(mapValue.get()))
continue; // If CSS value assumes CSSValueList, then only skip if the value was present in style to apply.
- else if (mapValue && styleValue->cssText() == mapValue->cssText())
+ else if (styleValue->cssText() == mapValue->cssText())
continue; // If CSS value is primitive, then skip if they are equal.
- if (extractedStyle)
- extractedStyle->setProperty(equivalent.propertyID, mapValue->cssText());
+ if (extractedStyle) {
+ if (equivalent.primitiveId == CSSValueInvalid)
+ extractedStyle->setProperty(equivalent.propertyID, element->getAttribute(*equivalent.attribute));
+ else
+ extractedStyle->setProperty(equivalent.propertyID, mapValue->cssText());
+ }
if (mode == RemoveNone)
return true;