Changeset 84311 in webkit


Ignore:
Timestamp:
Apr 19, 2011 4:37:32 PM (13 years ago)
Author:
enrica@apple.com
Message:

REGRESSION(r55762): Highlight color can't be copied in gmail.
https://bugs.webkit.org/show_bug.cgi?id=58925
<rdar://problem/9253057>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Test: editing/pasteboard/copy-text-with-backgroundcolor.html

The changes of r55762 uncovered the underlying issue here. The markup fragment
placed in the pasteboard does not contain the background color style.
This occurs only if the selection is limited to a single text node, whereas if the
selection spans across multiple nodes, the style is preserved correctly.
The fix consists in changing the logic that decides whether we should include the wrapping
node in the markup. That logic is based on the code in highestAncestorToWrapMarkup which relies
on isElementPresentational to choose candidates to be the wrapping node.
I've extended it to accept nodes that have non fully transparent background colors.

  • editing/Editor.cpp:

(WebCore::Editor::hasTransparentBackgroundColor): Now is a static method of the class.

  • editing/Editor.h:
  • editing/markup.cpp:

(WebCore::isElementPresentational): Modified to use hasTransparentBackgroundColor.

LayoutTests:

The following test checks that when we copy a text node surrounded by an element that
has non transparent background color we preserve the background color as well.

  • editing/pasteboard/copy-text-with-backgroundcolor-expected.txt: Added.
  • editing/pasteboard/copy-text-with-backgroundcolor.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r84308 r84311  
     12011-04-19  Enrica Casucci  <enrica@apple.com>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        REGRESSION(r55762): Highlight color can't be copied in gmail.
     6        https://bugs.webkit.org/show_bug.cgi?id=58925
     7        <rdar://problem/9253057>
     8
     9        The following test checks that when we copy a text node surrounded by an element that
     10        has non transparent background color we preserve the background color as well.
     11       
     12        * editing/pasteboard/copy-text-with-backgroundcolor-expected.txt: Added.
     13        * editing/pasteboard/copy-text-with-backgroundcolor.html: Added.
     14
    1152011-04-19  Chris Rogers  <crogers@google.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r84309 r84311  
     12011-04-19  Enrica Casucci  <enrica@apple.com>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        REGRESSION(r55762): Highlight color can't be copied in gmail.
     6        https://bugs.webkit.org/show_bug.cgi?id=58925
     7        <rdar://problem/9253057>
     8
     9        Test: editing/pasteboard/copy-text-with-backgroundcolor.html
     10
     11        The changes of r55762 uncovered the underlying issue here. The markup fragment
     12        placed in the pasteboard does not contain the background color style.
     13        This occurs only if the selection is limited to a single text node, whereas if the
     14        selection spans across multiple nodes, the style is preserved correctly.
     15        The fix consists in changing the logic that decides whether we should include the wrapping
     16        node in the markup. That logic is based on the code in highestAncestorToWrapMarkup which relies
     17        on isElementPresentational to choose candidates to be the wrapping node.
     18        I've extended it to accept nodes that have non fully transparent background colors.
     19
     20        * editing/Editor.cpp:
     21        (WebCore::Editor::hasTransparentBackgroundColor): Now is a static method of the class.
     22        * editing/Editor.h:
     23        * editing/markup.cpp:
     24        (WebCore::isElementPresentational): Modified to use hasTransparentBackgroundColor.
     25
    1262011-04-19  Geoffrey Garen  <ggaren@apple.com>
    227
  • trunk/Source/WebCore/editing/Editor.cpp

    r83501 r84311  
    917917}
    918918
    919 static bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
     919bool Editor::hasTransparentBackgroundColor(CSSStyleDeclaration* style)
    920920{
    921921    RefPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor);
  • trunk/Source/WebCore/editing/Editor.h

    r83492 r84311  
    199199    Command command(const String& commandName, EditorCommandSource);
    200200    static bool commandIsSupportedFromMenuOrKeyBinding(const String& commandName); // Works without a frame.
     201    static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
    201202
    202203    bool insertText(const String&, Event* triggeringEvent);
  • trunk/Source/WebCore/editing/markup.cpp

    r84265 r84311  
    466466    if (!style)
    467467        return false;
    468     return !propertyMissingOrEqualToNone(style.get(), CSSPropertyTextDecoration);
     468    return !propertyMissingOrEqualToNone(style.get(), CSSPropertyTextDecoration) || !Editor::hasTransparentBackgroundColor(style.get());
    469469}
    470470
Note: See TracChangeset for help on using the changeset viewer.