[WK2] Refactoring: WebBackForwardList getters should be const
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 08:47:11 +0000 (08:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 08:47:11 +0000 (08:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94711

Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> 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):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebBackForwardList.cpp
Source/WebKit2/UIProcess/WebBackForwardList.h

index 606ce66..55fef59 100644 (file)
@@ -1,3 +1,25 @@
+2012-08-23  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        [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  <nbhargava@google.com>
 
         Reduce Font.h includes across project -- improves RenderObject.h compile time
index 00e8f4c..763023d 100644 (file)
@@ -186,21 +186,21 @@ WebBackForwardListItem* WebBackForwardList::itemAtIndex(int index)
     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 @@ PassRefPtr<ImmutableArray> WebBackForwardList::backListAsImmutableArrayWithLimit
     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());
 
index 16a562d..d78ed5a 100644 (file)
@@ -70,12 +70,12 @@ public:
     
     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;