Changeset 146835 in webkit


Ignore:
Timestamp:
Mar 25, 2013 6:33:10 PM (11 years ago)
Author:
tony@chromium.org
Message:

Image alt text not included in plain-text version when copying
https://bugs.webkit.org/show_bug.cgi?id=11200

Reviewed by Ryosuke Niwa.

Source/WebCore:

Add a setting to enable copying image alt text to the clipboard and drag and drop pasteboard.
This setting is disabled by default, so each port can enable if they want to match IE10 and
Firefox's behavior.

Test: editing/pasteboard/copy-image-with-alt-text.html

  • editing/Editor.cpp:

(WebCore::Editor::cut): Explicitly ask that the selection on the pasteboard as being for the clipboard.
(WebCore::Editor::copy): Explicitly ask that the selection on the pasteboard as being for the clipboard.
(WebCore::Editor::selectedText): Add a private version of selectedText() that can choose between having image alt text or not.
(WebCore::Editor::selectedTextForClipboard): Ask for image alt text if the setting is enabled.

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

(WebCore::TextIterator::TextIterator): Add a bool to keep track of whether or not to emit image alt text.
(WebCore::TextIterator::handleReplacedElement): If there's alt text, point the iterator to it.

  • editing/TextIterator.h:

(TextIterator):

  • editing/mac/EditorMac.mm:

(WebCore::Editor::takeFindStringFromSelection): Use the same text as on the clipboard.
(WebCore::Editor::writeSelectionToPasteboard): Don't include image alt text since this is
used by Services.
(WebCore::Editor::stringSelectionForPasteboard): Don't include image alt text since this is
used by Services.

  • page/DragController.cpp:

(WebCore::DragController::startDrag): Use image alt text (matches Firefox).

  • page/Settings.in: Add a setting that disables image alt text by default.
  • platform/Pasteboard.h:
  • platform/blackberry/PasteboardBlackBerry.cpp:

(WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.

  • platform/chromium/ClipboardChromium.cpp:

(WebCore::ClipboardChromium::writeRange): Use clipboard text when writing ranges (used by d&d).

  • platform/chromium/PasteboardChromium.cpp:

(WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.

  • platform/efl/PasteboardEfl.cpp:

(WebCore::Pasteboard::writeSelection): Update function param.

  • platform/gtk/ClipboardGtk.cpp:

(WebCore::ClipboardGtk::writeRange): Use clipboard text when writing ranges (used by d&d).

  • platform/gtk/PasteboardGtk.cpp:

(WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.

  • platform/mac/ClipboardMac.mm:

(WebCore::ClipboardMac::writeRange): Use clipboard text when writing ranges (used by d&d).

  • platform/mac/PasteboardMac.mm:

(WebCore::Pasteboard::getStringSelection): Use ShouldSerializeSelectedTextForClipboard to determine whether the selected
text is for the clipboard or not.
(WebCore::Pasteboard::writeSelectionForTypes): Pass ShouldSerializeSelectedTextForClipboard through.
(WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.

  • platform/qt/ClipboardQt.cpp:

(WebCore::ClipboardQt::writeRange): Use clipboard text when writing ranges (used by d&d).

  • platform/qt/PasteboardQt.cpp:

(WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.

  • platform/win/ClipboardWin.cpp:

(WebCore::ClipboardWin::writeRange): Use clipboard text when writing ranges (used by d&d).

  • platform/win/PasteboardWin.cpp:

(WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.

  • platform/wince/PasteboardWinCE.cpp:

(WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.

  • platform/wx/PasteboardWx.cpp:

(WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.

  • rendering/RenderImage.h:

(WebCore::RenderImage::altText): Add a getter for the alt text.

LayoutTests:

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

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r146834 r146835  
     12013-03-25  Tony Chang  <tony@chromium.org>
     2
     3        Image alt text not included in plain-text version when copying
     4        https://bugs.webkit.org/show_bug.cgi?id=11200
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * editing/pasteboard/copy-image-with-alt-text-expected.txt: Added.
     9        * editing/pasteboard/copy-image-with-alt-text.html: Added.
     10
    1112013-03-25  James Robinson  <jamesr@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r146833 r146835  
     12013-03-25  Tony Chang  <tony@chromium.org>
     2
     3        Image alt text not included in plain-text version when copying
     4        https://bugs.webkit.org/show_bug.cgi?id=11200
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Add a setting to enable copying image alt text to the clipboard and drag and drop pasteboard.
     9        This setting is disabled by default, so each port can enable if they want to match IE10 and
     10        Firefox's behavior.
     11
     12        Test: editing/pasteboard/copy-image-with-alt-text.html
     13
     14        * editing/Editor.cpp:
     15        (WebCore::Editor::cut): Explicitly ask that the selection on the pasteboard as being for the clipboard.
     16        (WebCore::Editor::copy): Explicitly ask that the selection on the pasteboard as being for the clipboard.
     17        (WebCore::Editor::selectedText): Add a private version of selectedText() that can choose between having image alt text or not.
     18        (WebCore::Editor::selectedTextForClipboard): Ask for image alt text if the setting is enabled.
     19        * editing/Editor.h:
     20        * editing/TextIterator.cpp:
     21        (WebCore::TextIterator::TextIterator): Add a bool to keep track of whether or not to emit image alt text.
     22        (WebCore::TextIterator::handleReplacedElement): If there's alt text, point the iterator to it.
     23        * editing/TextIterator.h:
     24        (TextIterator):
     25        * editing/mac/EditorMac.mm:
     26        (WebCore::Editor::takeFindStringFromSelection): Use the same text as on the clipboard.
     27        (WebCore::Editor::writeSelectionToPasteboard): Don't include image alt text since this is
     28        used by Services.
     29        (WebCore::Editor::stringSelectionForPasteboard): Don't include image alt text since this is
     30        used by Services.
     31        * page/DragController.cpp:
     32        (WebCore::DragController::startDrag): Use image alt text (matches Firefox).
     33        * page/Settings.in: Add a setting that disables image alt text by default.
     34        * platform/Pasteboard.h:
     35        * platform/blackberry/PasteboardBlackBerry.cpp:
     36        (WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.
     37        * platform/chromium/ClipboardChromium.cpp:
     38        (WebCore::ClipboardChromium::writeRange): Use clipboard text when writing ranges (used by d&d).
     39        * platform/chromium/PasteboardChromium.cpp:
     40        (WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.
     41        * platform/efl/PasteboardEfl.cpp:
     42        (WebCore::Pasteboard::writeSelection): Update function param.
     43        * platform/gtk/ClipboardGtk.cpp:
     44        (WebCore::ClipboardGtk::writeRange): Use clipboard text when writing ranges (used by d&d).
     45        * platform/gtk/PasteboardGtk.cpp:
     46        (WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.
     47        * platform/mac/ClipboardMac.mm:
     48        (WebCore::ClipboardMac::writeRange): Use clipboard text when writing ranges (used by d&d).
     49        * platform/mac/PasteboardMac.mm:
     50        (WebCore::Pasteboard::getStringSelection): Use ShouldSerializeSelectedTextForClipboard to determine whether the selected
     51        text is for the clipboard or not.
     52        (WebCore::Pasteboard::writeSelectionForTypes): Pass ShouldSerializeSelectedTextForClipboard through.
     53        (WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.
     54        * platform/qt/ClipboardQt.cpp:
     55        (WebCore::ClipboardQt::writeRange): Use clipboard text when writing ranges (used by d&d).
     56        * platform/qt/PasteboardQt.cpp:
     57        (WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.
     58        * platform/win/ClipboardWin.cpp:
     59        (WebCore::ClipboardWin::writeRange): Use clipboard text when writing ranges (used by d&d).
     60        * platform/win/PasteboardWin.cpp:
     61        (WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.
     62        * platform/wince/PasteboardWinCE.cpp:
     63        (WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.
     64        * platform/wx/PasteboardWx.cpp:
     65        (WebCore::Pasteboard::writeSelection): Add ShouldSerializeSelectedTextForClipboard parameter.
     66        * rendering/RenderImage.h:
     67        (WebCore::RenderImage::altText): Add a getter for the alt text.
     68
    1692013-03-25  Dean Jackson  <dino@apple.com>
    270
  • trunk/Source/WebCore/editing/Editor.cpp

    r146726 r146835  
    10441044        updateMarkersForWordsAffectedByEditing(true);
    10451045        if (enclosingTextFormControl(m_frame->selection()->start())) {
    1046             Pasteboard::generalPasteboard()->writePlainText(selectedText(),
     1046            Pasteboard::generalPasteboard()->writePlainText(selectedTextForClipboard(),
    10471047                canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace);
    10481048        } else
    1049             Pasteboard::generalPasteboard()->writeSelection(selection.get(), canSmartCopyOrDelete(), m_frame);
     1049            Pasteboard::generalPasteboard()->writeSelection(selection.get(), canSmartCopyOrDelete(), m_frame, IncludeImageAltTextForClipboard);
    10501050        didWriteSelectionToPasteboard();
    10511051        deleteSelectionWithSmartDelete(canSmartCopyOrDelete());
     
    10641064    willWriteSelectionToPasteboard(selectedRange());
    10651065    if (enclosingTextFormControl(m_frame->selection()->start())) {
    1066         Pasteboard::generalPasteboard()->writePlainText(selectedText(),
     1066        Pasteboard::generalPasteboard()->writePlainText(selectedTextForClipboard(),
    10671067            canSmartCopyOrDelete() ? Pasteboard::CanSmartReplace : Pasteboard::CannotSmartReplace);
    10681068    } else {
     
    10711071            Pasteboard::generalPasteboard()->writeImage(imageElement, document->url(), document->title());
    10721072        else
    1073             Pasteboard::generalPasteboard()->writeSelection(selectedRange().get(), canSmartCopyOrDelete(), m_frame);
     1073            Pasteboard::generalPasteboard()->writeSelection(selectedRange().get(), canSmartCopyOrDelete(), m_frame, IncludeImageAltTextForClipboard);
    10741074    }
    10751075
     
    26142614String Editor::selectedText() const
    26152615{
     2616    return selectedText(TextIteratorDefaultBehavior);
     2617}
     2618
     2619String Editor::selectedTextForClipboard() const
     2620{
     2621    if (m_frame->settings() && m_frame->settings()->selectionIncludesAltImageText())
     2622        return selectedText(TextIteratorEmitsImageAltText);
     2623    return selectedText();
     2624}
     2625
     2626String Editor::selectedText(TextIteratorBehavior behavior) const
     2627{
    26162628    // We remove '\0' characters because they are not visibly rendered to the user.
    2617     return plainText(m_frame->selection()->toNormalizedRange().get()).replace(0, "");
     2629    return plainText(m_frame->selection()->toNormalizedRange().get(), behavior).replace(0, "");
    26182630}
    26192631
  • trunk/Source/WebCore/editing/Editor.h

    r142711 r146835  
    3939#include "FrameSelection.h"
    4040#include "TextChecking.h"
     41#include "TextIterator.h"
    4142#include "VisibleSelection.h"
    4243#include "WritingDirection.h"
     
    356357
    357358    String selectedText() const;
     359    String selectedTextForClipboard() const;
    358360    bool findString(const String&, FindOptions);
    359361    // FIXME: Switch callers over to the FindOptions version and retire this one.
     
    443445    TextCheckingTypeMask resolveTextCheckingTypeMask(TextCheckingTypeMask);
    444446
     447    String selectedText(TextIteratorBehavior) const;
     448
    445449    void selectComposition();
    446450    enum SetCompositionMode { ConfirmComposition, CancelComposition };
  • trunk/Source/WebCore/editing/TextIterator.cpp

    r146796 r146835  
    3939#include "NodeTraversal.h"
    4040#include "Range.h"
     41#include "RenderImage.h"
    4142#include "RenderTableCell.h"
    4243#include "RenderTableRow.h"
     
    267268    , m_stopsOnFormControls(behavior & TextIteratorStopsOnFormControls)
    268269    , m_shouldStop(false)
     270    , m_emitsImageAltText(behavior & TextIteratorEmitsImageAltText)
    269271{
    270272    if (!r)
     
    689691    m_positionStartOffset = 0;
    690692    m_positionEndOffset = 1;
    691 
    692693    m_textCharacters = 0;
     694
     695    if (m_emitsImageAltText && renderer->isImage() && renderer->isRenderImage()) {
     696        m_text = toRenderImage(renderer)->altText();
     697        if (!m_text.isEmpty()) {
     698            m_textLength = m_text.length();
     699            m_lastCharacter = m_text[m_textLength - 1];
     700            return true;
     701        }
     702    }
     703
    693704    m_textLength = 0;
    694 
    695705    m_lastCharacter = 0;
    696706
  • trunk/Source/WebCore/editing/TextIterator.h

    r146796 r146835  
    4545    TextIteratorEmitsObjectReplacementCharacters = 1 << 4,
    4646    TextIteratorEmitsOriginalText = 1 << 5,
    47     TextIteratorStopsOnFormControls = 1 << 6
     47    TextIteratorStopsOnFormControls = 1 << 6,
     48    TextIteratorEmitsImageAltText = 1 << 7,
    4849};
    4950   
     
    193194    // Used when m_stopsOnFormControls is set to determine if the iterator should keep advancing.
    194195    bool m_shouldStop;
     196
     197    bool m_emitsImageAltText;
    195198};
    196199
  • trunk/Source/WebCore/editing/mac/EditorMac.mm

    r143863 r146835  
    263263    types.append(String(NSStringPboardType));
    264264    platformStrategies()->pasteboardStrategy()->setTypes(types, NSFindPboard);
    265     platformStrategies()->pasteboardStrategy()->setStringForType(m_frame->displayStringModifiedByEncoding(selectedText()), NSStringPboardType, NSFindPboard);
     265    platformStrategies()->pasteboardStrategy()->setStringForType(m_frame->displayStringModifiedByEncoding(selectedTextForClipboard()), NSStringPboardType, NSFindPboard);
    266266}
    267267
     
    269269{
    270270    Pasteboard pasteboard(pasteboardName);
    271     pasteboard.writeSelectionForTypes(pasteboardTypes, true, m_frame);
     271    pasteboard.writeSelectionForTypes(pasteboardTypes, true, m_frame, DefaultSelectedTextType);
    272272}
    273273   
     
    283283String Editor::stringSelectionForPasteboard()
    284284{
    285     return Pasteboard::getStringSelection(m_frame);
     285    return Pasteboard::getStringSelection(m_frame, DefaultSelectedTextType);
    286286}
    287287
  • trunk/Source/WebCore/page/DragController.cpp

    r145818 r146835  
    790790        if (!clipboard->hasData()) {
    791791            if (enclosingTextFormControl(src->selection()->start()))
    792                 clipboard->writePlainText(src->editor()->selectedText());
     792                clipboard->writePlainText(src->editor()->selectedTextForClipboard());
    793793            else {
    794794                RefPtr<Range> selectionRange = src->selection()->toNormalizedRange();
  • trunk/Source/WebCore/page/Settings.in

    r146664 r146835  
    204204smartInsertDeleteEnabled initial=defaultSmartInsertDeleteEnabled
    205205selectTrailingWhitespaceEnabled initial=defaultSelectTrailingWhitespaceEnabled
     206
     207selectionIncludesAltImageText initial=false
  • trunk/Source/WebCore/platform/Pasteboard.h

    r127862 r146835  
    6464#endif
    6565
    66     class ArchiveResource;
     66class ArchiveResource;
    6767class Clipboard;
    6868class DocumentFragment;
     
    7373class Range;
    7474class SharedBuffer;
     75
     76enum ShouldSerializeSelectedTextForClipboard { DefaultSelectedTextType, IncludeImageAltTextForClipboard };
    7577   
    7678class Pasteboard {
     
    8486#if PLATFORM(MAC)
    8587    // This is required to support OS X services.
    86     void writeSelectionForTypes(const Vector<String>& pasteboardTypes, bool canSmartCopyOrDelete, Frame*);
     88    void writeSelectionForTypes(const Vector<String>& pasteboardTypes, bool canSmartCopyOrDelete, Frame*, ShouldSerializeSelectedTextForClipboard);
    8789    explicit Pasteboard(const String& pasteboardName);
    88     static String getStringSelection(Frame*);
     90    static String getStringSelection(Frame*, ShouldSerializeSelectedTextForClipboard);
    8991    static PassRefPtr<SharedBuffer> getDataSelection(Frame*, const String& pasteboardType);
    9092#endif
    9193   
    9294    static Pasteboard* generalPasteboard();
    93     void writeSelection(Range*, bool canSmartCopyOrDelete, Frame*);
     95    void writeSelection(Range*, bool canSmartCopyOrDelete, Frame*, ShouldSerializeSelectedTextForClipboard = DefaultSelectedTextType);
    9496    void writePlainText(const String&, SmartReplaceOption);
    9597    void writeURL(const KURL&, const String&, Frame* = 0);
  • trunk/Source/WebCore/platform/blackberry/PasteboardBlackBerry.cpp

    r146264 r146835  
    6262}
    6363
    64 void Pasteboard::writeSelection(Range* selectedRange, bool, Frame* frame)
     64void Pasteboard::writeSelection(Range* selectedRange, bool, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
    6565{
    66     WTF::String text = frame->editor()->selectedText();
     66    WTF::String text = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor()->selectedTextForClipboard() : frame->editor()->selectedText();
    6767    WTF::String html = createMarkup(selectedRange, 0, AnnotateForInterchange);
    6868    WTF::String url = frame->document()->url().string();
  • trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp

    r146644 r146835  
    433433    m_dataObject->setHTMLAndBaseURL(createMarkup(selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs), frame->document()->url());
    434434
    435     String str = frame->editor()->selectedText();
     435    String str = frame->editor()->selectedTextForClipboard();
    436436#if OS(WINDOWS)
    437437    replaceNewlinesWithWindowsStyleNewlines(str);
  • trunk/Source/WebCore/platform/chromium/PasteboardChromium.cpp

    r146264 r146835  
    8686}
    8787
    88 void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
     88void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
    8989{
    9090    String html = createMarkup(selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs);
    9191    KURL url = selectedRange->startContainer()->document()->url();
    92     String plainText = frame->editor()->selectedText();
     92    String plainText = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor()->selectedTextForClipboard() : frame->editor()->selectedText();
    9393#if OS(WINDOWS)
    9494    replaceNewlinesWithWindowsStyleNewlines(plainText);
  • trunk/Source/WebCore/platform/efl/PasteboardEfl.cpp

    r128570 r146835  
    5252}
    5353
    54 void Pasteboard::writeSelection(Range*, bool, Frame*)
     54void Pasteboard::writeSelection(Range*, bool, Frame*, ShouldSerializeSelectedTextForClipboard)
    5555{
    5656    notImplemented();
  • trunk/Source/WebCore/platform/gtk/ClipboardGtk.cpp

    r146644 r146835  
    312312    ASSERT(range);
    313313
    314     m_dataObject->setText(frame->editor()->selectedText());
     314    m_dataObject->setText(frame->editor()->selectedTextForClipboard());
    315315    m_dataObject->setMarkup(createMarkup(range, 0, AnnotateForInterchange, false, ResolveNonLocalURLs));
    316316
  • trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp

    r146264 r146835  
    5757}
    5858
    59 void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
    60 {
    61     PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper();
    62     GtkClipboard* clipboard = helper->getCurrentClipboard(frame);
    63 
    64     DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
    65     dataObject->clearAll();
    66 
    67     dataObject->setText(frame->editor()->selectedText());
     59void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
     60{
     61    PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper();
     62    GtkClipboard* clipboard = helper->getCurrentClipboard(frame);
     63
     64    DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
     65    dataObject->clearAll();
     66
     67    dataObject->setText(shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor()->selectedTextForClipboard() : frame->editor()->selectedText());
    6868    dataObject->setMarkup(createMarkup(selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs));
    6969    helper->writeClipboardContents(clipboard, canSmartCopyOrDelete ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste);
  • trunk/Source/WebCore/platform/mac/ClipboardMac.mm

    r146644 r146835  
    378378    ASSERT(frame);
    379379    Pasteboard pasteboard(m_pasteboardName);
    380     pasteboard.writeSelection(range, frame->editor()->smartInsertDeleteEnabled() && frame->selection()->granularity() == WordGranularity, frame);
     380    pasteboard.writeSelection(range, frame->editor()->smartInsertDeleteEnabled() && frame->selection()->granularity() == WordGranularity, frame, IncludeImageAltTextForClipboard);
    381381}
    382382
  • trunk/Source/WebCore/platform/mac/PasteboardMac.mm

    r146391 r146835  
    136136}
    137137
    138 String Pasteboard::getStringSelection(Frame* frame)
    139 {
    140     String text = frame->editor()->selectedText();
     138String Pasteboard::getStringSelection(Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
     139{
     140    String text = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor()->selectedTextForClipboard() : frame->editor()->selectedText();
    141141    text.replace(noBreakSpace, ' ');
    142142    return text;
     
    176176}
    177177
    178 void Pasteboard::writeSelectionForTypes(const Vector<String>& pasteboardTypes, bool canSmartCopyOrDelete, Frame* frame)
     178void Pasteboard::writeSelectionForTypes(const Vector<String>& pasteboardTypes, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
    179179{
    180180    NSAttributedString* attributedString = nil;
     
    209209    // Put plain string on the pasteboard.
    210210    if (types.contains(String(NSStringPboardType)))
    211         platformStrategies()->pasteboardStrategy()->setStringForType(getStringSelection(frame), NSStringPboardType, m_pasteboardName);
     211        platformStrategies()->pasteboardStrategy()->setStringForType(getStringSelection(frame, shouldSerializeSelectedTextForClipboard), NSStringPboardType, m_pasteboardName);
    212212   
    213213    if (types.contains(WebSmartPastePboardType))
     
    228228}
    229229   
    230 void Pasteboard::writeSelection(Range*, bool canSmartCopyOrDelete, Frame* frame)
    231 {
    232     writeSelectionForTypes(Vector<String>(), canSmartCopyOrDelete, frame);
     230void Pasteboard::writeSelection(Range*, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
     231{
     232    writeSelectionForTypes(Vector<String>(), canSmartCopyOrDelete, frame, shouldSerializeSelectedTextForClipboard);
    233233}
    234234
  • trunk/Source/WebCore/platform/qt/ClipboardQt.cpp

    r146723 r146835  
    327327    if (!m_writableData)
    328328        m_writableData = new QMimeData;
    329     QString text = frame->editor()->selectedText();
     329    QString text = frame->editor()->selectedTextForClipboard();
    330330    text.replace(QChar(0xa0), QLatin1Char(' '));
    331331    m_writableData->setText(text);
  • trunk/Source/WebCore/platform/qt/PasteboardQt.cpp

    r146264 r146835  
    6060}
    6161
    62 void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
     62void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
    6363{
    6464    QMimeData* md = new QMimeData;
    65     QString text = frame->editor()->selectedText();
     65    QString text = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor()->selectedTextForClipboard() : frame->editor()->selectedText();
    6666    text.replace(QChar(0xa0), QLatin1Char(' '));
    6767    md->setText(text);
  • trunk/Source/WebCore/platform/win/ClipboardWin.cpp

    r146644 r146835  
    748748        ::GlobalFree(medium.hGlobal);
    749749
    750     String str = frame->editor()->selectedText();
     750    String str = frame->editor()->selectedTextForClipboard();
    751751    replaceNewlinesWithWindowsStyleNewlines(str);
    752752    replaceNBSPWithSpace(str);
  • trunk/Source/WebCore/platform/win/PasteboardWin.cpp

    r144536 r146835  
    114114}
    115115
    116 void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
     116void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
    117117{
    118118    clear();
     
    130130   
    131131    // Put plain string on the pasteboard. CF_UNICODETEXT covers CF_TEXT as well
    132     String str = frame->editor()->selectedText();
     132    String str = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor()->selectedTextForClipboard() : frame->editor()->selectedText();
    133133    replaceNewlinesWithWindowsStyleNewlines(str);
    134134    replaceNBSPWithSpace(str);
  • trunk/Source/WebCore/platform/wince/PasteboardWinCE.cpp

    r141877 r146835  
    110110}
    111111
    112 void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
     112void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
    113113{
    114114    clear();
     
    125125
    126126    // Put plain string on the pasteboard. CF_UNICODETEXT covers CF_TEXT as well
    127     String str = frame->selectedText();
     127    String str = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor()->selectedTextForClipboard() : frame->editor()->selectedText();
    128128    replaceNewlinesWithWindowsStyleNewlines(str);
    129129    replaceNBSPWithSpace(str);
  • trunk/Source/WebCore/platform/wx/PasteboardWx.cpp

    r146264 r146835  
    5151}
    5252
    53 void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
     53void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
    5454{
    5555    if (wxTheClipboard->Open()) {
     
    5757        wxTheClipboard->SetData(new wxHTMLDataObject(createMarkup(selectedRange, 0, AnnotateForInterchange)));
    5858#endif
    59         wxTheClipboard->SetData(new wxTextDataObject(frame->editor()->selectedText()));
     59        wxTheClipboard->SetData(new wxTextDataObject(shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor()->selectedTextForClipboard() : frame->editor()->selectedText()));
    6060        wxTheClipboard->Close();
    6161    }
  • trunk/Source/WebCore/rendering/RenderImage.h

    r146279 r146835  
    5959
    6060    bool isGeneratedContent() const { return m_isGeneratedContent; }
     61
     62    String altText() const { return m_altText; }
    6163
    6264protected:
Note: See TracChangeset for help on using the changeset viewer.