[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    [PATCH] constify some methods
From:       Bernhard <shentey () web ! de>
Date:       2008-08-28 13:40:26
Message-ID: 200808281540.27105.shentey () web ! de
[Download RAW message or body]

Hi khtml developers,

while playing with the khtml sources I've fixed some caretPos() methods in the \
rendering directory to be const. At least for me, it helped me understand more \
quickly that none of these methods will have side effects on their objects, as the \
const keyword provided evidence. So I figured I'd share the patch with you. Feel free \
to apply it in the khtml/rendering directory.

Greetings,
Bernhard


["const_patch.diff" (text/x-diff)]

Index: render_br.cpp
===================================================================
--- render_br.cpp	(Revision 853333)
+++ render_br.cpp	(Arbeitskopie)
@@ -57,7 +57,7 @@
 }
 
 #if 0
-void RenderBR::caretPos(int offset, int flags, int &_x, int &_y, int &width, int \
&height) +void RenderBR::caretPos(int offset, int flags, int &_x, int &_y, int \
&width, int &height) const  {
   RenderText::caretPos(offset,flags,_x,_y,width,height);
   return;
Index: render_object.h
===================================================================
--- render_object.h	(Revision 853333)
+++ render_object.h	(Arbeitskopie)
@@ -761,7 +761,7 @@
      * @param width returns the caret's width
      * @param height returns the caret's height
      */
-    virtual void caretPos(int offset, int flags, int &_x, int &_y, int &width, int \
&height); +    virtual void caretPos(int offset, int flags, int &_x, int &_y, int \
&width, int &height) const;  
     // returns the lowest position of the lowest object in that particular object.
     // This 'height' is relative to the topleft of the margin box of the object.
Index: render_inline.cpp
===================================================================
--- render_inline.cpp	(Revision 853333)
+++ render_inline.cpp	(Arbeitskopie)
@@ -872,7 +872,7 @@
     return RenderFlow::positionForCoordinates(x, y);
 }
 
-void RenderInline::caretPos(int offset, int flags, int &_x, int &_y, int &width, int \
&height) +void RenderInline::caretPos(int offset, int flags, int &_x, int &_y, int \
&width, int &height) const  {
     _x = -1;
 
Index: render_image.cpp
===================================================================
--- render_image.cpp	(Revision 853333)
+++ render_image.cpp	(Arbeitskopie)
@@ -509,7 +509,7 @@
 }
 
 #if 0
-void RenderImage::caretPos(int offset, int flags, int &_x, int &_y, int &width, int \
&height) +void RenderImage::caretPos(int offset, int flags, int &_x, int &_y, int \
&width, int &height) const  {
     RenderReplaced::caretPos(offset, flags, _x, _y, width, height);
 
Index: render_text.h
===================================================================
--- render_text.h	(Revision 853333)
+++ render_text.h	(Arbeitskopie)
@@ -235,7 +235,7 @@
 
     virtual SelectionState selectionState() const {return \
                KDE_CAST_BF_ENUM(SelectionState, m_selectionState);}
     virtual void setSelectionState(SelectionState s) {m_selectionState = s; }
-    virtual void caretPos(int offset, int flags, int &_x, int &_y, int &width, int \
&height); +    virtual void caretPos(int offset, int flags, int &_x, int &_y, int \
                &width, int &height) const;
     virtual bool absolutePosition(int &/*xPos*/, int &/*yPos*/, bool f = false) \
const;  bool posOfChar(int ch, int &x, int &y);
     virtual bool isPointInsideSelection(int x, int y, const DOM::Selection &) const;
@@ -278,7 +278,7 @@
      * @return the text box, or 0 if no match has been found
      */
     InlineTextBox * findInlineTextBox( int offset, int &pos,
-    					bool checkFirstLetter = false );
+    					bool checkFirstLetter = false ) const;
 	
 protected: // members
     InlineTextBox* m_firstTextBox;
Index: render_box.h
===================================================================
--- render_box.h	(Revision 853333)
+++ render_box.h	(Arbeitskopie)
@@ -117,7 +117,7 @@
     int staticX() const { return m_staticX; }
     int staticY() const { return m_staticY; }
 
