Commit 7d3dbfed authored by justing's avatar justing

LayoutTests:

        Reviewed by darin
        
        <rdar://problem/5091898> REGRESSION: GMail Editor: A line of underlined text copied with Select All pastes with wrong font family

        Demonstrates the bug fixed:
        * editing/style/5091898-expected.checksum: Added.
        * editing/style/5091898-expected.png: Added.
        * editing/style/5091898-expected.txt: Added.
        * editing/style/5091898.html: Added.
        Demonstrates a related bug fixed (deleting
        the line break before a paragraph could remove
        its underlining):
        * editing/deleting/5091898-expected.checksum: Added.
        * editing/deleting/5091898-expected.png: Added.
        * editing/deleting/5091898-expected.txt: Added.
        * editing/deleting/5091898.html: Added.
        Demonstrates that a link now (correctly) exists, 
        instead of just underlined text:
        * editing/pasteboard/4840662-expected.txt:

WebCore:

        Reviewed by darin
        
        <rdar://problem/5091898> REGRESSION: GMail Editor: A line of underlined text copied with Select All pastes with wrong font family
        
        createMarkup skipped elements if they were blocks
        when called from moveParagraphs (because that function 
        must receive only inline content).  This patch adds 
        code to inline these blocks instead of skipping them 
        so that we don't lose any of the style that they 
        contribute to the copied markup.

        * editing/markup.cpp:
        (WebCore::startMarkup): Add an inlineBlocks option.
        Make sure to overwrite display:block coming from
        a style sheet or the inline style declaration.
        (WebCore::createMarkup): Don't refuse to include a 
        specialCommonAncestor that's a block if we were asked 
        to include only inline content, since we can now inline 
        block elements in startMarkup.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20542 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 97ab9364
