Title: [126406] trunk/Source/WebKit2
Revision
126406
Author
[email protected]
Date
2012-08-23 01:47:11 -0700 (Thu, 23 Aug 2012)

Log Message

[WK2] Refactoring: WebBackForwardList getters should be const
https://bugs.webkit.org/show_bug.cgi?id=94711

Patch by Mikhail Pozdnyakov <[email protected]> on 2012-08-23
Reviewed by Kenneth Rohde Christiansen.

Before the change were not consistent with each other
(WebBackForwardList::entries() was const but WebBackForwardList::currentIndex() was not).
Besides having not const getters is not a good practice in C++. (Please read
Scott Meyers. Effective C++ (3rd edition). ISBN: 0-321-33487-6.
Item 3: 'Use const whenever possible').

* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::backListCount):
(WebKit::WebBackForwardList::forwardListCount):
(WebKit::WebBackForwardList::backListAsImmutableArrayWithLimit):
(WebKit::WebBackForwardList::forwardListAsImmutableArrayWithLimit):
* UIProcess/WebBackForwardList.h:
(WebKit::WebBackForwardList::currentIndex):
(WebBackForwardList):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (126405 => 126406)


--- trunk/Source/WebKit2/ChangeLog	2012-08-23 08:32:23 UTC (rev 126405)
+++ trunk/Source/WebKit2/ChangeLog	2012-08-23 08:47:11 UTC (rev 126406)
@@ -1,3 +1,25 @@
+2012-08-23  Mikhail Pozdnyakov  <[email protected]>
+
+        [WK2] Refactoring: WebBackForwardList getters should be const
+        https://bugs.webkit.org/show_bug.cgi?id=94711
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Before the change were not consistent with each other
+        (WebBackForwardList::entries() was const but WebBackForwardList::currentIndex() was not).
+        Besides having not const getters is not a good practice in C++. (Please read
+        Scott Meyers. Effective C++ (3rd edition). ISBN: 0-321-33487-6.
+        Item 3: 'Use const whenever possible').
+
+        * UIProcess/WebBackForwardList.cpp:
+        (WebKit::WebBackForwardList::backListCount):
+        (WebKit::WebBackForwardList::forwardListCount):
+        (WebKit::WebBackForwardList::backListAsImmutableArrayWithLimit):
+        (WebKit::WebBackForwardList::forwardListAsImmutableArrayWithLimit):
+        * UIProcess/WebBackForwardList.h:
+        (WebKit::WebBackForwardList::currentIndex):
+        (WebBackForwardList):
+
 2012-08-22  Nikhil Bhargava  <[email protected]>
 
         Reduce Font.h includes across project -- improves RenderObject.h compile time

Modified: trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp (126405 => 126406)


--- trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp	2012-08-23 08:32:23 UTC (rev 126405)
+++ trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp	2012-08-23 08:47:11 UTC (rev 126406)
@@ -186,21 +186,21 @@
     return m_entries[index + m_currentIndex].get();
 }
 
-int WebBackForwardList::backListCount()
+int WebBackForwardList::backListCount() const
 {
     ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size());
 
     return m_page && m_hasCurrentIndex ? m_currentIndex : 0;
 }
 
-int WebBackForwardList::forwardListCount()
+int WebBackForwardList::forwardListCount() const
 {
     ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size());
 
     return m_page && m_hasCurrentIndex ? m_entries.size() - (m_currentIndex + 1) : 0;
 }
 
-PassRefPtr<ImmutableArray> WebBackForwardList::backListAsImmutableArrayWithLimit(unsigned limit)
+PassRefPtr<ImmutableArray> WebBackForwardList::backListAsImmutableArrayWithLimit(unsigned limit) const
 {
     ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size());
 
@@ -224,7 +224,7 @@
     return ImmutableArray::adopt(vector);
 }
 
-PassRefPtr<ImmutableArray> WebBackForwardList::forwardListAsImmutableArrayWithLimit(unsigned limit)
+PassRefPtr<ImmutableArray> WebBackForwardList::forwardListAsImmutableArrayWithLimit(unsigned limit) const
 {
     ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size());
 

Modified: trunk/Source/WebKit2/UIProcess/WebBackForwardList.h (126405 => 126406)


--- trunk/Source/WebKit2/UIProcess/WebBackForwardList.h	2012-08-23 08:32:23 UTC (rev 126405)
+++ trunk/Source/WebKit2/UIProcess/WebBackForwardList.h	2012-08-23 08:47:11 UTC (rev 126406)
@@ -70,12 +70,12 @@
     
     const BackForwardListItemVector& entries() const { return m_entries; }
 
-    uint32_t currentIndex() { return m_currentIndex; }
-    int backListCount();
-    int forwardListCount();
+    uint32_t currentIndex() const { return m_currentIndex; }
+    int backListCount() const;
+    int forwardListCount() const;
 
-    PassRefPtr<ImmutableArray> backListAsImmutableArrayWithLimit(unsigned limit);
-    PassRefPtr<ImmutableArray> forwardListAsImmutableArrayWithLimit(unsigned limit);
+    PassRefPtr<ImmutableArray> backListAsImmutableArrayWithLimit(unsigned limit) const;
+    PassRefPtr<ImmutableArray> forwardListAsImmutableArrayWithLimit(unsigned limit) const;
 
 #if USE(CF)
     CFDictionaryRef createCFDictionaryRepresentation(WebPageProxy::WebPageProxySessionStateFilterCallback, void* context) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to