[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
cblu
cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:21:54 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 3b3b202a370dc593e92ae3672827bb82a4b42d6e
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Jan 25 22:37:39 2003 +0000
WebCore:
Fixed: 3153605 - Drag image when dragging text should be the actual text
Reviewed by darin.
* khtml/rendering/font.cpp:
(Font::drawLineForText): take a "from" and "to" so only selected portions of text draw lines
* khtml/rendering/font.h:
* khtml/rendering/render_layer.cpp:
(RenderLayer::paint): handle the selection-only case
* khtml/rendering/render_layer.h:
* khtml/rendering/render_root.cpp:
(RenderRoot::selectionRect): new, computes bounding box of the selection
* khtml/rendering/render_root.h:
* khtml/rendering/render_text.cpp:
(TextSlave::paintDecoration): take a "from" and "to" so only selected portions of text draw lines
(RenderText::paintObject): when only drawing the selection, only draw selected text and no selection background
(RenderText::paint): handle the selection-only case
* khtml/rendering/render_text.h:
* kwq/KWQKHTMLPart.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::paint): handle the selection-only case
(KWQKHTMLPart::selectionRect): new, returns the bounding box of the selection
* kwq/KWQPainter.h:
* kwq/KWQPainter.mm:
(QPainter::drawLineForText): take a "from" and "to" so only selected portions of text draw lines
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge drawRect:withPainter:]): handle the selection-only case
(-[WebCoreBridge selectionRect]): new, returns the bounding box of the selection clipped to visible
(-[WebCoreBridge selectionImage]): new, returns the image of the selection
WebKit:
Fixed: 3153605 - Drag image when dragging text should be the actual text
Reviewed by darin.
* Misc.subproj/WebNSImageExtras.m:
(-[NSImage _web_dissolveToFraction:]): handle non-flipped images
* Misc.subproj/WebNSViewExtras.h: moved some constants around
* Misc.subproj/WebNSViewExtras.m:
* Resources/text_clipping.tiff: Removed.
* WebKit.pbproj/project.pbxproj:
* WebView.subproj/WebHTMLViewPrivate.m:
(-[WebHTMLView _handleMouseDragged:]): cleaned-up, get text drag image from WebCore
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3455 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 1c3130f..2fadbad 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,36 @@
+2003-01-25 Chris Blumenberg <cblu at apple.com>
+
+ Fixed: 3153605 - Drag image when dragging text should be the actual text
+
+ Reviewed by darin.
+
+ * khtml/rendering/font.cpp:
+ (Font::drawLineForText): take a "from" and "to" so only selected portions of text draw lines
+ * khtml/rendering/font.h:
+ * khtml/rendering/render_layer.cpp:
+ (RenderLayer::paint): handle the selection-only case
+ * khtml/rendering/render_layer.h:
+ * khtml/rendering/render_root.cpp:
+ (RenderRoot::selectionRect): new, computes bounding box of the selection
+ * khtml/rendering/render_root.h:
+ * khtml/rendering/render_text.cpp:
+ (TextSlave::paintDecoration): take a "from" and "to" so only selected portions of text draw lines
+ (RenderText::paintObject): when only drawing the selection, only draw selected text and no selection background
+ (RenderText::paint): handle the selection-only case
+ * khtml/rendering/render_text.h:
+ * kwq/KWQKHTMLPart.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::paint): handle the selection-only case
+ (KWQKHTMLPart::selectionRect): new, returns the bounding box of the selection
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (QPainter::drawLineForText): take a "from" and "to" so only selected portions of text draw lines
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge drawRect:withPainter:]): handle the selection-only case
+ (-[WebCoreBridge selectionRect]): new, returns the bounding box of the selection clipped to visible
+ (-[WebCoreBridge selectionImage]): new, returns the image of the selection
+
2003-01-24 David Hyatt <hyatt at apple.com>
Fix for 3153260, tables used as height spacers don't get the
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 1c3130f..2fadbad 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,36 @@
+2003-01-25 Chris Blumenberg <cblu at apple.com>
+
+ Fixed: 3153605 - Drag image when dragging text should be the actual text
+
+ Reviewed by darin.
+
+ * khtml/rendering/font.cpp:
+ (Font::drawLineForText): take a "from" and "to" so only selected portions of text draw lines
+ * khtml/rendering/font.h:
+ * khtml/rendering/render_layer.cpp:
+ (RenderLayer::paint): handle the selection-only case
+ * khtml/rendering/render_layer.h:
+ * khtml/rendering/render_root.cpp:
+ (RenderRoot::selectionRect): new, computes bounding box of the selection
+ * khtml/rendering/render_root.h:
+ * khtml/rendering/render_text.cpp:
+ (TextSlave::paintDecoration): take a "from" and "to" so only selected portions of text draw lines
+ (RenderText::paintObject): when only drawing the selection, only draw selected text and no selection background
+ (RenderText::paint): handle the selection-only case
+ * khtml/rendering/render_text.h:
+ * kwq/KWQKHTMLPart.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::paint): handle the selection-only case
+ (KWQKHTMLPart::selectionRect): new, returns the bounding box of the selection
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (QPainter::drawLineForText): take a "from" and "to" so only selected portions of text draw lines
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge drawRect:withPainter:]): handle the selection-only case
+ (-[WebCoreBridge selectionRect]): new, returns the bounding box of the selection clipped to visible
+ (-[WebCoreBridge selectionImage]): new, returns the image of the selection
+
2003-01-24 David Hyatt <hyatt at apple.com>
Fix for 3153260, tables used as height spacers don't get the
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index ae95039..50698e1 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -4648,7 +4648,8 @@ void KHTMLPart::khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event )
#if APPLE_CHANGES
// Clear the selection if the mouse didn't move after the last mouse press.
// We do this so when clicking on the selection, the selection goes away.
- if (!d->m_mouseMovedSinceLastMousePress &&
+ if (d->m_dragStartPos.x() == event->qmouseEvent()->x() &&
+ d->m_dragStartPos.y() == event->qmouseEvent()->y() &&
!d->m_selectionInitiatedWithDoubleClick &&
!d->m_selectionInitiatedWithTripleClick) {
d->m_selectionStart = 0;
diff --git a/WebCore/khtml/rendering/font.cpp b/WebCore/khtml/rendering/font.cpp
index 0f1643a..3f4c50c 100644
--- a/WebCore/khtml/rendering/font.cpp
+++ b/WebCore/khtml/rendering/font.cpp
@@ -41,9 +41,9 @@ using namespace khtml;
#if APPLE_CHANGES
void Font::drawLineForText( QPainter *p, int x, int y, QChar *str, int slen, int pos, int len,
- int toAdd, int yOffset, QPainter::TextDirection d) const
+ int toAdd, int yOffset, QPainter::TextDirection d, int from, int to) const
{
- p->drawLineForText(x, y, str + pos, std::min(slen - pos, len), toAdd, yOffset, d, letterSpacing, wordSpacing);
+ p->drawLineForText(x, y, str + pos, std::min(slen - pos, len), from, to, toAdd, yOffset, d, letterSpacing, wordSpacing);
}
#endif
diff --git a/WebCore/khtml/rendering/font.h b/WebCore/khtml/rendering/font.h
index 06a097b..7d5eebe 100644
--- a/WebCore/khtml/rendering/font.h
+++ b/WebCore/khtml/rendering/font.h
@@ -99,7 +99,7 @@ public:
#if APPLE_CHANGES
void drawLineForText( QPainter *p, int x, int y, QChar *str, int slen, int pos, int len, int toAdd, int yOffset,
- QPainter::TextDirection d) const;
+ QPainter::TextDirection d, int from=-1, int to=-1) const;
float floatWidth( QChar *str, int slen, int pos, int len ) const;
void floatCharacterWidths( QChar *str, int slen, int pos, int len, int toAdd, float *buffer) const;
bool isFixedPitch() const;
diff --git a/WebCore/khtml/rendering/render_layer.cpp b/WebCore/khtml/rendering/render_layer.cpp
index 40d2b3b..1e9db9f 100644
--- a/WebCore/khtml/rendering/render_layer.cpp
+++ b/WebCore/khtml/rendering/render_layer.cpp
@@ -253,7 +253,7 @@ RenderLayer::convertToLayerCoords(RenderLayer* ancestorLayer, int& x, int& y)
}
void
-RenderLayer::paint(QPainter *p, int x, int y, int w, int h)
+RenderLayer::paint(QPainter *p, int x, int y, int w, int h, bool selectionOnly)
{
// Create the z-tree of layers that should be displayed.
QRect damageRect(x,y,w,h);
@@ -336,19 +336,26 @@ RenderLayer::paint(QPainter *p, int x, int y, int w, int h)
#endif
}
}
-
- elt->layer->renderer()->paint(p, x, y, w, h,
- elt->absBounds.x() - elt->layer->renderer()->xPos(),
- elt->absBounds.y() - elt->layer->renderer()->yPos(),
- PaintActionBackground);
- elt->layer->renderer()->paint(p, x, y, w, h,
- elt->absBounds.x() - elt->layer->renderer()->xPos(),
- elt->absBounds.y() - elt->layer->renderer()->yPos(),
- PaintActionFloat);
- elt->layer->renderer()->paint(p, x, y, w, h,
- elt->absBounds.x() - elt->layer->renderer()->xPos(),
- elt->absBounds.y() - elt->layer->renderer()->yPos(),
- PaintActionForeground);
+
+ if (selectionOnly) {
+ elt->layer->renderer()->paint(p, x, y, w, h,
+ elt->absBounds.x() - elt->layer->renderer()->xPos(),
+ elt->absBounds.y() - elt->layer->renderer()->yPos(),
+ PaintActionSelection);
+ } else {
+ elt->layer->renderer()->paint(p, x, y, w, h,
+ elt->absBounds.x() - elt->layer->renderer()->xPos(),
+ elt->absBounds.y() - elt->layer->renderer()->yPos(),
+ PaintActionBackground);
+ elt->layer->renderer()->paint(p, x, y, w, h,
+ elt->absBounds.x() - elt->layer->renderer()->xPos(),
+ elt->absBounds.y() - elt->layer->renderer()->yPos(),
+ PaintActionFloat);
+ elt->layer->renderer()->paint(p, x, y, w, h,
+ elt->absBounds.x() - elt->layer->renderer()->xPos(),
+ elt->absBounds.y() - elt->layer->renderer()->yPos(),
+ PaintActionForeground);
+ }
}
if (currRect != paintRect)
diff --git a/WebCore/khtml/rendering/render_layer.h b/WebCore/khtml/rendering/render_layer.h
index 083dbd7..3c9abbf 100644
--- a/WebCore/khtml/rendering/render_layer.h
+++ b/WebCore/khtml/rendering/render_layer.h
@@ -118,7 +118,7 @@ public:
// paints the layers that intersect the damage rect from back to
// front. The nodeAtPoint method looks for mouse events by walking
// layers that intersect the point from front to back.
- void paint(QPainter *p, int x, int y, int w, int h);
+ void paint(QPainter *p, int x, int y, int w, int h, bool selectionOnly=false);
bool nodeAtPoint(RenderObject::NodeInfo& info, int x, int y);
void clearOtherLayersHoverActiveState();
diff --git a/WebCore/khtml/rendering/render_root.cpp b/WebCore/khtml/rendering/render_root.cpp
index a8332f8..1467d26 100644
--- a/WebCore/khtml/rendering/render_root.cpp
+++ b/WebCore/khtml/rendering/render_root.cpp
@@ -276,7 +276,6 @@ void RenderRoot::close()
//printTree();
}
-#if APPLE_CHANGES
static QRect enclosingPositionedRect (RenderObject *n)
{
RenderObject *enclosingParent = (RenderObject*)n;
@@ -296,7 +295,34 @@ static QRect enclosingPositionedRect (RenderObject *n)
}
return rect;
}
-#endif
+
+QRect RenderRoot::selectionRect() const
+{
+ RenderObject *r = m_selectionStart;
+ QRect selectionRect = enclosingPositionedRect(r);
+
+ while (r && r != m_selectionEnd)
+ {
+ if (r->selectionState() == SelectionInside && r != m_selectionStart) {
+ selectionRect = selectionRect.unite(enclosingPositionedRect(r));
+ }
+
+ RenderObject* n;
+ if ( !(n = r->firstChild()) ){
+ if ( !(n = r->nextSibling()) )
+ {
+ n = r->parent();
+ while (n && !n->nextSibling())
+ n = n->parent();
+ if (n)
+ n = n->nextSibling();
+ }
+ }
+ r = n;
+ }
+
+ return selectionRect;
+}
void RenderRoot::setSelection(RenderObject *s, int sp, RenderObject *e, int ep)
{
diff --git a/WebCore/khtml/rendering/render_root.h b/WebCore/khtml/rendering/render_root.h
index abebb55..061fde3 100644
--- a/WebCore/khtml/rendering/render_root.h
+++ b/WebCore/khtml/rendering/render_root.h
@@ -76,6 +76,8 @@ public:
int viewportWidth() const { return m_viewportWidth; }
int viewportHeight() const { return m_viewportHeight; }
+
+ QRect selectionRect() const;
protected:
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index 036e03e..6b2bc49 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -97,7 +97,29 @@ void TextSlave::paintSelection(const Font *f, RenderText *text, QPainter *p, Ren
p->restore();
}
-void TextSlave::paintDecoration( QPainter *pt, const Font *f, RenderText* p, int _tx, int _ty, int deco, bool begin, bool end)
+#ifdef APPLE_CHANGES
+void TextSlave::paintDecoration( QPainter *pt, const Font *f, RenderText* p,
+ int _tx, int _ty, int deco, bool begin, bool end, int from, int to)
+{
+ _tx += m_x;
+ _ty += m_y;
+
+ // Use a special function for underlines to get the positioning exactly right.
+ if (deco & UNDERLINE) {
+ f->drawLineForText(pt, _tx, _ty, p->str->s, p->str->l, m_start, m_len,
+ m_toAdd, m_baseline, m_reversed ? QPainter::RTL : QPainter::LTR, from, to);
+ }
+ if (deco & OVERLINE) {
+ f->drawLineForText(pt, _tx, _ty, p->str->s, p->str->l, m_start, m_len,
+ m_toAdd, 0, m_reversed ? QPainter::RTL : QPainter::LTR, from, to);
+ }
+ if (deco & LINE_THROUGH) {
+ f->drawLineForText(pt, _tx, _ty, p->str->s, p->str->l, m_start, m_len,
+ m_toAdd, 2*m_baseline/3, m_reversed ? QPainter::RTL : QPainter::LTR, from, to);
+ }
+}
+#else
+void TextSlave::paintDecoration( QPainter *pt, RenderText* p, int _tx, int _ty, int decoration, bool begin, bool end);
{
_tx += m_x;
_ty += m_y;
@@ -110,19 +132,6 @@ void TextSlave::paintDecoration( QPainter *pt, const Font *f, RenderText* p, int
if ( end )
width -= p->paddingRight() + p->borderRight();
-#if APPLE_CHANGES
- // Use a special function for underlines to get the positioning exactly right.
- if(deco & UNDERLINE){
- f->drawLineForText(pt, _tx, _ty, p->str->s, p->str->l, m_start, m_len,
- m_toAdd, m_baseline, m_reversed ? QPainter::RTL : QPainter::LTR);
- }
- if(deco & OVERLINE)
- f->drawLineForText(pt, _tx, _ty, p->str->s, p->str->l, m_start, m_len,
- m_toAdd, 0, m_reversed ? QPainter::RTL : QPainter::LTR);
- if(deco & LINE_THROUGH)
- f->drawLineForText(pt, _tx, _ty, p->str->s, p->str->l, m_start, m_len,
- m_toAdd, 2*m_baseline/3, m_reversed ? QPainter::RTL : QPainter::LTR);
-#else
int underlineOffset = ( pt->fontMetrics().height() + m_baseline ) / 2;
if(underlineOffset <= m_baseline) underlineOffset = m_baseline+1;
@@ -133,10 +142,11 @@ void TextSlave::paintDecoration( QPainter *pt, const Font *f, RenderText* p, int
pt->drawLine(_tx, _ty, _tx + width, _ty );
if(deco & LINE_THROUGH)
pt->drawLine(_tx, _ty + 2*m_baseline/3, _tx + width, _ty + 2*m_baseline/3 );
-#endif
// NO! Do NOT add BLINK! It is the most annouing feature of Netscape, and IE has a reason not to
// support it. Lars
}
+#endif
+
void TextSlave::paintBoxDecorations(QPainter *pt, RenderStyle* style, RenderText *p, int _tx, int _ty, bool begin, bool end)
{
@@ -654,12 +664,16 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
#if APPLE_CHANGES
// Do one pass for the selection, then another for the rest.
bool haveSelection = startPos != endPos && !isPrinting && selectionState() != SelectionNone;
+ if (!haveSelection && paintAction == PaintActionSelection) {
+ // When only painting the selection, don't bother to paint if there is none.
+ return;
+ }
int startLine = si;
for (int pass = 0; pass < (haveSelection ? 2 : 1); pass++) {
si = startLine;
bool drawDecorations = !haveSelection || pass == 0;
- bool drawSelectionBackground = haveSelection && pass == 0;
+ bool drawSelectionBackground = haveSelection && pass == 0 && paintAction != PaintActionSelection;
bool drawText = !haveSelection || pass == 1;
#endif
@@ -710,14 +724,35 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
if(_style->color() != p->pen().color())
p->setPen(_style->color());
- if (s->m_len > 0)
- font->drawText(p, s->m_x + tx, s->m_y + ty + s->m_baseline, str->s, str->l, s->m_start, s->m_len,
- s->m_toAdd, s->m_reversed ? QPainter::RTL : QPainter::LTR);
+ if (s->m_len > 0) {
+ if (paintAction == PaintActionSelection) {
+ int offset = s->m_start;
+ int sPos = QMAX( startPos - offset, 0 );
+ int ePos = QMIN( endPos - offset, s->m_len );
+ if ( sPos < ePos ){
+ font->drawText(p, s->m_x + tx, s->m_y + ty + s->m_baseline, str->s, str->l, s->m_start, s->m_len,
+ s->m_toAdd, s->m_reversed ? QPainter::RTL : QPainter::LTR, sPos, ePos);
+ }
+ } else {
+ font->drawText(p, s->m_x + tx, s->m_y + ty + s->m_baseline, str->s, str->l, s->m_start, s->m_len,
+ s->m_toAdd, s->m_reversed ? QPainter::RTL : QPainter::LTR);
+ }
+ }
if(d != TDNONE)
{
p->setPen(_style->textDecorationColor());
- s->paintDecoration(p, font, this, tx, ty, d, si == 0, si == ( int ) m_lines.count()-1);
+ if (paintAction == PaintActionSelection) {
+ int offset = s->m_start;
+ int sPos = QMAX( startPos - offset, 0 );
+ int ePos = QMIN( endPos - offset, s->m_len );
+ if ( sPos < ePos ){
+ s->paintDecoration(p, font, this, tx, ty, d, si == 0, si == ( int ) m_lines.count()-1, sPos, ePos);
+ }
+ } else {
+ s->paintDecoration(p, font, this, tx, ty, d,si == 0, si == ( int ) m_lines.count()-1,
+ s->m_start, s->m_start+s->m_len);
+ }
}
#if APPLE_CHANGES
@@ -790,8 +825,12 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
void RenderText::paint(QPainter *p, int x, int y, int w, int h,
int tx, int ty, PaintAction paintAction)
{
- if (paintAction != PaintActionForeground || style()->visibility() != VISIBLE)
+ if (paintAction != PaintActionForeground && paintAction != PaintActionSelection) {
+ return;
+ }
+ if (style()->visibility() != VISIBLE) {
return;
+ }
int s = m_lines.count() - 1;
if ( s < 0 ) return;
diff --git a/WebCore/khtml/rendering/render_text.h b/WebCore/khtml/rendering/render_text.h
index d11741b..eb2753e 100644
--- a/WebCore/khtml/rendering/render_text.h
+++ b/WebCore/khtml/rendering/render_text.h
@@ -74,7 +74,8 @@ private:
public:
#ifdef APPLE_CHANGES
- void paintDecoration( QPainter *pt, const Font *, RenderText* p, int _tx, int _ty, int decoration, bool begin, bool end);
+ void paintDecoration( QPainter *pt, const Font *, RenderText* p,
+ int _tx, int _ty, int decoration, bool begin, bool end, int from, int to);
#else
void paintDecoration( QPainter *pt, RenderText* p, int _tx, int _ty, int decoration, bool begin, bool end);
#endif
diff --git a/WebCore/kwq/KWQKHTMLPart.h b/WebCore/kwq/KWQKHTMLPart.h
index c559b7d..cb25dd8 100644
--- a/WebCore/kwq/KWQKHTMLPart.h
+++ b/WebCore/kwq/KWQKHTMLPart.h
@@ -132,6 +132,7 @@ public:
khtml::RenderObject *renderer();
void forceLayout();
void paint(QPainter *, const QRect &);
+ void paintSelectionOnly(QPainter *p, const QRect &rect);
void createEmptyDocument();
@@ -148,6 +149,8 @@ public:
DOM::NodeImpl *selectionEnd() const;
int selectionEndOffset() const;
+ QRect selectionRect() const;
+
static NSAttributedString *attributedString(DOM::NodeImpl *startNode, int startOffset, DOM::NodeImpl *endNode, int endOffset);
void addMetaData(const QString &key, const QString &value);
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index c32fda7..5a2cae1 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -361,12 +361,21 @@ void KWQKHTMLPart::paint(QPainter *p, const QRect &rect)
#endif
if (renderer()) {
- renderer()->layer()->paint(p, rect.x(), rect.y(), rect.width(), rect.height());
+ renderer()->layer()->paint(p, rect.x(), rect.y(), rect.width(), rect.height(), false);
} else {
ERROR("called KWQKHTMLPart::paint with nil renderer");
}
}
+void KWQKHTMLPart::paintSelectionOnly(QPainter *p, const QRect &rect)
+{
+ if (renderer()) {
+ renderer()->layer()->paint(p, rect.x(), rect.y(), rect.width(), rect.height(), true);
+ } else {
+ ERROR("called KWQKHTMLPart::paintSelectionOnly with nil renderer");
+ }
+}
+
RenderObject *KWQKHTMLPart::renderer()
{
DocumentImpl *doc = xmlDocImpl();
@@ -1339,3 +1348,19 @@ NSAttributedString *KWQKHTMLPart::attributedString(NodeImpl *_startNode, int sta
return result;
}
+
+QRect KWQKHTMLPart::selectionRect() const
+{
+ if(!xmlDocImpl()){
+ return QRect();
+ }
+
+ khtml::RenderRoot *root = static_cast<khtml::RenderRoot *>(xmlDocImpl()->renderer());
+ if (!root) {
+ return QRect();
+
+ }
+
+ return root->selectionRect();
+}
+
diff --git a/WebCore/kwq/KWQPainter.h b/WebCore/kwq/KWQPainter.h
index de334a6..fc01629 100644
--- a/WebCore/kwq/KWQPainter.h
+++ b/WebCore/kwq/KWQPainter.h
@@ -91,8 +91,10 @@ public:
void setRasterOp(RasterOp);
void drawText(int x, int y, int, int, int alignmentFlags, const QString &);
- void drawText(int x, int y, const QChar *, int length, int from, int to, int toAdd, const QColor& backgroundColor, QPainter::TextDirection d, int letterSpacing, int wordSpacing);
- void drawLineForText(int x, int y, const QChar *, int length, int toAdd, int yOffset, QPainter::TextDirection d, int letterSpacing, int wordSpacing);
+ void drawText(int x, int y, const QChar *, int length, int from, int to, int toAdd,
+ const QColor& backgroundColor, QPainter::TextDirection d, int letterSpacing, int wordSpacing);
+ void drawLineForText(int x, int y, const QChar *, int length, int from, int to, int toAdd,
+ int yOffset, QPainter::TextDirection d, int letterSpacing, int wordSpacing);
static QColor selectedTextBackgroundColor();
bool paintingDisabled() const;
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index 36992cb..ece5bec 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -417,7 +417,7 @@ void QPainter::drawText(int x, int y, const QChar *str, int len, int from, int t
fontFamilies: families];
}
-void QPainter::drawLineForText(int x, int y, const QChar *str, int length, int toAdd, int yOffset, QPainter::TextDirection d, int letterSpacing, int wordSpacing)
+void QPainter::drawLineForText(int x, int y, const QChar *str, int length, int from, int to, int toAdd, int yOffset, QPainter::TextDirection d, int letterSpacing, int wordSpacing)
{
if (data->state.paintingDisabled)
return;
@@ -428,8 +428,8 @@ void QPainter::drawLineForText(int x, int y, const QChar *str, int length, int t
[data->lastTextRenderer
drawLineForCharacters:(const UniChar *)str stringLength:length
- fromCharacterPosition:0
- toCharacterPosition:length
+ fromCharacterPosition:from
+ toCharacterPosition:to
atPoint:NSMakePoint(x, y)
yOffset:(float)yOffset
withPadding: toAdd
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 726f000..c1b11bb 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -88,6 +88,7 @@ enum FrameBorderStyle {
KWQKHTMLPart *_part;
KHTMLRenderPart *_renderPart;
RenderArena *_renderPartArena;
+ BOOL _drawSelectionOnly;
}
- (void)setRenderPart:(KHTMLRenderPart *)renderPart;
@@ -169,6 +170,9 @@ enum FrameBorderStyle {
- (void)selectAll;
- (void)deselectAll;
+- (NSRect)selectionRect;
+- (NSImage *)selectionImage;
+
- (id <WebDOMNode>)selectionStart;
- (int)selectionStartOffset;
- (id <WebDOMNode>)selectionEnd;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 077a1ed..436417a 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -308,7 +308,11 @@ static bool initializedObjectCacheSize = FALSE;
- (void)drawRect:(NSRect)rect withPainter:(QPainter *)p
{
- _part->paint(p, QRect(rect));
+ if (_drawSelectionOnly) {
+ _part->paintSelectionOnly(p, QRect(rect));
+ } else {
+ _part->paint(p, QRect(rect));
+ }
}
- (void)drawRect:(NSRect)rect
@@ -603,6 +607,43 @@ static bool initializedObjectCacheSize = FALSE;
return _part->selectionEndOffset();
}
+- (NSRect)selectionRect
+{
+ NSView *view = _part->view()->getDocumentView();
+ if (!view) {
+ return NSZeroRect;
+ }
+
+ return NSIntersectionRect(NSRect(_part->selectionRect()), [view visibleRect]);
+}
+
+- (NSImage *)selectionImage
+{
+ NSView *view = _part->view()->getDocumentView();
+ if (!view) {
+ return nil;
+ }
+
+ NSRect rect = [self selectionRect];
+ NSImage *selectionImage = [[[NSImage alloc] initWithSize:rect.size] autorelease];
+ [selectionImage setFlipped:YES];
+ [selectionImage lockFocus];
+
+ [NSGraphicsContext saveGraphicsState];
+ CGContextTranslateCTM((CGContext *)[[NSGraphicsContext currentContext] graphicsPort], -NSMinX(rect), -NSMinY(rect));
+
+ _drawSelectionOnly = YES;
+ [view drawRect:[view bounds]];
+ _drawSelectionOnly = NO;
+
+ [NSGraphicsContext restoreGraphicsState];
+
+ [selectionImage unlockFocus];
+ [selectionImage setFlipped:NO];
+
+ return selectionImage;
+}
+
- (void)setName:(NSString *)name
{
_part->setName(QString::fromNSString(name));
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index c198e56..d6cd28d 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,18 @@
+2003-01-25 Chris Blumenberg <cblu at apple.com>
+
+ Fixed: 3153605 - Drag image when dragging text should be the actual text
+
+ Reviewed by darin.
+
+ * Misc.subproj/WebNSImageExtras.m:
+ (-[NSImage _web_dissolveToFraction:]): handle non-flipped images
+ * Misc.subproj/WebNSViewExtras.h: moved some constants around
+ * Misc.subproj/WebNSViewExtras.m:
+ * Resources/text_clipping.tiff: Removed.
+ * WebKit.pbproj/project.pbxproj:
+ * WebView.subproj/WebHTMLViewPrivate.m:
+ (-[WebHTMLView _handleMouseDragged:]): cleaned-up, get text drag image from WebCore
+
2003-01-25 Darin Adler <darin at apple.com>
* Plugins.subproj/WebBaseNetscapePluginView.m: Replace some tabs with spaces.
diff --git a/WebKit/Misc.subproj/WebNSImageExtras.m b/WebKit/Misc.subproj/WebNSImageExtras.m
index fa7f8db..120d90f 100644
--- a/WebKit/Misc.subproj/WebNSImageExtras.m
+++ b/WebKit/Misc.subproj/WebNSImageExtras.m
@@ -61,15 +61,17 @@ static BOOL AKBugIsFixed = NO;
NSImage *dissolvedImage = [[NSImage alloc] initWithSize:[self size]];
if (AKBugIsFixed) {
+ NSPoint point = [self isFlipped] ? NSMakePoint(0, [self size].height) : NSZeroPoint;
+
// In this case the dragging image is always correct.
[dissolvedImage setFlipped:[self isFlipped]];
[dissolvedImage lockFocus];
- [self dissolveToPoint:NSMakePoint(0, [self size].height) fraction: delta];
+ [self dissolveToPoint:point fraction: delta];
[dissolvedImage unlockFocus];
[self lockFocus];
- [dissolvedImage compositeToPoint:NSMakePoint(0, [self size].height) operation:NSCompositeCopy];
+ [dissolvedImage compositeToPoint:point operation:NSCompositeCopy];
[self unlockFocus];
} else {
// In this case Thousands mode will have an inverted drag image. Millions is OK.
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.h b/WebKit/Misc.subproj/WebNSViewExtras.h
index 0447e52..37f9205 100644
--- a/WebKit/Misc.subproj/WebNSViewExtras.h
+++ b/WebKit/Misc.subproj/WebNSViewExtras.h
@@ -5,8 +5,7 @@
#import <AppKit/AppKit.h>
-#define WebDragStartHysteresisX 5.0
-#define WebDragStartHysteresisY 5.0
+#define WebDragImageAlpha 0.75
@class WebView;
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.m b/WebKit/Misc.subproj/WebNSViewExtras.m
index 5989693..c60b5f4 100644
--- a/WebKit/Misc.subproj/WebNSViewExtras.m
+++ b/WebKit/Misc.subproj/WebNSViewExtras.m
@@ -11,7 +11,8 @@
#import <WebFoundation/WebNSStringExtras.h>
#import <WebFoundation/WebNSURLExtras.h>
-#define WebDragImageAlpha 0.75
+#define WebDragStartHysteresisX 5.0
+#define WebDragStartHysteresisY 5.0
#define WebMaxDragImageSize NSMakeSize(400, 400)
#ifdef DEBUG_VIEWS
diff --git a/WebKit/Resources/text_clipping.tiff b/WebKit/Resources/text_clipping.tiff
deleted file mode 100644
index 74ffaca..0000000
Binary files a/WebKit/Resources/text_clipping.tiff and /dev/null differ
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index b01e5be..0d6d1f3 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -310,7 +310,6 @@
9345D17D0365BF35008635CE,
F5883BDF025E5C6A01000102,
F5B67131023EDF8901C1A525,
- 8461DAAF03DDD6CD00CA2ACA,
);
isa = PBXResourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -436,7 +435,6 @@
35F3577E0198AAB80ACA1520,
932399D7034CF7F6008635CE,
F5883BDE025E5C6A01000102,
- 8461DAAE03DDD6CD00CA2ACA,
F5B67130023EDF8901C1A525,
F5F732D202FF4D4F01A80180,
9345D4E70365C58D008635CE,
@@ -1826,18 +1824,6 @@
//842
//843
//844
- 8461DAAE03DDD6CD00CA2ACA = {
- isa = PBXFileReference;
- name = text_clipping.tiff;
- path = Resources/text_clipping.tiff;
- refType = 4;
- };
- 8461DAAF03DDD6CD00CA2ACA = {
- fileRef = 8461DAAE03DDD6CD00CA2ACA;
- isa = PBXBuildFile;
- settings = {
- };
- };
8467275C0367158500CA2ACA = {
fileEncoding = 30;
isa = PBXFileReference;
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.m b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
index a5e9350..f5dd3b8 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.m
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
@@ -22,6 +22,7 @@
#import <WebKit/WebFramePrivate.h>
#import <WebKit/WebHTMLView.h>
#import <WebKit/WebImageRenderer.h>
+#import <WebKit/WebNSImageExtras.h>
#import <WebKit/WebNSPasteboardExtras.h>
#import <WebKit/WebNSViewExtras.h>
#import <WebKit/WebNetscapePluginEmbeddedView.h>
@@ -34,14 +35,13 @@
// These are a little larger than typical because dragging links is a fairly
// advanced feature that can confuse non-power-users
-#define DragStartXHysteresis 10.0
-#define DragStartYHysteresis 10.0
-
-#define TextDragDelay 0.2
+#define DragHysteresis 10.0
+#define TextDragHysteresis 3.0
+#define TextDragDelay 0.15
#define DRAG_LABEL_BORDER_X 4.0
#define DRAG_LABEL_BORDER_Y 2.0
-#define DRAG_LABEL_RADIUS 5
+#define DRAG_LABEL_RADIUS 5.0
#define MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP 120.0
@@ -474,65 +474,68 @@ static BOOL forceRealHitTest = NO;
return;
}
- NSPoint mouseDownPoint = [_private->mouseDownEvent locationInWindow];
- float deltaX = ABS([event locationInWindow].x - mouseDownPoint.x);
- float deltaY = ABS([event locationInWindow].y - mouseDownPoint.y);
-
NSDictionary *element = _private->dragElement;
- NSURL *linkURL = [element objectForKey: WebElementLinkURLKey];
- NSURL *imageURL = [element objectForKey: WebElementImageURLKey];
+ NSURL *linkURL = [element objectForKey:WebElementLinkURLKey];
+ NSURL *imageURL = [element objectForKey:WebElementImageURLKey];
+ BOOL isSelectedText = [[element objectForKey:WebElementIsSelectedTextKey] boolValue];
[_private->draggingImageURL release];
_private->draggingImageURL = nil;
// We must have started over something draggable:
ASSERT((imageURL && [[WebPreferences standardPreferences] willLoadImagesAutomatically]) ||
- (!imageURL && linkURL) ||
- [[element objectForKey:WebElementIsSelectedTextKey] boolValue]);
+ (!imageURL && linkURL) || isSelectedText);
- // drag hysteresis hasn't ben met yet but we don't want to do
- // other drag actions like selection.
- if (deltaX < DragStartXHysteresis && deltaY < DragStartYHysteresis) {
+ NSPoint mouseDownPoint = [self convertPoint:[_private->mouseDownEvent locationInWindow] fromView:nil];
+ NSPoint mouseDraggedPoint = [self convertPoint:[event locationInWindow] fromView:nil];
+ float deltaX = ABS(mouseDraggedPoint.x - mouseDownPoint.x);
+ float deltaY = ABS(mouseDraggedPoint.y - mouseDownPoint.y);
+
+ // Drag hysteresis hasn't been met yet but we don't want to do other drag actions like selection.
+ if (((imageURL || linkURL) && deltaX < DragHysteresis && deltaY < DragHysteresis) ||
+ (isSelectedText && deltaX < TextDragHysteresis && deltaY < TextDragHysteresis)) {
return;
}
if (imageURL) {
_private->draggingImageURL = [imageURL retain];
-
- [self _web_dragPromisedImage:[element objectForKey:WebElementImageKey]
- origin:[[element objectForKey:WebElementImageLocationKey] pointValue]
- URL:linkURL ? linkURL : imageURL
- fileType:[[imageURL path] pathExtension]
- title:[element objectForKey:WebElementImageAltStringKey]
- event:_private->mouseDownEvent];
- } else if (linkURL || [[element objectForKey:WebElementIsSelectedTextKey] boolValue]) {
+ [self _web_dragPromisedImage:[element objectForKey:WebElementImageKey]
+ origin:[[element objectForKey:WebElementImageLocationKey] pointValue]
+ URL:linkURL ? linkURL : imageURL
+ fileType:[[imageURL path] pathExtension]
+ title:[element objectForKey:WebElementImageAltStringKey]
+ event:_private->mouseDownEvent];
+
+ } else if (linkURL) {
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
- NSSize centerOffset;
- NSImage *dragImage;
+ NSString *label = [element objectForKey:WebElementLinkLabelKey];
+ [pasteboard _web_writeURL:linkURL andTitle:label withOwner:self];
+ NSImage *dragImage = [self _dragImageForElement:element];
+ NSSize offset = NSMakeSize([dragImage size].width / 2, -DRAG_LABEL_BORDER_Y);
+ [self dragImage:dragImage
+ at:NSMakePoint(mouseDraggedPoint.x - offset.width, mouseDraggedPoint.y - offset.height)
+ offset:offset
+ event:event
+ pasteboard:pasteboard
+ source:self
+ slideBack:NO];
- if (linkURL) {
- dragImage = [self _dragImageForElement:element];
- NSString *label = [element objectForKey: WebElementLinkLabelKey];
- centerOffset = NSMakeSize([dragImage size].width / 2, -DRAG_LABEL_BORDER_Y);
- [pasteboard _web_writeURL:linkURL andTitle:label withOwner:self];
- } else {
- NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"text_clipping" ofType:@"tiff"];
- dragImage = [[[NSImage alloc] initByReferencingFile:path] autorelease];
- centerOffset = NSMakeSize([dragImage size].width / 2, -([dragImage size].width/4));
- [self _writeSelectionToPasteboard:pasteboard];
- }
-
- NSPoint mousePoint = [self convertPoint:[event locationInWindow] fromView:nil];
- NSPoint imagePoint = NSMakePoint(mousePoint.x - centerOffset.width, mousePoint.y - centerOffset.height);
-
- [self dragImage:dragImage
- at:imagePoint
- offset:centerOffset
- event:event
- pasteboard:pasteboard
- source:self
- slideBack:NO];
+ } else if (isSelectedText) {
+ NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
+ [self _writeSelectionToPasteboard:pasteboard];
+ NSImage *selectionImage = [[self _bridge] selectionImage];
+ [selectionImage _web_dissolveToFraction:WebDragImageAlpha];
+ NSRect selectionRect = [[self _bridge] selectionRect];
+ [self dragImage:selectionImage
+ at:NSMakePoint(NSMinX(selectionRect), NSMaxY(selectionRect))
+ offset:NSMakeSize(mouseDownPoint.x, mouseDownPoint.y)
+ event:_private->mouseDownEvent
+ pasteboard:pasteboard
+ source:self
+ slideBack:YES];
+ } else {
+ ERROR("Attempt to drag unknown element");
}
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list