[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf

jberlin at webkit.org jberlin at webkit.org
Tue Jan 5 23:59:53 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit cc5f2ac814bd67c65bf033a31f5ec7edf8f4f3e8
Author: jberlin at webkit.org <jberlin at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 24 13:46:30 2009 +0000

            Fix for WebKit bug 29968 - Selecting text with text-overflow ellipsis
            should not show cut off text
            https://bugs.webkit.org/show_bug.cgi?id=29968
    
            Reviewed by Dan Bernstein.
    
            Also fixes the issue on both Mac OS X and Windows where the highlight
            would extend only partway into the ellipsis based on the size of the
            characters being truncated.
    
            Test: editing/selection/select-text-overflow-ellipsis.html
    
            WebCore:
    
            * rendering/EllipsisBox.cpp:
            (WebCore::EllipsisBox::paint):
            When the ellipsis have been selected, paints them with the color for
            selected text.
            (WebCore::EllipsisBox::selectionRect):
            Returns the selection rect for the ellipsis text.
            (WebCore::EllipsisBox::paintSelection):
            Paints the selection highlight around the ellipsis text.
    
            * rendering/EllipsisBox.h:
            (WebCore::EllipsisBox::EllipsisBox):
            Default the selection state of the EllipsisBox to SelectionNone.
            (WebCore::EllipsisBox::setSelectionState):
            Allow the selection state to be explicitly set by the InlineTextBox
            that it is associated with, since the selection state depends on the
            position of the selection within the truncated text.
            (WebCore::EllipsisBox::selectionState):
            Return the cached selection state.
    
            * rendering/InlineTextBox.cpp:
            (WebCore::InlineTextBox::selectionState):
            If the text is truncated and the selection extends into the truncation
            where there are ellipsis, set the selection state on the EllipsisBox.
            (WebCore::paintTextWithShadows):
            Allow for an upper bound to be specified on the maximum length of the
            text to be painted.
            (WebCore::InlineTextBox::paint):
            Make sure the text that is drawn gets appropriately truncated. This was
            not an issue before on Mac OS X because it wasn't necessary to draw the
            selected text separately (the selected text had the same color as the
            non-selected text).
            (WebCore::InlineTextBox::paintSelection):
            If the text is being truncated, let whatever is being painted in the
            space after the truncated text paint its own highlight.
    
            * rendering/InlineTextBox.h:
            (WebCore::InlineTextBox::truncation):
            Allow RenderText to access the truncation status.
    
            * rendering/RenderText.cpp:
            (WebCore::RenderText::selectionRectForRepaint):
            Make sure that any ellipsis box that falls within the selection also
            gets repainted.
    
            Places the expected results under the mac and win platforms separately
            because they are pixel test results and also the size of the
            RenderBlocks are showing up as slightly different between mac and win.
    
            LayoutTests:
    
            * editing/selection/select-text-overflow-ellipsis.html: Added.
            * platform/mac/editing/selection/select-text-overflow-ellipsis-expected.checksum: Added.
            * platform/mac/editing/selection/select-text-overflow-ellipsis-expected.png: Added.
            * platform/mac/editing/selection/select-text-overflow-ellipsis-expected.txt: Added.
            * platform/win/editing/selection/select-text-overflow-ellipsis-expected.checksum: Added.
            * platform/win/editing/selection/select-text-overflow-ellipsis-expected.png: Added.
            * platform/win/editing/selection/select-text-overflow-ellipsis-expected.txt: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 51c25b1..323fba0 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,27 @@
+2009-12-24  Jessie Berlin  <jberlin at webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        Fix for WebKit bug 29968 - Selecting text with text-overflow ellipsis
+        should not show cut off text
+        https://bugs.webkit.org/show_bug.cgi?id=29968
+        
+        Also fixes the issue on both Mac OS X and Windows where the highlight
+        would extend only partway into the ellipsis based on the size of the
+        characters being truncated.
+        
+        Places the expected results under the mac and win platforms separately
+        because they are pixel test results and also the size of the
+        RenderBlocks are showing up as slightly different between mac and win.
+
+        * editing/selection/select-text-overflow-ellipsis.html: Added.
+        * platform/mac/editing/selection/select-text-overflow-ellipsis-expected.checksum: Added.
+        * platform/mac/editing/selection/select-text-overflow-ellipsis-expected.png: Added.
+        * platform/mac/editing/selection/select-text-overflow-ellipsis-expected.txt: Added.
+        * platform/win/editing/selection/select-text-overflow-ellipsis-expected.checksum: Added.
+        * platform/win/editing/selection/select-text-overflow-ellipsis-expected.png: Added.
+        * platform/win/editing/selection/select-text-overflow-ellipsis-expected.txt: Added.
+
 2009-12-21  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/LayoutTests/editing/selection/select-text-overflow-ellipsis.html b/LayoutTests/editing/selection/select-text-overflow-ellipsis.html
new file mode 100644
index 0000000..f94fde3
--- /dev/null
+++ b/LayoutTests/editing/selection/select-text-overflow-ellipsis.html
@@ -0,0 +1,19 @@
+<html>
+  <head>
+    <title>Test for WebKit bug 29968: Selecting text with text-overflow ellipsis should not show cut off text</head>
+  <style type="text/css">
+    .cutoff {
+      width: 95px;
+      white-space: pre;
+      overflow: hidden;
+      text-overflow: ellipsis;
+    }
+  </style>
+  <body>
+    <h3>Test for <a href='https://bugs.webkit.org/show_bug.cgi?id=29968'>WebKit bug 29968</a>: Selecting text with text-overflow ellipsis should not show cut off text</h3>
+    <div id="selection_with_ellipsis" class="cutoff">Lorem ipsum dolor</div>
+    <script type="text/javascript">
+      getSelection().setBaseAndExtent(selection_with_ellipsis.firstChild, 0, selection_with_ellipsis.firstChild, 11);
+    </script>
+  </body>
+</html>
diff --git a/LayoutTests/platform/mac/editing/selection/select-text-overflow-ellipsis-expected.checksum b/LayoutTests/platform/mac/editing/selection/select-text-overflow-ellipsis-expected.checksum
new file mode 100644
index 0000000..3009007
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/select-text-overflow-ellipsis-expected.checksum
@@ -0,0 +1 @@
+e2c2782746a40e3a5a17462dfb23e934
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/selection/select-text-overflow-ellipsis-expected.png b/LayoutTests/platform/mac/editing/selection/select-text-overflow-ellipsis-expected.png
new file mode 100644
index 0000000..92bdb57
Binary files /dev/null and b/LayoutTests/platform/mac/editing/selection/select-text-overflow-ellipsis-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/select-text-overflow-ellipsis-expected.txt b/LayoutTests/platform/mac/editing/selection/select-text-overflow-ellipsis-expected.txt
new file mode 100644
index 0000000..65c7676
--- /dev/null
+++ b/LayoutTests/platform/mac/editing/selection/select-text-overflow-ellipsis-expected.txt
@@ -0,0 +1,19 @@
+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 {H3} at (0,0) size 784x22
+        RenderText {#text} at (0,0) size 68x22
+          text run at (0,0) width 68: "Test for "
+        RenderInline {A} at (0,0) size 156x22 [color=#0000EE]
+          RenderText {#text} at (68,0) size 156x22
+            text run at (68,0) width 156: "WebKit bug 29968"
+        RenderText {#text} at (224,0) size 560x22
+          text run at (224,0) width 560: ": Selecting text with text-overflow ellipsis should not show cut off text"
+layer at (8,48) size 95x18 scrollWidth 121
+  RenderBlock {DIV} at (0,40) size 95x18
+    RenderText {#text} at (0,0) size 121x18
+      text run at (0,0) width 121: "Lorem ipsum dolor"
+selection start: position 0 of child 0 {#text} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 11 of child 0 {#text} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/win/editing/selection/select-text-overflow-ellipsis-expected.checksum b/LayoutTests/platform/win/editing/selection/select-text-overflow-ellipsis-expected.checksum
new file mode 100644
index 0000000..c8cdc53
--- /dev/null
+++ b/LayoutTests/platform/win/editing/selection/select-text-overflow-ellipsis-expected.checksum
@@ -0,0 +1 @@
+af7503d3c725ac726fc10b9ddc00a55a
\ No newline at end of file
diff --git a/LayoutTests/platform/win/editing/selection/select-text-overflow-ellipsis-expected.png b/LayoutTests/platform/win/editing/selection/select-text-overflow-ellipsis-expected.png
new file mode 100644
index 0000000..7265b71
Binary files /dev/null and b/LayoutTests/platform/win/editing/selection/select-text-overflow-ellipsis-expected.png differ
diff --git a/LayoutTests/platform/win/editing/selection/select-text-overflow-ellipsis-expected.txt b/LayoutTests/platform/win/editing/selection/select-text-overflow-ellipsis-expected.txt
new file mode 100644
index 0000000..7ebb1a8
--- /dev/null
+++ b/LayoutTests/platform/win/editing/selection/select-text-overflow-ellipsis-expected.txt
@@ -0,0 +1,19 @@
+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 {H3} at (0,0) size 784x25
+        RenderText {#text} at (0,0) size 68x24
+          text run at (0,0) width 68: "Test for "
+        RenderInline {A} at (0,0) size 156x24 [color=#0000EE]
+          RenderText {#text} at (68,0) size 156x24
+            text run at (68,0) width 156: "WebKit bug 29968"
+        RenderText {#text} at (224,0) size 560x24
+          text run at (224,0) width 560: ": Selecting text with text-overflow ellipsis should not show cut off text"
+layer at (8,51) size 95x21 scrollWidth 121
+  RenderBlock {DIV} at (0,43) size 95x21
+    RenderText {#text} at (0,0) size 121x20
+      text run at (0,0) width 121: "Lorem ipsum dolor"
+selection start: position 0 of child 0 {#text} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 11 of child 0 {#text} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 50dd919..f4b0a39 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,61 @@
+2009-12-24  Jessie Berlin  <jberlin at webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        Fix for WebKit bug 29968 - Selecting text with text-overflow ellipsis
+        should not show cut off text
+        https://bugs.webkit.org/show_bug.cgi?id=29968
+
+        Also fixes the issue on both Mac OS X and Windows where the highlight
+        would extend only partway into the ellipsis based on the size of the
+        characters being truncated.
+
+        Test: editing/selection/select-text-overflow-ellipsis.html
+
+        * rendering/EllipsisBox.cpp:
+        (WebCore::EllipsisBox::paint):
+        When the ellipsis have been selected, paints them with the color for
+        selected text.
+        (WebCore::EllipsisBox::selectionRect):
+        Returns the selection rect for the ellipsis text.
+        (WebCore::EllipsisBox::paintSelection):
+        Paints the selection highlight around the ellipsis text.
+
+        * rendering/EllipsisBox.h:
+        (WebCore::EllipsisBox::EllipsisBox):
+        Default the selection state of the EllipsisBox to SelectionNone.
+        (WebCore::EllipsisBox::setSelectionState):
+        Allow the selection state to be explicitly set by the InlineTextBox
+        that it is associated with, since the selection state depends on the
+        position of the selection within the truncated text.
+        (WebCore::EllipsisBox::selectionState):
+        Return the cached selection state.
+        
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::selectionState):
+        If the text is truncated and the selection extends into the truncation
+        where there are ellipsis, set the selection state on the EllipsisBox.
+        (WebCore::paintTextWithShadows):
+        Allow for an upper bound to be specified on the maximum length of the
+        text to be painted.
+        (WebCore::InlineTextBox::paint):
+        Make sure the text that is drawn gets appropriately truncated. This was
+        not an issue before on Mac OS X because it wasn't necessary to draw the
+        selected text separately (the selected text had the same color as the
+        non-selected text).
+        (WebCore::InlineTextBox::paintSelection):
+        If the text is being truncated, let whatever is being painted in the
+        space after the truncated text paint its own highlight. 
+        
+        * rendering/InlineTextBox.h:
+        (WebCore::InlineTextBox::truncation):
+        Allow RenderText to access the truncation status.
+        
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::selectionRectForRepaint):
+        Make sure that any ellipsis box that falls within the selection also
+        gets repainted.
+
 2009-12-24  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/rendering/EllipsisBox.cpp b/WebCore/rendering/EllipsisBox.cpp
index bea9d73..6ec3195 100644
--- a/WebCore/rendering/EllipsisBox.cpp
+++ b/WebCore/rendering/EllipsisBox.cpp
@@ -23,6 +23,7 @@
 #include "Document.h"
 #include "GraphicsContext.h"
 #include "HitTestResult.h"
+#include "RootInlineBox.h"
 
 namespace WebCore {
 
@@ -40,9 +41,22 @@ void EllipsisBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
         setShadow = true;
     }
 
+    if (selectionState() != RenderObject::SelectionNone) {
+        paintSelection(context, tx, ty, style, style->font());
+
+        // Select the correct color for painting the text.
+        Color foreground = paintInfo.forceBlackText ? Color::black : renderer()->selectionForegroundColor();
+        if (foreground.isValid() && foreground != textColor)
+            context->setFillColor(foreground, style->colorSpace());
+    }
+
     const String& str = m_str;
     context->drawText(style->font(), TextRun(str.characters(), str.length(), false, 0, 0, false, style->visuallyOrdered()), IntPoint(m_x + tx, m_y + ty + style->font().ascent()));
 
+    // Restore the regular fill color.
+    if (textColor != context->fillColor())
+        context->setFillColor(textColor, style->colorSpace());
+
     if (setShadow)
         context->clearShadow();
 
@@ -54,6 +68,35 @@ void EllipsisBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
     }
 }
 
+IntRect EllipsisBox::selectionRect(int tx, int ty)
+{
+    RenderStyle* style = m_renderer->style(m_firstLine);
+    const Font& f = style->font();
+    return enclosingIntRect(f.selectionRectForText(TextRun(m_str.characters(), m_str.length(), false, 0, 0, false, style->visuallyOrdered()),
+            IntPoint(m_x + tx, m_y + ty + root()->selectionTop()), root()->selectionHeight()));
+}
+
+void EllipsisBox::paintSelection(GraphicsContext* context, int tx, int ty, RenderStyle* style, const Font& font)
+{
+    Color textColor = style->color();
+    Color c = m_renderer->selectionBackgroundColor();
+    if (!c.isValid() || !c.alpha())
+        return;
+
+    // If the text color ends up being the same as the selection background, invert the selection
+    // background.
+    if (textColor == c)
+        c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
+
+    context->save();
+    int y = root()->selectionTop();
+    int h = root()->selectionHeight();
+    context->clip(IntRect(m_x + tx, y + ty, m_width, h));
+    context->drawHighlightForText(font, TextRun(m_str.characters(), m_str.length(), false, 0, 0, false, style->visuallyOrdered()),
+        IntPoint(m_x + tx, m_y + ty + y), h, c, style->colorSpace());
+    context->restore();
+}
+
 bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty)
 {
     tx += m_x;
diff --git a/WebCore/rendering/EllipsisBox.h b/WebCore/rendering/EllipsisBox.h
index a228d7a..087fc72 100644
--- a/WebCore/rendering/EllipsisBox.h
+++ b/WebCore/rendering/EllipsisBox.h
@@ -35,18 +35,24 @@ public:
         , m_height(height)
         , m_str(ellipsisStr)
         , m_markupBox(markupBox)
+        , m_selectionState(RenderObject::SelectionNone)
     {
     }
 
     virtual void paint(RenderObject::PaintInfo&, int tx, int ty);
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty);
+    void setSelectionState(RenderObject::SelectionState s) { m_selectionState = s; }
+    IntRect selectionRect(int tx, int ty);
 
 private:
     virtual int height() const { return m_height; }
+    virtual RenderObject::SelectionState selectionState() { return m_selectionState; }
+    void paintSelection(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&);
 
     int m_height;
     AtomicString m_str;
     InlineBox* m_markupBox;
+    RenderObject::SelectionState m_selectionState;
 };
 
 } // namespace WebCore
diff --git a/WebCore/rendering/InlineTextBox.cpp b/WebCore/rendering/InlineTextBox.cpp
index b44c5e0..234bb18 100644
--- a/WebCore/rendering/InlineTextBox.cpp
+++ b/WebCore/rendering/InlineTextBox.cpp
@@ -27,6 +27,7 @@
 #include "ChromeClient.h"
 #include "Document.h"
 #include "Editor.h"
+#include "EllipsisBox.h"
 #include "Frame.h"
 #include "GraphicsContext.h"
 #include "HitTestResult.h"
@@ -82,6 +83,23 @@ RenderObject::SelectionState InlineTextBox::selectionState()
         else if (state == RenderObject::SelectionBoth)
             state = RenderObject::SelectionNone;
     }
+
+    // If there are ellipsis following, make sure their selection is updated.
+    if (m_truncation != cNoTruncation && root()->ellipsisBox()) {
+        EllipsisBox* ellipsis = root()->ellipsisBox();
+        if (state != RenderObject::SelectionNone) {
+            int start, end;
+            selectionStartEnd(start, end);
+            // The ellipsis should be considered to be selected if the end of
+            // the selection is past the beginning of the truncation and the
+            // beginning of the selection is before or at the beginning of the
+            // truncation.
+            ellipsis->setSelectionState(end >= m_truncation && start <= m_truncation ?
+                RenderObject::SelectionInside : RenderObject::SelectionNone);
+        } else
+            ellipsis->setSelectionState(RenderObject::SelectionNone);
+    }
+
     return state;
 }
 
@@ -255,7 +273,7 @@ bool InlineTextBox::nodeAtPoint(const HitTestRequest&, HitTestResult& result, in
     return false;
 }
 
-static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, int startOffset, int endOffset, const IntPoint& textOrigin, int x, int y, int w, int h, ShadowData* shadow, bool stroked)
+static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, int startOffset, int endOffset, int truncationPoint, const IntPoint& textOrigin, int x, int y, int w, int h, ShadowData* shadow, bool stroked)
 {
     Color fillColor = context->fillColor();
     ColorSpace fillColorSpace = context->fillColorSpace();
@@ -290,8 +308,8 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con
         else {
             if (endOffset > 0)
                 context->drawText(font, textRun, textOrigin + extraOffset,  0, endOffset);
-            if (startOffset < textRun.length())
-                context->drawText(font, textRun, textOrigin + extraOffset, startOffset);
+            if (startOffset < truncationPoint)
+                context->drawText(font, textRun, textOrigin + extraOffset, startOffset, truncationPoint);
         }
 
         if (!shadow)
@@ -461,6 +479,13 @@ void InlineTextBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
     if (paintSelectedTextOnly || paintSelectedTextSeparately)
         selectionStartEnd(sPos, ePos);
 
+    int length = m_len;
+    if (m_truncation != cNoTruncation) {
+        sPos = min<int>(sPos, m_truncation);
+        ePos = min<int>(ePos, m_truncation);
+        length = m_truncation;
+    }
+
     if (!paintSelectedTextOnly) {
         // For stroked painting, we have to change the text drawing mode.  It's probably dangerous to leave that mutated as a side
         // effect, so only when we know we're stroking, do a save/restore.
@@ -470,9 +495,9 @@ void InlineTextBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
         updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace());
         if (!paintSelectedTextSeparately || ePos <= sPos) {
             // FIXME: Truncate right-to-left text correctly.
-            paintTextWithShadows(context, font, textRun, 0, m_truncation == cNoTruncation ? m_len : m_truncation, textOrigin, m_x + tx, m_y + ty, width(), height(), textShadow, textStrokeWidth > 0);
+            paintTextWithShadows(context, font, textRun, 0, length, length, textOrigin, m_x + tx, m_y + ty, width(), height(), textShadow, textStrokeWidth > 0);
         } else
-            paintTextWithShadows(context, font, textRun, ePos, sPos, textOrigin, m_x + tx, m_y + ty, width(), height(), textShadow, textStrokeWidth > 0);
+            paintTextWithShadows(context, font, textRun, ePos, sPos, length, textOrigin, m_x + tx, m_y + ty, width(), height(), textShadow, textStrokeWidth > 0);
 
         if (textStrokeWidth > 0)
             context->restore();
@@ -484,7 +509,7 @@ void InlineTextBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
             context->save();
 
         updateGraphicsContext(context, selectionFillColor, selectionStrokeColor, selectionStrokeWidth, styleToUse->colorSpace());
-        paintTextWithShadows(context, font, textRun, sPos, ePos, textOrigin, m_x + tx, m_y + ty, width(), height(), selectionShadow, selectionStrokeWidth > 0);
+        paintTextWithShadows(context, font, textRun, sPos, ePos, length, textOrigin, m_x + tx, m_y + ty, width(), height(), selectionShadow, selectionStrokeWidth > 0);
 
         if (selectionStrokeWidth > 0)
             context->restore();
@@ -566,8 +591,11 @@ void InlineTextBox::paintSelection(GraphicsContext* context, int tx, int ty, Ren
     updateGraphicsContext(context, c, c, 0, style->colorSpace());  // Don't draw text at all!
     int y = selectionTop();
     int h = selectionHeight();
+    // If the text is truncated, let the thing being painted in the truncation
+    // draw its own highlight.
+    int length = m_truncation != cNoTruncation ? m_truncation : m_len;
     context->clip(IntRect(m_x + tx, y + ty, m_width, h));
-    context->drawHighlightForText(font, TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, 
+    context->drawHighlightForText(font, TextRun(textRenderer()->text()->characters() + m_start, length, textRenderer()->allowTabs(), textPos(), m_toAdd, 
                                   direction() == RTL, m_dirOverride || style->visuallyOrdered()),
                                   IntPoint(m_x + tx, y + ty), h, c, style->colorSpace(), sPos, ePos);
     context->restore();
diff --git a/WebCore/rendering/InlineTextBox.h b/WebCore/rendering/InlineTextBox.h
index 80af2e3..0a83ddd 100644
--- a/WebCore/rendering/InlineTextBox.h
+++ b/WebCore/rendering/InlineTextBox.h
@@ -62,6 +62,8 @@ public:
     void setFallbackFonts(const HashSet<const SimpleFontData*>&);
     void takeFallbackFonts(Vector<const SimpleFontData*>&);
 
+    unsigned short truncation() { return m_truncation; }
+
 private:
     virtual int selectionTop();
     virtual int selectionHeight();
diff --git a/WebCore/rendering/RenderText.cpp b/WebCore/rendering/RenderText.cpp
index 3e48a70..8006ba3 100644
--- a/WebCore/rendering/RenderText.cpp
+++ b/WebCore/rendering/RenderText.cpp
@@ -26,6 +26,7 @@
 #include "RenderText.h"
 
 #include "CharacterNames.h"
+#include "EllipsisBox.h"
 #include "FloatQuad.h"
 #include "FrameView.h"
 #include "InlineTextBox.h"
@@ -1171,9 +1172,25 @@ IntRect RenderText::selectionRectForRepaint(RenderBoxModelObject* repaintContain
         return IntRect();
 
     IntRect rect;
-    for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox())
+    for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
         rect.unite(box->selectionRect(0, 0, startPos, endPos));
 
+        // Check if there are ellipsis which fall within the selection.
+        unsigned short truncation = box->truncation();
+        if (truncation != cNoTruncation) {
+            if (EllipsisBox* ellipsis = box->root()->ellipsisBox()) {
+                int ePos = min<int>(endPos - box->start(), box->len());
+                int sPos = max<int>(startPos - box->start(), 0);
+                // The ellipsis should be considered to be selected if the end of
+                // the selection is past the beginning of the truncation and the
+                // beginning of the selection is before or at the beginning of the
+                // truncation.
+                if (ePos >= truncation && sPos <= truncation)
+                    rect.unite(ellipsis->selectionRect(0, 0));
+            }
+        }
+    }
+
     if (clipToVisibleContent)
         computeRectForRepaint(repaintContainer, rect);
     else {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list