Reviewed by Kevin, Timo O, Brady, Darin, and Hyatt (whee!)
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jul 2006 23:59:34 +0000 (23:59 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jul 2006 23:59:34 +0000 (23:59 +0000)
        - added support for creating a selection image with white text

        * rendering/RenderObject.h:
        (WebCore::):
        add PaintRestriction enum
        (WebCore::RenderObject::PaintInfo::PaintInfo):
        add forceWhiteText boolean to PaintInfo struct

        * page/FramePrivate.h:
        (WebCore::FramePrivate::FramePrivate):
        replaced m_selectionOnly bool with m_paintRestriction, which also handles forcing the
        text to white

        * page/Frame.cpp:
        (WebCore::Frame::paint):
        updated to use & pass m_paintRestriction where it used to use & pass just m_selectionOnly

        * bridge/mac/FrameMac.h:
        * bridge/mac/FrameMac.mm:
        (WebCore::FrameMac::selectionImage):
        now takes forceWhiteText parameter, stored in FramePrivate as part of PaintRestriction

        * bridge/mac/WebCoreFrameBridge.h:
        * bridge/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge selectionImageForcingWhiteText:]):
        renamed from selectionImage, now takes forceWhiteText parameter, which is passed
        down into Frame

        * rendering/RenderLayer.h:
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::paint):
        use a PaintRestriction value where we used to use a selectionOnly bool
        (WebCore::RenderLayer::paintLayer):
        ditto; also stores forceWhiteText in PaintInfo struct

        * kcanvas/KCanvasResources.cpp:
        (WebCore::KCanvasMarker::draw):
        updated for changed signature of PaintInfo constructor

        * ksvg2/svg/SVGMaskElement.cpp:
        (WebCore::SVGMaskElement::drawMaskerContent):
        ditto

        * ksvg2/svg/SVGPatternElement.cpp:
        (WebCore::SVGPatternElement::drawPatternContentIntoTile):
        ditto

        * rendering/InlineTextBox.cpp:
        (WebCore::InlineTextBox::paint):
        paint with white text color if forceWhiteText is set in PaintInfo struct

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

15 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/mac/FrameMac.h
WebCore/bridge/mac/FrameMac.mm
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/kcanvas/KCanvasResources.cpp
WebCore/ksvg2/svg/SVGMaskElement.cpp
WebCore/ksvg2/svg/SVGPatternElement.cpp
WebCore/page/Frame.cpp
WebCore/page/FramePrivate.h
WebCore/rendering/InlineTextBox.cpp
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderLayer.h
WebCore/rendering/RenderObject.h

index 3643ce8..18af12e 100644 (file)
@@ -1,3 +1,58 @@
+2006-07-11  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Kevin, Timo O, Brady, Darin, and Hyatt (whee!)
+
+        - added support for creating a selection image with white text
+
+        * rendering/RenderObject.h:
+        (WebCore::):
+        add PaintRestriction enum
+        (WebCore::RenderObject::PaintInfo::PaintInfo):
+        add forceWhiteText boolean to PaintInfo struct
+
+        * page/FramePrivate.h:
+        (WebCore::FramePrivate::FramePrivate):
+        replaced m_selectionOnly bool with m_paintRestriction, which also handles forcing the
+        text to white
+
+        * page/Frame.cpp:
+        (WebCore::Frame::paint):
+        updated to use & pass m_paintRestriction where it used to use & pass just m_selectionOnly
+
+        * bridge/mac/FrameMac.h:
+        * bridge/mac/FrameMac.mm:
+        (WebCore::FrameMac::selectionImage):
+        now takes forceWhiteText parameter, stored in FramePrivate as part of PaintRestriction
+
+        * bridge/mac/WebCoreFrameBridge.h:
+        * bridge/mac/WebCoreFrameBridge.mm:
+        (-[WebCoreFrameBridge selectionImageForcingWhiteText:]):
+        renamed from selectionImage, now takes forceWhiteText parameter, which is passed
+        down into Frame
+
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::paint):
+        use a PaintRestriction value where we used to use a selectionOnly bool
+        (WebCore::RenderLayer::paintLayer):
+        ditto; also stores forceWhiteText in PaintInfo struct
+
+        * kcanvas/KCanvasResources.cpp:
+        (WebCore::KCanvasMarker::draw):
+        updated for changed signature of PaintInfo constructor
+
+        * ksvg2/svg/SVGMaskElement.cpp:
+        (WebCore::SVGMaskElement::drawMaskerContent):
+        ditto
+
+        * ksvg2/svg/SVGPatternElement.cpp:
+        (WebCore::SVGPatternElement::drawPatternContentIntoTile):
+        ditto
+
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::paint):
+        paint with white text color if forceWhiteText is set in PaintInfo struct
+
 2006-07-11  Tim Omernick  <timo@apple.com>
 
         Reviewed by Anders.
