[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:52:49 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit b6f8074b6061a505f2d72b2685a6493aa235d3c1
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jul 27 22:00:32 2004 +0000
Reviewed by Hyatt
Fixed the problem where BR elements on lines by themselves don't paint when selected.
* khtml/khtml_part.cpp:
(KHTMLPart::selectAll): Related fix. Include BR's when figuring out what "all" is.
* khtml/rendering/render_br.cpp:
(RenderBR::paint): New function implementation. Teach BR's how to paint selections.
* khtml/rendering/render_br.h:
* khtml/rendering/render_text.cpp:
(InlineTextBox::paintSelection): Fix some geometry calculations to be more readable (i.e. don't
reuse function argument as a local). Also, improve the logic for determining whether to
extend the selection to block boundaries.
(RenderText::paint): Remove extendSelection argument from paintSelection. The logic to figure out
extensions is now fully contained in paintSelection.
* khtml/rendering/render_text.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@7131 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index e40dd65..d443d7b 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,22 @@
+2004-07-27 Ken Kocienda <kocienda at apple.com>
+
+ Reviewed by Hyatt
+
+ Fixed the problem where BR elements on lines by themselves don't paint when selected.
+
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::selectAll): Related fix. Include BR's when figuring out what "all" is.
+ * khtml/rendering/render_br.cpp:
+ (RenderBR::paint): New function implementation. Teach BR's how to paint selections.
+ * khtml/rendering/render_br.h:
+ * khtml/rendering/render_text.cpp:
+ (InlineTextBox::paintSelection): Fix some geometry calculations to be more readable (i.e. don't
+ reuse function argument as a local). Also, improve the logic for determining whether to
+ extend the selection to block boundaries.
+ (RenderText::paint): Remove extendSelection argument from paintSelection. The logic to figure out
+ extensions is now fully contained in paintSelection.
+ * khtml/rendering/render_text.h:
+
2004-07-27 David Hyatt <hyatt at apple.com>
Fix for 3665211 (again). Make sure not to leave child line boxes pointing to deleted ancestor line boxes.
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index e5d7bab..db89dcb 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -4874,8 +4874,8 @@ void KHTMLPart::selectAll()
first = d->m_doc;
NodeImpl *next;
- // Look for first text/cdata node that has a renderer
- while ( first && !((first->nodeType() == Node::TEXT_NODE || first->nodeType() == Node::CDATA_SECTION_NODE) && first->renderer()) )
+ // Look for first rendered text node
+ while (first && !(first->renderer() && first->renderer()->isText()))
{
next = first->firstChild();
if ( !next ) next = first->nextSibling();
@@ -4893,8 +4893,8 @@ void KHTMLPart::selectAll()
last = static_cast<HTMLDocumentImpl*>(d->m_doc)->body();
else
last = d->m_doc;
- // Look for last text/cdata node that has a renderer
- while ( last && !((last->nodeType() == Node::TEXT_NODE || last->nodeType() == Node::CDATA_SECTION_NODE) && last->renderer()) )
+ // Look for last rendered text node
+ while (last && !(last->renderer() && last->renderer()->isText()))
{
next = last->lastChild();
if ( !next ) next = last->previousSibling();
diff --git a/WebCore/khtml/rendering/render_br.cpp b/WebCore/khtml/rendering/render_br.cpp
index 62d908f..b37d7ba 100644
--- a/WebCore/khtml/rendering/render_br.cpp
+++ b/WebCore/khtml/rendering/render_br.cpp
@@ -20,7 +20,10 @@
*
*/
#include "render_br.h"
-#include "xml/dom_position.h"
+
+#include "dom_position.h"
+#include "render_block.h"
+#include "render_line.h"
using namespace khtml;
using DOM::Position;
@@ -127,3 +130,64 @@ InlineBox *RenderBR::inlineBox(long offset)
{
return firstTextBox();
}
+
+void RenderBR::paint(PaintInfo& i, int tx, int ty)
+{
+#if APPLE_CHANGES
+ if (!firstTextBox() || selectionState() == SelectionNone || (i.phase != PaintActionForeground && i.phase != PaintActionSelection))
+ return;
+
+ bool isPrinting = (i.p->device()->devType() == QInternal::Printer);
+ if (isPrinting)
+ return;
+
+ // Do the calculations to draw selections as tall as the line.
+ // Use the bottom of the line above as the y position (if there is one,
+ // otherwise use the top of this renderer's line) and the height of the line as the height.
+ // This mimics Cocoa.
+ int y = 0;
+ RootInlineBox *root = firstTextBox()->root();
+ if (root->prevRootBox())
+ y = root->prevRootBox()->bottomOverflow();
+ else
+ y = root->topOverflow();
+
+ int h = root->bottomOverflow() - y;
+
+ RenderBlock *cb = containingBlock();
+
+ // Extend selection to the start of the line if:
+ // 1. The starting point of the selection is at or beyond the start of the text box; and
+ // 2. This box is the first box on the line; and
+ // 3. There is a another line before this one (first lines have special behavior;
+ // the selection never extends on the first line); and
+ // 4. The last leaf renderer on the previous line is selected.
+ int x = firstTextBox()->xPos();
+ RenderObject *prevLineLastLeaf = root->prevRootBox() ? root->prevRootBox()->lastLeafChild()->object() : 0;
+ if (root->firstLeafChild() == firstTextBox() && root->prevRootBox() && prevLineLastLeaf &&
+ prevLineLastLeaf->selectionState() != RenderObject::SelectionNone)
+ x = kMax(cb->leftOffset(y), cb->leftOffset(root->blockHeight()));
+
+ // Extending to the end of the line is "automatic" with BR's.
+ int maxX = kMin(cb->rightOffset(y), cb->rightOffset(root->blockHeight()));
+ int w = maxX - x;
+
+ // Macintosh-style text highlighting is to draw with a particular background color, not invert.
+ i.p->save();
+ QColor textColor = style()->color();
+ QColor c = i.p->selectedTextBackgroundColor();
+
+ // if text color and selection background color are identical, invert background color.
+ if (textColor == c)
+ c = QColor(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
+
+ RenderStyle* pseudoStyle = getPseudoStyle(RenderStyle::SELECTION);
+ if (pseudoStyle && pseudoStyle->backgroundColor().isValid())
+ c = pseudoStyle->backgroundColor();
+
+ QBrush brush = i.p->brush();
+ brush.setColor(c);
+ i.p->fillRect(x + tx, y + ty, w, h, brush);
+ i.p->restore();
+#endif
+}
diff --git a/WebCore/khtml/rendering/render_br.h b/WebCore/khtml/rendering/render_br.h
index 077fd2e..b264a14 100644
--- a/WebCore/khtml/rendering/render_br.h
+++ b/WebCore/khtml/rendering/render_br.h
@@ -42,7 +42,7 @@ public:
virtual const char *renderName() const { return "RenderBR"; }
- virtual void paint(PaintInfo&, int, int) {}
+ virtual void paint(PaintInfo& i, int tx, int ty);
virtual void position(InlineBox* box, int from, int len, bool reverse);
virtual unsigned int width(unsigned int, unsigned int, const Font *) const { return 0; }
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index d1cfdef..e2ec0fe 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -25,6 +25,7 @@
//#define BIDI_DEBUG
#include "rendering/render_canvas.h"
+#include "rendering/render_object.h"
#include "rendering/render_text.h"
#include "rendering/break_lines.h"
#include "xml/dom_nodeimpl.h"
@@ -137,7 +138,7 @@ int InlineTextBox::placeEllipsisBox(bool ltr, int blockEdge, int ellipsisWidth,
return -1;
}
-void InlineTextBox::paintSelection(const Font *f, RenderText *text, QPainter *p, RenderStyle* style, int tx, int ty, int startPos, int endPos, bool extendSelection)
+void InlineTextBox::paintSelection(const Font *f, RenderText *text, QPainter *p, RenderStyle* style, int tx, int ty, int startPos, int endPos)
{
int offset = m_start;
int sPos = kMax(startPos - offset, 0);
@@ -174,25 +175,38 @@ void InlineTextBox::paintSelection(const Font *f, RenderText *text, QPainter *p,
// This mimics Cocoa.
RenderBlock *cb = object()->containingBlock();
+ int y = 0;
if (root()->prevRootBox())
- ty = root()->prevRootBox()->bottomOverflow();
+ y = root()->prevRootBox()->bottomOverflow();
else
- ty = root()->topOverflow();
+ y = root()->topOverflow();
- int h = root()->bottomOverflow() - ty;
+ int h = root()->bottomOverflow() - y;
- int absx, absy;
- cb->absolutePosition(absx, absy);
-
- int x = m_x + tx;
+ int x = m_x;
int minX = x;
int maxX = x;
- if ((extendSelection || startPos < m_start) && root()->firstLeafChild() == this)
- minX = absx + kMax(cb->leftOffset(ty), cb->leftOffset(root()->blockHeight()));
- if ((extendSelection || endPos > m_start + m_len) && root()->lastLeafChild() == this)
- maxX = absx + kMin(cb->rightOffset(ty), cb->rightOffset(root()->blockHeight()));
+
+ // Extend selection to the start of the line if:
+ // 1. The starting point of the selection is at or beyond the start of the text box; and
+ // 2. This box is the first box on the line; and
+ // 3. There is a another line before this one (first lines have special behavior;
+ // the selection never extends on the first line); and
+ // 4. The last leaf renderer on the previous line is selected.
+ RenderObject *prevLineLastLeaf = root()->prevRootBox() ? root()->prevRootBox()->lastLeafChild()->object() : 0;
+ if (startPos <= m_start && root()->firstLeafChild() == this && root()->prevRootBox() && prevLineLastLeaf &&
+ prevLineLastLeaf->selectionState() != RenderObject::SelectionNone)
+ minX = kMax(cb->leftOffset(y), cb->leftOffset(root()->blockHeight()));
+
+ // Extend selection to the end of the line if:
+ // 1. The ending point of the selection is at or beyond the end of the text box; and
+ // 2. There is a another line after this one (last lines have special behavior;
+ // the selection never extends on the last line); and
+ // 3. The last leaf renderer of the root box is this box.
+ if (endPos >= m_start + m_len && root()->nextRootBox() && root()->lastLeafChild() == this)
+ maxX = kMin(cb->rightOffset(y), cb->rightOffset(root()->blockHeight()));
- f->drawHighlightForText(p, x, minX, maxX, absy + ty, h, text->str->s, text->str->l, m_start, m_len,
+ f->drawHighlightForText(p, x + tx, minX + tx, maxX + tx, y + ty, h, text->str->s, text->str->l, m_start, m_len,
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,
@@ -848,7 +862,7 @@ void RenderText::paint(PaintInfo& i, int tx, int ty)
if (drawSelectionBackground)
#endif
if (!isPrinting && (selectionState() != SelectionNone))
- s->paintSelection(font, this, p, _style, tx, ty, startPos, endPos, selectionState() == SelectionInside);
+ s->paintSelection(font, this, p, _style, tx, ty, startPos, endPos);
#ifdef BIDI_DEBUG
{
diff --git a/WebCore/khtml/rendering/render_text.h b/WebCore/khtml/rendering/render_text.h
index 91e0fae..5e02bef 100644
--- a/WebCore/khtml/rendering/render_text.h
+++ b/WebCore/khtml/rendering/render_text.h
@@ -100,7 +100,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, bool extendSelection);
+ void paintSelection(const Font *f, RenderText *text, QPainter *p, RenderStyle* style, int tx, int ty, int startPos, int endPos);
virtual long caretMinOffset() const;
virtual long caretMaxOffset() const;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list