-    virtual void caretPos(int offset, int flags, int &_x, int &_y, int &width, int \
&height); +    virtual void caretPos(int offset, int flags, int &_x, int &_y, int \
&width, int &height) const;  
     void calcHorizontalMargins(const Length& ml, const Length& mr, int cw);
     RenderBlock* createAnonymousBlock();
Index: render_object.cpp
===================================================================
--- render_object.cpp	(Revision 853333)
+++ render_object.cpp	(Arbeitskopie)
@@ -1781,7 +1781,7 @@
     }
 }
 
-void RenderObject::caretPos(int /*offset*/, int /*flags*/, int &_x, int &_y, int \
&width, int &height) +void RenderObject::caretPos(int /*offset*/, int /*flags*/, int \
&_x, int &_y, int &width, int &height) const  {
     _x = _y = height = -1;
     width = 1;        // the caret has a default width of one pixel. If you want
Index: render_br.h
===================================================================
--- render_br.h	(Revision 853333)
+++ render_br.h	(Arbeitskopie)
@@ -67,7 +67,7 @@
     
     virtual DOM::Position positionForCoordinates(int _x, int _y);
 #if 0
-    virtual void caretPos(int offset, int flags, int &_x, int &_y, int &width, int \
&height); +    virtual void caretPos(int offset, int flags, int &_x, int &_y, int \
&width, int &height) const;  #endif
 
     virtual InlineBox *inlineBox(long offset);
Index: render_inline.h
===================================================================
--- render_inline.h	(Revision 853333)
+++ render_inline.h	(Arbeitskopie)
@@ -82,7 +82,7 @@
 
     virtual DOM::Position positionForCoordinates(int x, int y);
 
-    virtual void caretPos(int offset, int flags, int &_x, int &_y, int &width, int \
&height); +    virtual void caretPos(int offset, int flags, int &_x, int &_y, int \
&width, int &height) const;  void paintOutlines(QPainter *p, int tx, int ty);    
 
 protected:
Index: render_text.cpp
===================================================================
--- render_text.cpp	(Revision 853333)
+++ render_text.cpp	(Arbeitskopie)
@@ -803,7 +803,7 @@
     return element() ? element()->string() : 0;
 }
 
-InlineTextBox * RenderText::findInlineTextBox( int offset, int &pos, bool \
checkFirstLetter ) +InlineTextBox * RenderText::findInlineTextBox( int offset, int \
&pos, bool checkFirstLetter ) const  {
   Q_UNUSED( checkFirstLetter );
     // The text boxes point to parts of the rendertext's str string
@@ -977,7 +977,7 @@
     return Position(element(), 0);
 }
 
-void RenderText::caretPos(int offset, int flags, int &_x, int &_y, int &width, int \
&height) +void RenderText::caretPos(int offset, int flags, int &_x, int &_y, int \
&width, int &height) const  {
   if (!m_firstTextBox) {
     _x = _y = height = -1;
Index: render_image.h
===================================================================
--- render_image.h	(Revision 853333)
+++ render_image.h	(Arbeitskopie)
@@ -80,7 +80,7 @@
     virtual SelectionState selectionState() const {return \
                KDE_CAST_BF_ENUM(SelectionState, m_selectionState);}
     virtual void setSelectionState(SelectionState s) {m_selectionState = s; }
 #if 0
-    virtual void caretPos(int offset, int flags, int &_x, int &_y, int &width, int \
&height); +    virtual void caretPos(int offset, int flags, int &_x, int &_y, int \
&width, int &height) const;  #endif
 
 private:
Index: render_box.cpp
===================================================================
--- render_box.cpp	(Revision 853333)
+++ render_box.cpp	(Arbeitskopie)
@@ -2432,7 +2432,7 @@
     return RenderContainer::handleEvent(e);
 }
 
-void RenderBox::caretPos(int /*offset*/, int flags, int &_x, int &_y, int &width, \
int &height) +void RenderBox::caretPos(int /*offset*/, int flags, int &_x, int &_y, \
int &width, int &height) const  {
 #if 0
     _x = -1;



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic