LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Apr 2006 06:50:04 +0000 (06:50 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Apr 2006 06:50:04 +0000 (06:50 +0000)
        Reviewed by Darin.

        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=8408
          Paint the highlight behind selected list markers

        * editing/selection/extend-by-word-002-expected.checksum: Updated.
        * editing/selection/extend-by-word-002-expected.png: Updated.
        * fast/lists/markers-in-selection-expected.checksum: Added.
        * fast/lists/markers-in-selection-expected.png: Added.
        * fast/lists/markers-in-selection-expected.txt: Added.
        * fast/lists/markers-in-selection.html: Added.

WebCore:

        Reviewed by Darin.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8408
          Paint the highlight behind selected list markers

        Test: fast/lists/markers-in-selection.html

        * rendering/RenderObject.h: Added selectionColorImageOverlayAlpha constant -
        the maximum opacity of the selection color when painted over images.
        * rendering/render_list.cpp:
        (WebCore::RenderListMarker::RenderListMarker):
        (WebCore::RenderListMarker::paint): Paint the selection highlight
        if selected: over the marker for image markers, under the marker for all other
        markers.
        (WebCore::RenderListMarker::setSelectionState): Added.
        (WebCore::RenderListMarker::selectionRect): Added.
        (WebCore::RenderListMarker::selectionColor): Added. Ensures that the selection
        color is transparent for image markers.
        * rendering/render_list.h:
        (WebCore::RenderListMarker::selectionState):
        (WebCore::RenderListMarker::canBeSelectionLeaf):
        * rendering/render_replaced.cpp
        (WebCore::RenderReplaced::selectionColor): Changed to use the selectionColorImageOverlayAlpha
        constant.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13893 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/selection/extend-by-word-002-expected.checksum
LayoutTests/editing/selection/extend-by-word-002-expected.png
LayoutTests/fast/lists/markers-in-selection-expected.checksum [new file with mode: 0644]
LayoutTests/fast/lists/markers-in-selection-expected.png [new file with mode: 0644]
LayoutTests/fast/lists/markers-in-selection-expected.txt [new file with mode: 0644]
LayoutTests/fast/lists/markers-in-selection.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderObject.h
WebCore/rendering/render_list.cpp
WebCore/rendering/render_list.h
WebCore/rendering/render_replaced.cpp

index 39dbada..368cfb2 100644 (file)
@@ -2,6 +2,20 @@
 
         Reviewed by Darin.
 
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=8408
+          Paint the highlight behind selected list markers
+
+        * editing/selection/extend-by-word-002-expected.checksum: Updated.
+        * editing/selection/extend-by-word-002-expected.png: Updated.
+        * fast/lists/markers-in-selection-expected.checksum: Added.
+        * fast/lists/markers-in-selection-expected.png: Added.
+        * fast/lists/markers-in-selection-expected.txt: Added.
+        * fast/lists/markers-in-selection.html: Added.
+
+2006-04-16  Mitz Pettel  <opendarwin.org@mitzpettel.com>
+
+        Reviewed by Darin.
+
         - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=8420
           iExploder(#12): Assertion failure in RenderContainer::removeChildNode
 
index 7f49dc3..160515d 100644 (file)
@@ -1 +1 @@
-dc913b4d1d4e27a2ca37b973795b36cf
\ No newline at end of file
+060766cae30f62e7cdcca788a01f76cb
\ No newline at end of file
index 95d3fbe..f5332ee 100644 (file)
Binary files a/LayoutTests/editing/selection/extend-by-word-002-expected.png and b/LayoutTests/editing/selection/extend-by-word-002-expected.png differ
diff --git a/LayoutTests/fast/lists/markers-in-selection-expected.checksum b/LayoutTests/fast/lists/markers-in-selection-expected.checksum
new file mode 100644 (file)
index 0000000..35461d9
--- /dev/null
@@ -0,0 +1,2 @@
+c6cf3c5b9c44fe2225896558e52705bf
+\ No newline at end of file
diff --git a/LayoutTests/fast/lists/markers-in-selection-expected.png b/LayoutTests/fast/lists/markers-in-selection-expected.png
new file mode 100644 (file)
index 0000000..255d8be
Binary files /dev/null and b/LayoutTests/fast/lists/markers-in-selection-expected.png differ
diff --git a/LayoutTests/fast/lists/markers-in-selection-expected.txt b/LayoutTests/fast/lists/markers-in-selection-expected.txt
new file mode 100644 (file)
index 0000000..ec9106c
--- /dev/null
@@ -0,0 +1,71 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+layer at (0,0) size 800x600
+  RenderCanvas 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 {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 53x18
+          text run at (0,0) width 53: "Test for "
+        RenderInline {I} at (0,0) size 648x18
+          RenderInline {A} at (0,0) size 348x18 [color=#0000EE]
+            RenderText {#text} at (53,0) size 348x18
+              text run at (53,0) width 348: "http://bugzilla.opendarwin.org/show_bug.cgi?id=8408"
+          RenderText {#text} at (401,0) size 300x18
+            text run at (401,0) width 4: " "
+            text run at (405,0) width 296: "Paint the highlight behind selected list markers"
+        RenderText {#text} at (701,0) size 4x18
+          text run at (701,0) width 4: "."
+      RenderBlock {P} at (0,34) size 784x18
+        RenderText {#text} at (0,0) size 366x18
+          text run at (0,0) width 366: "This tests the rendering of list markers inside the selection."
+      RenderBlock (anonymous) at (0,68) size 784x0
+        RenderInline {A} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {HR} at (0,68) size 784x2 [border: (1px inset #000000)]
+      RenderBlock {UL} at (0,86) size 784x18
+        RenderListItem {LI} at (40,0) size 744x18
+          RenderListMarker at (-17,0) size 7x18
+          RenderText {#text} at (0,0) size 157x18
+            text run at (0,0) width 157: "Item with outside marker"
+      RenderBlock {UL} at (0,120) size 784x18
+        RenderListItem {LI} at (40,0) size 744x18
+          RenderListMarker at (-1,0) size 7x18
+          RenderText {#text} at (14,0) size 149x18
+            text run at (14,0) width 149: "Item with inside marker"
+      RenderBlock {UL} at (0,154) size 784x18
+        RenderListItem {LI} at (40,0) size 744x18
+          RenderListMarker at (-17,4) size 10x10
+          RenderText {#text} at (0,0) size 199x18
+            text run at (0,0) width 199: "Item with outside image marker"
+      RenderBlock {UL} at (0,188) size 784x18
+        RenderListItem {LI} at (40,0) size 744x18
+          RenderListMarker at (0,4) size 10x10
+          RenderText {#text} at (17,0) size 191x18
+            text run at (17,0) width 191: "Item with inside image marker"
+      RenderBlock {OL} at (0,222) size 784x36
+        RenderListItem {LI} at (40,0) size 744x18
+          RenderListMarker at (-20,0) size 16x18
+          RenderText {#text} at (0,0) size 157x18
+            text run at (0,0) width 157: "Item with outside ordinal"
+        RenderListItem {LI} at (40,18) size 744x18
+          RenderListMarker at (-20,0) size 16x18
+          RenderText {#text} at (0,0) size 101x18
+            text run at (0,0) width 101: "and another one"
+      RenderBlock {OL} at (0,274) size 784x36
+        RenderListItem {LI} at (40,0) size 744x18
+          RenderListMarker at (0,0) size 16x18
+          RenderText {#text} at (16,0) size 149x18
+            text run at (16,0) width 149: "Item with inside ordinal"
+        RenderListItem {LI} at (40,18) size 744x18
+          RenderListMarker at (0,0) size 16x18
+          RenderText {#text} at (16,0) size 101x18
+            text run at (16,0) width 101: "and another one"
+      RenderBlock {HR} at (0,326) size 784x2 [border: (1px inset #000000)]
+      RenderBlock (anonymous) at (0,336) size 784x0
+        RenderInline {A} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+selection start: position 0 of child 7 {HR} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 0 of child 21 {HR} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/fast/lists/markers-in-selection.html b/LayoutTests/fast/lists/markers-in-selection.html
new file mode 100644 (file)
index 0000000..2f4ae9d
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<HTML>
+<HEAD>
+<TITLE></TITLE>
+<style>
+.inside { list-style-position: inside; }
+.img { list-style-image: url(resources/white.gif) }
+</style>
+<script>
+    function select() {
+        var s = document.getElementById("start");
+        var e = document.getElementById("end");
+        window.getSelection().setBaseAndExtent(s, 0, e, 0);
+    }
+</script>
+</HEAD>
+<BODY onload="select();">
+<p>
+    Test for <i><a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=8408">http://bugzilla.opendarwin.org/show_bug.cgi?id=8408</a>
+    Paint the highlight behind selected list markers</i>.
+</p>
+<p>
+    This tests the rendering of list markers inside the selection.
+</p>
+<a id="start"></a>
+<hr>
+<UL>
+<LI>Item with outside marker
+</UL>
+
+<UL class="inside">
+<LI>Item with inside marker
+</UL>
+
+<UL class="img">
+<LI>Item with outside image marker
+</UL>
+
+<UL class="img inside">
+<LI>Item with inside image marker
+</UL>
+
+<OL>
+<LI>Item with outside ordinal
+<LI>and another one
+</OL>
+
+<OL class="inside">
+<LI>Item with inside ordinal
+<LI>and another one
+</OL>
+<hr>
+<a id="end"></a>
+</BODY>
+</HTML>
index 685ea67..4795127 100644 (file)
@@ -2,6 +2,33 @@
 
         Reviewed by Darin.
 
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8408
+          Paint the highlight behind selected list markers
+
+        Test: fast/lists/markers-in-selection.html
+
+        * rendering/RenderObject.h: Added selectionColorImageOverlayAlpha constant -
+        the maximum opacity of the selection color when painted over images.
+        * rendering/render_list.cpp:
+        (WebCore::RenderListMarker::RenderListMarker):
+        (WebCore::RenderListMarker::paint): Paint the selection highlight
+        if selected: over the marker for image markers, under the marker for all other
+        markers.
+        (WebCore::RenderListMarker::setSelectionState): Added.
+        (WebCore::RenderListMarker::selectionRect): Added.
+        (WebCore::RenderListMarker::selectionColor): Added. Ensures that the selection
+        color is transparent for image markers.
+        * rendering/render_list.h:
+        (WebCore::RenderListMarker::selectionState):
+        (WebCore::RenderListMarker::canBeSelectionLeaf):
+        * rendering/render_replaced.cpp
+        (WebCore::RenderReplaced::selectionColor): Changed to use the selectionColorImageOverlayAlpha
+        constant.
+
+2006-04-16  Mitz Pettel  <opendarwin.org@mitzpettel.com>
+
+        Reviewed by Darin.
+
         - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8420
           iExploder(#12): Assertion failure in RenderContainer::removeChildNode
 
index 3e655c1..27cf62b 100644 (file)
@@ -71,6 +71,8 @@ class RenderTable;
 class RenderText;
 class VisiblePosition;
 
+const int selectionColorImageOverlayAlpha = 60 * 255 / 100;
+
 enum PaintPhase {
     PaintPhaseBlockBackground,
     PaintPhaseChildBlockBackground,
index 55ae142..702533d 100644 (file)
@@ -341,7 +341,7 @@ void RenderListItem::paint(PaintInfo& i, int _tx, int _ty)
 // -----------------------------------------------------------
 
 RenderListMarker::RenderListMarker(Document* document)
-    : RenderBox(document), m_listImage(0)
+    : RenderBox(document), m_listImage(0), m_selectionState(SelectionNone)
 {
     // init RenderObject attributes
     setInline(true);   // our object is Inline
@@ -415,6 +415,8 @@ void RenderListMarker::paint(PaintInfo& i, int _tx, int _ty)
 
     if (m_listImage && !m_listImage->isErrorImage()) {
         p->drawImageAtPoint(m_listImage->image(), marker.location());
+        if (selectionState() != SelectionNone)
+            p->fillRect(selectionRect(), selectionColor(p));
         return;
     }
 
@@ -423,6 +425,9 @@ void RenderListMarker::paint(PaintInfo& i, int _tx, int _ty)
     p->drawRect(box.x(), box.y(), box.width(), box.height());
 #endif
 
+    if (selectionState() != SelectionNone)
+        p->fillRect(selectionRect(), selectionColor(p));
+
     const Color color( style()->color() );
     p->setPen( color );
 
@@ -677,4 +682,39 @@ IntRect RenderListMarker::getRelativeMarkerRect()
     }
 }
 
+void RenderListMarker::setSelectionState(SelectionState state)
+{
+    m_selectionState = state;
+    RootInlineBox* root = inlineBoxWrapper()->root();
+    if (root)
+        root->setHasSelectedChildren(state != SelectionNone);
+    containingBlock()->setSelectionState(state);
+}
+
+IntRect RenderListMarker::selectionRect()
+{
+    if (selectionState() == SelectionNone)
+        return IntRect();
+
+    int absx, absy;
+    RenderBlock* cb = containingBlock();
+    cb->absolutePosition(absx, absy);
+    if (cb->hasOverflowClip())
+        cb->layer()->subtractScrollOffset(absx, absy);
+
+    RootInlineBox* root = inlineBoxWrapper()->root();
+    return IntRect(absx + xPos(), absy + root->selectionTop(), width(), root->selectionHeight());
+}
+
+Color RenderListMarker::selectionColor(GraphicsContext* p) const
+{
+    Color color = RenderBox::selectionColor(p);
+    if (!m_listImage || m_listImage->isErrorImage())
+        return color;
+    // Limit the opacity so that no user-specified selection color can obscure selected images.
+    if (color.alpha() > selectionColorImageOverlayAlpha)
+        color = Color(color.red(), color.green(), color.blue(), selectionColorImageOverlayAlpha);
+    return color;
+}
+
 }
index 6334903..21864b1 100644 (file)
@@ -73,10 +73,17 @@ public:
     
     IntRect getRelativeMarkerRect();
     
+    virtual SelectionState selectionState() const { return m_selectionState; }
+    virtual void setSelectionState(SelectionState);
+    virtual IntRect selectionRect();
+    virtual Color selectionColor(GraphicsContext*) const;
+    virtual bool canBeSelectionLeaf() const { return true; }
+
 private:
     DeprecatedString m_item;
     CachedImage *m_listImage;
     RenderListItem* m_listItem;
+    SelectionState m_selectionState;
 };
 
 class ListMarkerBox : public InlineBox
index 1307971..f916b06 100644 (file)
@@ -228,9 +228,9 @@ Color RenderReplaced::selectionColor(GraphicsContext* p) const
 {
     Color color = RenderBox::selectionColor(p);
          
-    // Force a 60% alpha so that no user-specified selection color can obscure selected images.
-    if (color.alpha() > 153)
-        color = Color(color.red(), color.green(), color.blue(), 153);
+    // Limit the opacity so that no user-specified selection color can obscure selected images.
+    if (color.alpha() > selectionColorImageOverlayAlpha)
+        color = Color(color.red(), color.green(), color.blue(), selectionColorImageOverlayAlpha);
 
     return color;
 }