index 58e24bc..2e82e1a 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
-/* Begin PBXBuildStyle section */
-               D0DBCB790A6303EC007FA386 /* Development */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = NO;
-                       };
-                       name = Development;
-               };
-               D0DBCB7A0A6303EC007FA386 /* Deployment */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = YES;
-                       };
-                       name = Deployment;
-               };
-/* End PBXBuildStyle section */
-
 /* Begin PBXContainerItemProxy section */
                DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
-                       buildSettings = {
-                       };
-                       buildStyles = (
-                               D0DBCB790A6303EC007FA386 /* Development */,
-                               D0DBCB7A0A6303EC007FA386 /* Deployment */,
-                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index f8ccb03..bacfc36 100644 (file)
@@ -184,7 +184,7 @@ public:
 
     virtual String mimeTypeForFileName(const String&) const;
 
-    NSImage* selectionImage() const;
+    NSImage* selectionImage(bool forceWhiteText = false) const;
     NSImage* snapshotDragImage(Node* node, NSRect* imageRect, NSRect* elementRect) const;
 
     bool dispatchDragSrcEvent(const AtomicString &eventType, const PlatformMouseEvent&) const;
index 1aba1b9..4bc55b9 100644 (file)
@@ -2676,11 +2676,11 @@ NSImage *FrameMac::imageFromRect(NSRect rect) const
     return nil;
 }
 
-NSImage *FrameMac::selectionImage() const
+NSImage* FrameMac::selectionImage(bool forceWhiteText) const
 {
-    d->m_drawSelectionOnly = true;  // invoke special drawing mode
+    d->m_paintRestriction = forceWhiteText ? PaintRestrictionSelectionOnlyWhiteText : PaintRestrictionSelectionOnly;
     NSImage *result = imageFromRect(visibleSelectionRect());
-    d->m_drawSelectionOnly = false;
+    d->m_paintRestriction = PaintRestrictionNone;
     return result;
 }
 
index ec013af..65e7dd8 100644 (file)
@@ -356,7 +356,7 @@ typedef enum {
 - (NSRect)selectionRect;
 - (NSRect)visibleSelectionRect;
 - (void)centerSelectionInVisibleArea;
-- (NSImage *)selectionImage;
+- (NSImage *)selectionImageForcingWhiteText:(BOOL)forceWhiteText;
 - (NSRect)caretRectAtNode:(DOMNode *)node offset:(int)offset affinity:(NSSelectionAffinity)affinity;
 - (NSRect)firstRectForDOMRange:(DOMRange *)range;
 
index e8e936d..db9289b 100644 (file)
@@ -1400,9 +1400,9 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
                  startCaretRect.height());
 }
 
-- (NSImage *)selectionImage
+- (NSImage *)selectionImageForcingWhiteText:(BOOL)forceWhiteText;
 {
-    return m_frame->selectionImage();
+    return m_frame->selectionImage(forceWhiteText);
 }
 
 - (void)setName:(NSString *)name
index abd9726..072f3d2 100644 (file)
@@ -239,7 +239,7 @@ void KCanvasMarker::draw(GraphicsContext* context, const FloatRect& rect, double
 
         // FIXME: PaintInfo should be passed into this method instead.
         // FIXME: bounding box fractions lost
-        RenderObject::PaintInfo info(context, enclosingIntRect(rect), PaintPhaseForeground, 0, 0);
+        RenderObject::PaintInfo info(context, enclosingIntRect(rect), PaintPhaseForeground, 0, 0, 0);
         m_marker->setLocalTransform(rotation.multiply(translation).matrix());
         static_cast<RenderSVGContainer *>(m_marker)->setDrawsContents(true);
         m_marker->paint(info, 0, 0);
index f4d6933..b3a2989 100644 (file)
@@ -126,7 +126,7 @@ KCanvasImage *SVGMaskElement::drawMaskerContent()
     OwnPtr<GraphicsContext> context(patternContext->createGraphicsContext());
 
     RenderSVGContainer *maskContainer = static_cast<RenderSVGContainer *>(renderer());
-    RenderObject::PaintInfo info(context.get(), IntRect(), PaintPhaseForeground, 0, 0);
+    RenderObject::PaintInfo info(context.get(), IntRect(), PaintPhaseForeground, 0, 0, 0);
     maskContainer->setDrawsContents(true);
     maskContainer->paint(info, 0, 0);
     maskContainer->setDrawsContents(false);
index 64ca4c5..2cd01a3 100644 (file)
@@ -268,7 +268,7 @@ void SVGPatternElement::drawPatternContentIntoTile(const SVGPatternElement* targ
         }
 #endif
 
-        RenderObject::PaintInfo info(context.get(), IntRect(), PaintPhaseForeground, 0, 0);
+        RenderObject::PaintInfo info(context.get(), IntRect(), PaintPhaseForeground, 0, 0, 0);
         item->paint(info, 0, 0);
 
 #if 0
index 48feba3..c68f7be 100644 (file)
@@ -2851,7 +2851,7 @@ void Frame::paint(GraphicsContext* p, const IntRect& rect)
         fillWithRed = false; // Subframe, don't fill with red.
     else if (view() && view()->isTransparent())
         fillWithRed = false; // Transparent, don't fill with red.
-    else if (d->m_drawSelectionOnly)
+    else if (d->m_paintRestriction == PaintRestrictionSelectionOnly || d->m_paintRestriction == PaintRestrictionSelectionOnlyWhiteText)
         fillWithRed = false; // Selections are transparent, don't fill with red.
     else if (d->m_elementToDraw)
         fillWithRed = false; // Element images are transparent, don't fill with red.
@@ -2865,9 +2865,9 @@ void Frame::paint(GraphicsContext* p, const IntRect& rect)
     if (renderer()) {
         // d->m_elementToDraw is used to draw only one element
         RenderObject *eltRenderer = d->m_elementToDraw ? d->m_elementToDraw->renderer() : 0;
-        if (!d->m_drawSelectionOnly)
+        if (d->m_paintRestriction == PaintRestrictionNone)
             renderer()->document()->invalidateRenderedRectsForMarkersInRect(rect);
-        renderer()->layer()->paint(p, rect, d->m_drawSelectionOnly, eltRenderer);
+        renderer()->layer()->paint(p, rect, d->m_paintRestriction, eltRenderer);
 
 #if __APPLE__
         // Regions may have changed as a result of the visibility/z-index of element changing.
index 2b1381c..8f1f47a 100644 (file)
@@ -52,7 +52,7 @@ namespace WebCore {
         historyNavigationScheduled,
         locationChangeScheduledDuringLoad
     };
-
+    
     class FramePrivate {
     public:
         FramePrivate(Page* page, Frame* parent, Frame* thisFrame, Element* ownerElement)
@@ -97,7 +97,7 @@ namespace WebCore {
             , m_userStyleSheetLoader(0)
             , m_autoscrollTimer(thisFrame, &Frame::autoscrollTimerFired)
             , m_autoscrollLayer(0)
-            , m_drawSelectionOnly(false)
+            , m_paintRestriction(PaintRestrictionNone)
             , m_markedTextUsesUnderlines(false)
             , m_highlightTextMatches(false)
             , m_windowHasFocus(false)
@@ -215,7 +215,7 @@ namespace WebCore {
         RenderLayer* m_autoscrollLayer;
         
         RefPtr<Node> m_elementToDraw;
-        bool m_drawSelectionOnly;
+        PaintRestriction m_paintRestriction;
         
         HashMap<String, String> m_formValuesAboutToBeSubmitted;
         RefPtr<Element> m_formAboutToBeSubmitted;
index f1411d4..11053f5 100644 (file)
@@ -292,11 +292,17 @@ void InlineTextBox::paint(RenderObject::PaintInfo& i, int tx, int ty)
     }
     DeprecatedValueListIterator<MarkedTextUnderline> underlineIt = underlines.begin();
 
-    Color textColor = styleToUse->color();
+    Color textColor;
     
-    // Make the text color legible against a white background
-    if (styleToUse->forceBackgroundsToWhite())
-        textColor = correctedTextColor(textColor, Color::white);
+    if (i.forceWhiteText)
+        textColor = Color::white;
+    else {
+        textColor = styleToUse->color();
+        
+        // Make the text color legible against a white background
+        if (styleToUse->forceBackgroundsToWhite())
+            textColor = correctedTextColor(textColor, Color::white);
+    }
 
     if (textColor != i.p->pen().color())
         i.p->setPen(textColor);
index 57da259..e87083b 100644 (file)
@@ -1193,9 +1193,9 @@ bool RenderLayer::scroll(ScrollDirection direction, ScrollGranularity granularit
 }
 
 void
-RenderLayer::paint(GraphicsContext* p, const IntRect& damageRect, bool selectionOnly, RenderObject *paintingRoot)
+RenderLayer::paint(GraphicsContext* p, const IntRect& damageRect, PaintRestriction paintRestriction, RenderObject *paintingRoot)
 {
-    paintLayer(this, p, damageRect, false, selectionOnly, paintingRoot);
+    paintLayer(this, p, damageRect, false, paintRestriction, paintingRoot);
 }
 
 static void setClip(GraphicsContext* p, const IntRect& paintDirtyRect, const IntRect& clipRect)
@@ -1219,7 +1219,7 @@ static void restoreClip(GraphicsContext* p, const IntRect& paintDirtyRect, const
 
 void
 RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p,
-                        const IntRect& paintDirtyRect, bool haveTransparency, bool selectionOnly,
+                        const IntRect& paintDirtyRect, bool haveTransparency, PaintRestriction paintRestriction,
                         RenderObject *paintingRoot)
 {
     // Calculate the clip rects we should use.
@@ -1237,6 +1237,9 @@ RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p,
     // If this layer is totally invisible, then return as there is nothing to paint
     if (!m_object->opacity())
         return;
+        
+    bool selectionOnly = paintRestriction == PaintRestrictionSelectionOnly || paintRestriction == PaintRestrictionSelectionOnlyWhiteText;
+    bool forceWhiteText = paintRestriction == PaintRestrictionSelectionOnlyWhiteText;
 
     if (isTransparent())
         haveTransparency = true;
@@ -1261,7 +1264,7 @@ RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p,
         setClip(p, paintDirtyRect, damageRect);
 
         // Paint the background.
-        RenderObject::PaintInfo info(p, damageRect, PaintPhaseBlockBackground, paintingRootForRenderer, 0);
+        RenderObject::PaintInfo info(p, damageRect, PaintPhaseBlockBackground, false, paintingRootForRenderer, 0);
         renderer()->paint(info, tx, ty);
 
         // Our scrollbar widgets paint exactly when we tell them to, so that they work properly with
@@ -1276,7 +1279,7 @@ RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p,
     // Now walk the sorted list of children with negative z-indices.
     if (m_negZOrderList)
         for (Vector<RenderLayer*>::iterator it = m_negZOrderList->begin(); it != m_negZOrderList->end(); ++it)
-            it[0]->paintLayer(rootLayer, p, paintDirtyRect, haveTransparency, selectionOnly, paintingRoot);
+            it[0]->paintLayer(rootLayer, p, paintDirtyRect, haveTransparency, paintRestriction, paintingRoot);
     
     // Now establish the appropriate clip and paint our child RenderObjects.
     if (shouldPaint && !clipRectToApply.isEmpty()) {
@@ -1288,6 +1291,7 @@ RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p,
         setClip(p, paintDirtyRect, clipRectToApply);
         RenderObject::PaintInfo info(p, clipRectToApply, 
                                      selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds,
+                                     forceWhiteText,
                                      paintingRootForRenderer, 0);
         renderer()->paint(info, tx, ty);
         if (!selectionOnly) {
@@ -1305,7 +1309,7 @@ RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p,
     
     if (!outlineRect.isEmpty()) {
         // Paint our own outline
-        RenderObject::PaintInfo info(p, outlineRect, PaintPhaseSelfOutline, paintingRootForRenderer, 0);
+        RenderObject::PaintInfo info(p, outlineRect, PaintPhaseSelfOutline, false, paintingRootForRenderer, 0);
         setClip(p, paintDirtyRect, outlineRect);
         renderer()->paint(info, tx, ty);
         restoreClip(p, paintDirtyRect, outlineRect);
@@ -1314,12 +1318,12 @@ RenderLayer::paintLayer(RenderLayer* rootLayer, GraphicsContext* p,
     // Paint any child layers that have overflow.
     if (m_overflowList)
         for (Vector<RenderLayer*>::iterator it = m_overflowList->begin(); it != m_overflowList->end(); ++it)
-            it[0]->paintLayer(rootLayer, p, paintDirtyRect, haveTransparency, selectionOnly, paintingRoot);
+            it[0]->paintLayer(rootLayer, p, paintDirtyRect, haveTransparency, paintRestriction, paintingRoot);
     
     // Now walk the sorted list of children with positive z-indices.
     if (m_posZOrderList)
         for (Vector<RenderLayer*>::iterator it = m_posZOrderList->begin(); it != m_posZOrderList->end(); ++it)
-            it[0]->paintLayer(rootLayer, p, paintDirtyRect, haveTransparency, selectionOnly, paintingRoot);
+            it[0]->paintLayer(rootLayer, p, paintDirtyRect, haveTransparency, paintRestriction, paintingRoot);
     
     // End our transparency layer
     if (isTransparent() && m_usedTransparency) {
index dd4faeb..634d93a 100644 (file)
@@ -291,7 +291,7 @@ public:
     // paints the layers that intersect the damage rect from back to
     // front.  The hitTest method looks for mouse events by walking
     // layers that intersect the point from front to back.
-    void paint(GraphicsContext*, const IntRect& damageRect, bool selectionOnly = false, RenderObject* paintingRoot = 0);
+    void paint(GraphicsContext*, const IntRect& damageRect, PaintRestriction = PaintRestrictionNone, RenderObject* paintingRoot = 0);
     bool hitTest(RenderObject::NodeInfo&, const IntPoint&);
 
     // This method figures out our layerBounds in coordinates relative to
@@ -334,7 +334,7 @@ private:
     void collectLayers(Vector<RenderLayer*>*&, Vector<RenderLayer*>*&);
 
     void paintLayer(RenderLayer* rootLayer, GraphicsContext*, const IntRect& paintDirtyRect,
-        bool haveTransparency, bool selectionOnly, RenderObject* paintingRoot);
+        bool haveTransparency, PaintRestriction, RenderObject* paintingRoot);
     RenderLayer* hitTestLayer(RenderLayer* rootLayer, RenderObject::NodeInfo&, const IntPoint&, const IntRect& hitTestRect);
     void computeScrollDimensions(bool* needHBar = 0, bool* needVBar = 0);
 
index 4f1efc2..dfd3cd0 100644 (file)
@@ -79,6 +79,12 @@ enum PaintPhase {
     PaintPhaseCollapsedTableBorders
 };
 
+enum PaintRestriction {
+    PaintRestrictionNone,
+    PaintRestrictionSelectionOnly,
+    PaintRestrictionSelectionOnlyWhiteText
+};
+
 enum HitTestFilter {
     HitTestAll,
     HitTestSelf,
@@ -397,11 +403,12 @@ public:
      * (tx|ty) is the calculated position of the parent
      */
     struct PaintInfo {
-        PaintInfo(GraphicsContext* _p, const IntRect& _r, PaintPhase _phase, RenderObject* _paintingRoot, RenderFlowSequencedSet* _outlineObjects)
-            : p(_p), r(_r), phase(_phase), paintingRoot(_paintingRoot), outlineObjects(_outlineObjects) {}
+        PaintInfo(GraphicsContext* _p, const IntRect& _r, PaintPhase _phase, bool _forceWhiteText, RenderObject* _paintingRoot, RenderFlowSequencedSet* _outlineObjects)
+            : p(_p), r(_r), phase(_phase), forceWhiteText(_forceWhiteText), paintingRoot(_paintingRoot), outlineObjects(_outlineObjects) {}
         GraphicsContext* p;
         IntRect r;
         PaintPhase phase;
+        bool forceWhiteText;
         RenderObject* paintingRoot; // used to draw just one element and its visual kids
         RenderFlowSequencedSet* outlineObjects; // used to list outlines that should be painted by a block with inline children
     };