[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:41:01 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit f7ecbced522ceeb4ae867e4da98e2c22001dc9be
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri May 21 08:34:45 2004 +0000

            Reviewed by Maciej.
    
            - fixed <rdar://problem/3090663>: (scroll to top of page when anchor is "#top" or "#")
    
            * khtml/khtml_part.cpp:
            (KHTMLPart::gotoAnchor): Detect anchor by checking for non-null, not non-empty, because an
            empty anchor is not the same as no anchor.
            (KHTMLPart::gotoAnchor): Add special case for anchors named "" and "top" (case insensitive),
            to scroll to the top left of the frame to match what WinIE and Mozilla do.
            (KHTMLPart::checkCompleted): Check for non-null here too for consistency.
    
            * kwq/KWQKURL.mm:
            (KURL::ref): Change check so that we return empty, not null, if there's an empty ref,
            as opposed to no ref.
            (KURL::hasRef): Return true if there's an empty ref, as opposed to no ref.
            (KURL::parse): Preserve an empty fragment when parsing.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6656 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 3dd767f..7880bda 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,22 @@
+2004-05-21  Darin Adler  <darin at apple.com>
+
+        Reviewed by Maciej.
+
+        - fixed <rdar://problem/3090663>: (scroll to top of page when anchor is "#top" or "#")
+
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::gotoAnchor): Detect anchor by checking for non-null, not non-empty, because an
+        empty anchor is not the same as no anchor.
+        (KHTMLPart::gotoAnchor): Add special case for anchors named "" and "top" (case insensitive),
+        to scroll to the top left of the frame to match what WinIE and Mozilla do.
+        (KHTMLPart::checkCompleted): Check for non-null here too for consistency.
+
+        * kwq/KWQKURL.mm:
+        (KURL::ref): Change check so that we return empty, not null, if there's an empty ref,
+        as opposed to no ref.
+        (KURL::hasRef): Return true if there's an empty ref, as opposed to no ref.
+        (KURL::parse): Preserve an empty fragment when parsing.
+
 2004-05-20  Darin Adler  <darin at apple.com>
 
         Reviewed by Maciej.
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index c8b95be..6556d00 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -1653,8 +1653,8 @@ void KHTMLPart::stopAnimations()
 
 void KHTMLPart::gotoAnchor()
 {
-    QString ref = m_url.encodedHtmlRef();
-    if (!ref.isEmpty())
+    if (m_url.hasRef()) {
+        QString ref = m_url.encodedHtmlRef();
         if (!gotoAnchor(ref)) {
             // Can't use htmlRef() here because it doesn't know which encoding to use to decode.
             // Decoding here has to match encoding in completeURL, which means it has to use the
@@ -1665,6 +1665,7 @@ void KHTMLPart::gotoAnchor()
 #else
                 gotoAnchor(KURL::decode_string(ref, d->m_decoder->codec()));
 #endif
+        }
     }
 }
 
@@ -1798,7 +1799,7 @@ void KHTMLPart::checkCompleted()
 
 #if !APPLE_CHANGES
   // check that the view has not been moved by the user  
-  if ( m_url.encodedHtmlRef().isEmpty() && d->m_view->contentsY() == 0 )
+  if ( !m_url.hasRef() && d->m_view->contentsY() == 0 )
       d->m_view->setContentsPos( d->m_extension->urlArgs().xOffset,
                                  d->m_extension->urlArgs().yOffset );
 #endif
@@ -2080,9 +2081,10 @@ bool KHTMLPart::gotoAnchor( const QString &name )
 
   d->m_doc->setCSSTarget(n); // Setting to null will clear the current target.
   
-  if(!n) {
-      kdDebug(6050) << "KHTMLPart::gotoAnchor node '" << name << "' not found" << endl;
-      return false;
+  // Implement the rule that "" and "top" both mean top of page as in other browsers.
+  if (!n && !(name.isEmpty() || name.lower() == "top")) {
+    kdDebug(6050) << "KHTMLPart::gotoAnchor node '" << name << "' not found" << endl;
+    return false;
   }
 
   // We need to update the layout before scrolling, otherwise we could
@@ -2096,14 +2098,15 @@ bool KHTMLPart::gotoAnchor( const QString &name )
   }
   
   int x = 0, y = 0;
-  HTMLElementImpl *a = static_cast<HTMLElementImpl *>(n);
-  a->getUpperLeftCorner(x, y);
+  if (n) {
+    static_cast<HTMLElementImpl *>(n)->getUpperLeftCorner(x, y);
+  }
+  // Scroll to actual top left of element with no slop, since some pages expect anchors to be exactly scrolled to.
 #if APPLE_CHANGES
-  // Remove the 50 pixel slop factor; some pages expect anchors to be exactly scrolled to.
-  // Also, call recursive version so this will expose correctly from within nested frames.
+  // Call recursive version so this will expose correctly from within nested frames.
   d->m_view->setContentsPosRecursive(x, y);
 #else
-  d->m_view->setContentsPos(x-50, y-50);
+  d->m_view->setContentsPos(x, y);
 #endif
 
   return true;
diff --git a/WebCore/kwq/KWQKURL.mm b/WebCore/kwq/KWQKURL.mm
index 1c8ad31..643333e 100644
--- a/WebCore/kwq/KWQKURL.mm
+++ b/WebCore/kwq/KWQKURL.mm
@@ -627,11 +627,7 @@ QString KURL::user() const
 
 QString KURL::ref() const
 {
-    if (!m_isValid) {
-	return QString();
-    }
-    
-    if (fragmentEndPos <= queryEndPos + 1) {
+    if (!m_isValid || fragmentEndPos == queryEndPos) {
 	return QString();
     }
 
@@ -640,7 +636,7 @@ QString KURL::ref() const
 
 bool KURL::hasRef() const
 {
-    return m_isValid && fragmentEndPos > queryEndPos + 1;
+    return m_isValid && fragmentEndPos != queryEndPos;
 }
 
 QString KURL::query() const
@@ -1409,7 +1405,7 @@ void KURL::parse(const char *url, const QString *originalString)
     queryEndPos = p - buffer;
     
     // add fragment, escaping bad characters
-    if (fragmentEnd != fragmentStart) {
+    if (fragmentEnd != queryEnd) {
 	*p++ = '#';
 	appendEscapingBadChars(p, url + fragmentStart, fragmentEnd - fragmentStart);
     }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list