2007-03-27 Justin Garcia <justin.garcia@apple.com>
Reviewed by darin
<rdar://problem/5091898> REGRESSION: GMail Editor: A line of underlined text copied with Select All pastes with wrong font family
Demonstrates the bug fixed:
* editing/style/5091898-expected.checksum: Added.
* editing/style/5091898-expected.png: Added.
* editing/style/5091898-expected.txt: Added.
* editing/style/5091898.html: Added.
Demonstrates a related bug fixed (deleting
the line break before a paragraph could remove
its underlining):
* editing/deleting/5091898-expected.checksum: Added.
* editing/deleting/5091898-expected.png: Added.
* editing/deleting/5091898-expected.txt: Added.
* editing/deleting/5091898.html: Added.
Demonstrates that a link now (correctly) exists,
instead of just underlined text:
* editing/pasteboard/4840662-expected.txt:
2007-03-26 Justin Garcia <justin.garcia@apple.com>
Reviewed by darin
dd8c13473ecb22f289f3387847af2827
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {P} at (0,0) size 784x36
RenderText {#text} at (0,0) size 767x36
text run at (0,0) width 767: "This tests for a bug where underlined content would lose its underlining when deleting the line break before the paragraph"
text run at (0,18) width 104: "that contained it."
RenderBlock {DIV} at (0,52) size 784x18
RenderText {#text} at (0,0) size 183x18
text run at (0,0) width 183: "This shouldn't be underlined."
RenderInline {DIV} at (0,0) size 168x18
RenderText {#text} at (183,0) size 168x18
text run at (183,0) width 168: "This should be underlined."
caret: position 29 of child 0 {#text} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<p>This tests for a bug where underlined content would lose its underlining when deleting the line break before the paragraph that contained it.</p>
<div contenteditable="true">This shouldn't be underlined.<div id="div" style="text-decoration: underline;">This should be underlined.</div></div>
<script>
var div = document.getElementById("div");
var range = document.createRange();
range.setStart(div, 0);
range.setEnd(div, 0);
var sel = window.getSelection();
sel.addRange(range);
document.execCommand("Delete");
</script>
......@@ -16,7 +16,7 @@ layer at (0,0) size 800x600
RenderInline {SPAN} at (0,0) size 42x18 [color=#000000]
RenderText {#text} at (21,0) size 20x18
text run at (21,0) width 20: "bar"
RenderInline {SPAN} at (0,0) size 22x18 [color=#0000EE]
RenderInline {A} at (0,0) size 22x18 [color=#0000EE]
RenderText {#text} at (41,0) size 22x18
text run at (41,0) width 22: "baz"
RenderBlock (anonymous) at (0,18) size 784x0
......
e042889fa18fd7b6837a93c63fcd536c
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderInline {SPAN} at (0,0) size 188x15
RenderText {#text} at (0,0) size 188x15
text run at (0,0) width 188: "This text should be Arial bold."
RenderInline {SPAN} at (0,0) size 192x15
RenderInline {SPAN} at (0,0) size 192x15
RenderInline {DIV} at (0,0) size 192x15
RenderText {#text} at (188,0) size 192x15
text run at (188,0) width 192: " This text should be Arial bold."
RenderText {#text} at (0,0) size 0x0
RenderText {#text} at (0,0) size 0x0
caret: position 32 of child 0 {#text} of child 0 {DIV} of child 1 {SPAN} of child 0 {SPAN} of child 0 {BODY} of child 0 {HTML} of document
<html style="font-family: Times New Roman; font-size: 13px;">
<body contenteditable="true" style="font-family: Arial; font-weight: bold;">This text should be Arial bold.</body>
<script>
document.body.focus();
document.execCommand("SelectAll");
document.execCommand("Underline");
document.execCommand("Copy");
window.getSelection().modify("move", "forward", "character");
document.execCommand("Paste");
</script>
</html>
2007-03-27 Justin Garcia <justin.garcia@apple.com>
Reviewed by darin
<rdar://problem/5091898> REGRESSION: GMail Editor: A line of underlined text copied with Select All pastes with wrong font family
createMarkup skipped elements if they were blocks
when called from moveParagraphs (because that function
must receive only inline content). This patch adds
code to inline these blocks instead of skipping them
so that we don't lose any of the style that they
contribute to the copied markup.
* editing/markup.cpp:
(WebCore::startMarkup): Add an inlineBlocks option.
Make sure to overwrite display:block coming from
a style sheet or the inline style declaration.
(WebCore::createMarkup): Don't refuse to include a
specialCommonAncestor that's a block if we were asked
to include only inline content, since we can now inline
block elements in startMarkup.
2007-03-27 Adele Peterson <adele@apple.com>
Reviewed by Hyatt.
......
......@@ -154,7 +154,7 @@ static void removeEnclosingMailBlockquoteStyle(CSSMutableStyleDeclaration* style
blockquoteStyle->diff(style);
}
static DeprecatedString startMarkup(const Node *node, const Range *range, EAnnotateForInterchange annotate)
static DeprecatedString startMarkup(const Node *node, const Range *range, EAnnotateForInterchange annotate, bool convertBlocksToInlines = false)
{
bool documentIsHTML = node->document()->isHTMLDocument();
switch (node->nodeType()) {
......@@ -189,10 +189,13 @@ static DeprecatedString startMarkup(const Node *node, const Range *range, EAnnot
case Node::ELEMENT_NODE: {
DeprecatedString markup = DeprecatedChar('<');
const Element* el = static_cast<const Element*>(node);
convertBlocksToInlines &= isBlock(const_cast<Node*>(node));
markup += el->nodeNamePreservingCase().deprecatedString();
String additionalStyle;
if (annotate && el->isHTMLElement()) {
RefPtr<CSSMutableStyleDeclaration> style = styleFromMatchedRulesForElement(const_cast<Element*>(el));
if (convertBlocksToInlines)
style->setProperty(CSS_PROP_DISPLAY, CSS_VAL_INLINE, true);
if (style->length() > 0)
additionalStyle = style->cssText();
}
......@@ -202,6 +205,11 @@ static DeprecatedString startMarkup(const Node *node, const Range *range, EAnnot
for (unsigned int i = 0; i < length; i++) {
Attribute *attr = attrs->attributeItem(i);
String value = attr->value();
if (attr->name() == styleAttr && convertBlocksToInlines) {
RefPtr<CSSMutableStyleDeclaration> inlineStyle = static_cast<const HTMLElement*>(el)->getInlineStyleDecl()->copy();
inlineStyle->setProperty(CSS_PROP_DISPLAY, CSS_VAL_INLINE, true);
value = inlineStyle->cssText();
}
if (annotate && attr->name() == styleAttr && additionalStyle.length()) {
value += "; " + additionalStyle;
additionalStyle = "";
......@@ -351,7 +359,7 @@ bool elementHasTextDecorationProperty(Node* node)
// FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForInterchange?
// FIXME: At least, annotation and style info should probably not be included in range.markupString()
DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotateForInterchange annotate, bool includeInlineSpecialAncestors)
DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotateForInterchange annotate, bool convertBlocksToInlines)
{
if (!range || range->isDetached())
return DeprecatedString();
......@@ -486,9 +494,6 @@ DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotat
if (Node *enclosingAnchor = enclosingNodeWithTag(specialCommonAncestor ? specialCommonAncestor : commonAncestor, aTag))
specialCommonAncestor = enclosingAnchor;
if (!annotate && includeInlineSpecialAncestors && isBlock(specialCommonAncestor))
specialCommonAncestor = 0;
Node* body = enclosingNodeWithTag(commonAncestor, bodyTag);
// FIXME: Only include markup for a fully selected root (and ancestors of lastClosed up to that root) if
......@@ -501,9 +506,7 @@ DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotat
if (specialCommonAncestor) {
// Also include all of the ancestors of lastClosed up to this special ancestor.
for (Node* ancestor = lastClosed->parentNode(); ancestor; ancestor = ancestor->parentNode()) {
if (!annotate && includeInlineSpecialAncestors && isBlock(ancestor))
continue;
if (ancestor == fullySelectedRoot) {
if (ancestor == fullySelectedRoot && !convertBlocksToInlines) {
RefPtr<CSSMutableStyleDeclaration> style = styleFromMatchedRulesAndInlineDecl(fullySelectedRoot);
// Bring the background attribute over, but not as an attribute because a background attribute on a div
......@@ -516,7 +519,7 @@ DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotat
markups.append("</div>");
}
} else {
markups.prepend(startMarkup(ancestor, range, annotate));
markups.prepend(startMarkup(ancestor, range, annotate, convertBlocksToInlines));
markups.append(endMarkup(ancestor));
}
if (nodes)
......
......@@ -45,7 +45,7 @@ namespace WebCore {
PassRefPtr<DocumentFragment> createFragmentFromNodes(Document*, const Vector<Node*>&);
DeprecatedString createMarkup(const Range*,
Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool includeInlineSpecialAncestors = false);
Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false);
DeprecatedString createMarkup(const Node*, EChildrenOnly = IncludeNode,
Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment