[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:38:14 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit ee8f1dbd9f71041c4225d18b32f1118d4f78cdce
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue May 4 23:43:16 2004 +0000

            Reviewed by Hyatt
    
            Fix for behavior which extends selection drawing to beginning and end of blocks.
            I added this feature a few days ago, but my checks to see if the extension should
            be done was naive: Is first or last item in root line box selected? Clearly this
            needs to be "selection is *beyond* first or last item in root line box. Done.
    
            * khtml/rendering/render_image.cpp:
            (RenderImage::paint): Add selectionState() == SelectionInside check.
            * khtml/rendering/render_text.cpp:
            (InlineTextBox::paintSelection): Constrain passed-in offsets to be relative to box.
            Use passed-in offsets to check whether selection extends beyond this box. Also, now
            passes in flag to tell whether the whole RenderText has selectionState() == SelectionInside
            (in which case you always want to extend).
            (RenderText::paint): Remove box offset constraining from here. Now done in above function.
            * khtml/rendering/render_text.h: Modify paintSelection interface to add
            selectionState() == SelectionInside flag.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6539 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index c3f06a2..72fe80f 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,25 @@
 2004-05-04  Ken Kocienda  <kocienda at apple.com>
 
+        Reviewed by Hyatt
+        
+        Fix for behavior which extends selection drawing to beginning and end of blocks.
+        I added this feature a few days ago, but my checks to see if the extension should
+        be done was naive: Is first or last item in root line box selected? Clearly this 
+        needs to be "selection is *beyond* first or last item in root line box. Done.
+
+        * khtml/rendering/render_image.cpp:
+        (RenderImage::paint): Add selectionState() == SelectionInside check.
+        * khtml/rendering/render_text.cpp:
+        (InlineTextBox::paintSelection): Constrain passed-in offsets to be relative to box.
+        Use passed-in offsets to check whether selection extends beyond this box. Also, now
+        passes in flag to tell whether the whole RenderText has selectionState() == SelectionInside
+        (in which case you always want to extend).
+        (RenderText::paint): Remove box offset constraining from here. Now done in above function.
+        * khtml/rendering/render_text.h: Modify paintSelection interface to add 
+        selectionState() == SelectionInside flag.
+
+2004-05-04  Ken Kocienda  <kocienda at apple.com>
+
         Reviewed by me
         
         Added layout tests for DOM traversal objects.
diff --git a/WebCore/khtml/rendering/render_image.cpp b/WebCore/khtml/rendering/render_image.cpp
index 383a158..85da492 100644
--- a/WebCore/khtml/rendering/render_image.cpp
+++ b/WebCore/khtml/rendering/render_image.cpp
@@ -351,11 +351,11 @@ void RenderImage::paint(PaintInfo& i, int _tx, int _ty)
                 int absx, absy;
                 containingBlock()->absolutePosition(absx, absy);
 
-                if (box->root()->firstLeafChild() == box) {
+                if (selectionState() == SelectionInside && box->root()->firstLeafChild() == box) {
                     extendSelectionToLeft = true;
                     selectionLeft = absx + containingBlock()->leftOffset(selectionTop);
                 }
-                if (box->root()->lastLeafChild() == box) {
+                if (selectionState() == SelectionInside && box->root()->lastLeafChild() == box) {
                     extendSelectionToRight = true;
                     selectionRight = absx + containingBlock()->rightOffset(selectionTop);
                 }
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index cb6fee0..2b44a1a 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -94,10 +94,14 @@ void InlineTextBox::attachLine()
     static_cast<RenderText*>(m_object)->attachTextBox(this);
 }
 
-void InlineTextBox::paintSelection(const Font *f, RenderText *text, QPainter *p, RenderStyle* style, int tx, int ty, int startPos, int endPos)
+void InlineTextBox::paintSelection(const Font *f, RenderText *text, QPainter *p, RenderStyle* style, int tx, int ty, int startPos, int endPos, bool extendSelection)
 {
-    if(startPos > m_len) return;
-    if(startPos < 0) startPos = 0;
+    int offset = m_start;
+    int sPos = kMax(startPos - offset, 0);
+    int ePos = kMin(endPos - offset, (int)m_len);
+
+    if (sPos >= ePos)
+        return;
 
     p->save();
 #if APPLE_CHANGES
@@ -140,16 +144,16 @@ void InlineTextBox::paintSelection(const Font *f, RenderText *text, QPainter *p,
     int x = m_x + tx;
     int minX = x;
     int maxX = x;
-    if (startPos == 0 && root()->firstLeafChild() == this)
+    if ((extendSelection || startPos < m_start) && root()->firstLeafChild() == this)
         minX = absx + kMax(cb->leftOffset(ty), cb->leftOffset(root()->blockHeight()));
-    if (endPos == m_len && root()->lastLeafChild() == this)
+    if ((extendSelection || endPos > m_start + m_len) && root()->lastLeafChild() == this)
         maxX = absx + kMin(cb->rightOffset(ty), cb->rightOffset(root()->blockHeight()));
     
     f->drawHighlightForText(p, x, minX, maxX, absy + ty, h, text->str->s, text->str->l, m_start, m_len,
-		m_toAdd, m_reversed ? QPainter::RTL : QPainter::LTR, style->visuallyOrdered(), startPos, endPos, c);
+		m_toAdd, m_reversed ? QPainter::RTL : QPainter::LTR, style->visuallyOrdered(), sPos, ePos, c);
 #else
     f->drawHighlightForText(p, m_x + tx, m_y + ty, text->str->s, text->str->l, m_start, m_len,
-		m_toAdd, m_reversed ? QPainter::RTL : QPainter::LTR, startPos, endPos, c);
+		m_toAdd, m_reversed ? QPainter::RTL : QPainter::LTR, sPos, ePos, c);
 #endif
     p->restore();
 }
@@ -833,15 +837,7 @@ void RenderText::paint(PaintInfo& i, int tx, int ty)
         if (drawSelectionBackground)
 #endif
         if (!isPrinting && (selectionState() != SelectionNone))
-        {
-            int offset = s->m_start;
-            int sPos = QMAX( startPos - offset, 0 );
-            int ePos = QMIN( endPos - offset, s->m_len );
-            //kdDebug(6040) << this << " paintSelection with startPos=" << sPos << " endPos=" << ePos << endl;
-            if ( sPos < ePos )
-                s->paintSelection(font, this, p, _style, tx, ty, sPos, ePos);
-
-        }
+            s->paintSelection(font, this, p, _style, tx, ty, startPos, endPos, selectionState() == SelectionInside);
 
 #ifdef BIDI_DEBUG
         {
diff --git a/WebCore/khtml/rendering/render_text.h b/WebCore/khtml/rendering/render_text.h
index 8cffa20..4b36315 100644
--- a/WebCore/khtml/rendering/render_text.h
+++ b/WebCore/khtml/rendering/render_text.h
@@ -93,7 +93,7 @@ public:
     virtual bool isInlineTextBox() { return true; }
     
     void paintDecoration( QPainter *pt, int _tx, int _ty, int decoration);
-    void paintSelection(const Font *f, RenderText *text, QPainter *p, RenderStyle* style, int tx, int ty, int startPos, int endPos);
+    void paintSelection(const Font *f, RenderText *text, QPainter *p, RenderStyle* style, int tx, int ty, int startPos, int endPos, bool extendSelection);
 
     virtual long caretMinOffset() const;
     virtual long caretMaxOffset() const;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list