Changeset 12114 in webkit


Ignore:
Timestamp:
Jan 15, 2006 7:14:52 AM (18 years ago)
Author:
darin
Message:

Reviewed by Hyatt.

I ran performance tests and the change results in a slight improvement.

  • bridge/mac/MacFrame.h: Removed include of KWQDict.h. Changed didTellBridgeAboutLoad and haveToldBridgeAboutLoad functions to take DOMString instead of QString. Changed urlsBridgeKnowsAbout from a QDict to a HashMap.
  • bridge/mac/MacFrame.mm: (MacFrame::didTellBridgeAboutLoad): Updated to use QDict and DOMString. (MacFrame::haveToldBridgeAboutLoad): Ditto.
  • khtml/editing/jsediting.h: Removed include of qdict.h.
  • khtml/rendering/render_frames.cpp: Removed include of qdict.h. Put file inside the khtml namespace instead of just using the namespace. Changed tabs to spaces. (khtml::RenderPartObject::updateWidget): Changed the local variable uniqueParamNames to be a HashSet instead of a QDict.
  • khtml/xml/DocumentImpl.h: Removed include of qdict.h, changed m_elementsById, m_idCount, and m_elementsByAccessKey to use HashMap and HashCountedSet instead of QDict.
  • khtml/xml/DocumentImpl.cpp: Changed tabs to spaces. (DocumentImpl::getElementById): Updated to use HashMap for m_elementsById and HashCountedSet for m_idCount. (DocumentImpl::addElementById): Ditto. Remove code to clear m_accessKeyDictValid, since setDocumentChanged already takes care of that. (DocumentImpl::removeElementById): Ditto. (DocumentImpl::getElementByAccessKey): Updated to use HashMap for m_elementsByAccessKey. (DocumentImpl::setDocumentChanged): Rearranged to do a couple fewer branches. Clear out the m_elementsByAccessKey map when clearing m_accessKeyMapValid to avoid keeping stale pointers around.
  • ksvg2/svg/SVGDocumentImpl.cpp: Removed include of q3dict.h.
  • WebCore.vcproj/WebCore/WebCore.vcproj: Removed obsolete QDict sources.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • ForwardingHeaders/q3dict.h: Removed.
  • ForwardingHeaders/qdict.h: Removed.
  • kwq/KWQDict.h: Removed.
  • kwq/KWQDictImpl.cpp: Removed.
  • kwq/KWQDictImpl.h: Removed.
  • WebCore+SVG/SVGNamesWrapper.cpp: Touched this file just so I could build again.
  • kwq/KWQKURL.h: Removed unused canonicalURL, _path, _user, _pass, and _host functions.
  • kwq/KWQKURL.mm: Changed tabs to spaces, removed unused functions, replaced NULL with 0.
  • kwq/KWQLoader.mm: Changed tabs to spaces. (KWQServeRequest): Removed QString conversion from call to didTellBridgeAboutLoad. (KWQServeSynchronousRequest): Ditto. (KWQCheckCacheObjectStatus): Ditto. Same for haveToldBridgeAboutLoad.
  • loader/Cache.h: Removed include of qdict.h. Changed declaration of the LRUList struct to just be a forward declaration. Changed tabs to spaces. Removed the static data member called "cache". Added a static member function called get. Renamed removeCacheEntry to remove.
  • loader/Cache.cpp: Put file inside the khtml namespace instead of just using the namespace. Changed tabs to spaces. Changed the main cache itself to a HashMap and made it a static variable local to this file instead of a static data member of Cache to hide its type from the header. Also made the LRUList type private to this file. (khtml::Cache::init): Create a HashMap instead of a QDict. (khtml::Cache::clear): To replace the use of setAutoDelete, write a loop to delete all the items in the cache map. (khtml::Cache::requestImage): Change code to use HashMap functions instead of QDict. (khtml::Cache::requestStyleSheet): Ditto. (khtml::Cache::preloadStyleSheet): Ditto. (khtml::Cache::requestScript): Ditto. (khtml::Cache::preloadScript): Ditto. (khtml::Cache::requestXSLStyleSheet): Ditto. (khtml::Cache::requestXBLDocument): Ditto. (khtml::Cache::removeCacheEntry): Ditto. (khtml::Cache::FastLog2): Fixed this for 64-bit compiles. (khtml::Cache::getStatistics): Ditto. (khtml::Cache::flushAll): Ditto. (khtml::Cache::get): Added. Function used by the loader.
  • loader/CachedObject.h: Removed include of qdict.h.
  • loader/DocLoader.h: Removed include of qdict.h.
  • loader/DocLoader.cpp: (khtml::DocLoader::needReload): Changed to use new get function of Cache instead of getting at the map directly. Also changed call to removeCacheEntry to remove because it was renamed.
  • loader/CachedImage.cpp: (khtml::CachedImage::data): Changed call to removeCacheEntry to remove because it was renamed.
  • loader/CachedImageCallback.cpp: (khtml::CachedImageCallback::handleError): Ditto.
  • loader/loader.cpp: (khtml::Loader::slotFinished): Ditto. (khtml::Loader::cancelRequests): Ditto.
Location:
trunk/WebCore
Files:
5 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r12109 r12114  
     12006-01-15  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Hyatt.
     4
     5        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6528
     6          remove all use of QDict from WebCore
     7
     8        I ran performance tests and the change results in a slight improvement.
     9
     10        * bridge/mac/MacFrame.h: Removed include of KWQDict.h. Changed didTellBridgeAboutLoad
     11        and haveToldBridgeAboutLoad functions to take DOMString instead of QString. Changed
     12        urlsBridgeKnowsAbout from a QDict to a HashMap.
     13        * bridge/mac/MacFrame.mm:
     14        (MacFrame::didTellBridgeAboutLoad): Updated to use QDict and DOMString.
     15        (MacFrame::haveToldBridgeAboutLoad): Ditto.
     16
     17        * khtml/editing/jsediting.h: Removed include of qdict.h.
     18
     19        * khtml/rendering/render_frames.cpp: Removed include of qdict.h. Put file inside the
     20        khtml namespace instead of just using the namespace. Changed tabs to spaces.
     21        (khtml::RenderPartObject::updateWidget): Changed the local variable uniqueParamNames
     22        to be a HashSet instead of a QDict.
     23
     24        * khtml/xml/DocumentImpl.h: Removed include of qdict.h, changed m_elementsById, m_idCount,
     25        and m_elementsByAccessKey to use HashMap and HashCountedSet instead of QDict.
     26        * khtml/xml/DocumentImpl.cpp: Changed tabs to spaces.
     27        (DocumentImpl::getElementById): Updated to use HashMap for m_elementsById and HashCountedSet
     28        for m_idCount.
     29        (DocumentImpl::addElementById): Ditto. Remove code to clear m_accessKeyDictValid,
     30        since setDocumentChanged already takes care of that.
     31        (DocumentImpl::removeElementById): Ditto.
     32        (DocumentImpl::getElementByAccessKey): Updated to use HashMap for m_elementsByAccessKey.
     33        (DocumentImpl::setDocumentChanged): Rearranged to do a couple fewer branches. Clear out
     34        the m_elementsByAccessKey map when clearing m_accessKeyMapValid to avoid keeping stale
     35        pointers around.
     36
     37        * ksvg2/svg/SVGDocumentImpl.cpp: Removed include of q3dict.h.
     38
     39        * WebCore.vcproj/WebCore/WebCore.vcproj: Removed obsolete QDict sources.
     40        * WebCore.xcodeproj/project.pbxproj: Ditto.
     41
     42        * ForwardingHeaders/q3dict.h: Removed.
     43        * ForwardingHeaders/qdict.h: Removed.
     44        * kwq/KWQDict.h: Removed.
     45        * kwq/KWQDictImpl.cpp: Removed.
     46        * kwq/KWQDictImpl.h: Removed.
     47
     48        * WebCore+SVG/SVGNamesWrapper.cpp: Touched this file just so I could build again.
     49
     50        * kwq/KWQKURL.h: Removed unused canonicalURL, _path, _user, _pass, and _host functions.
     51        * kwq/KWQKURL.mm: Changed tabs to spaces, removed unused functions, replaced NULL with 0.
     52
     53        * kwq/KWQLoader.mm: Changed tabs to spaces.
     54        (KWQServeRequest): Removed QString conversion from call to didTellBridgeAboutLoad.
     55        (KWQServeSynchronousRequest): Ditto.
     56        (KWQCheckCacheObjectStatus): Ditto. Same for haveToldBridgeAboutLoad.
     57
     58        * loader/Cache.h: Removed include of qdict.h. Changed declaration of the LRUList struct
     59        to just be a forward declaration. Changed tabs to spaces. Removed the static data member
     60        called "cache". Added a static member function called get. Renamed removeCacheEntry to remove.
     61        * loader/Cache.cpp: Put file inside the khtml namespace instead of just using the
     62        namespace. Changed tabs to spaces. Changed the main cache itself to a HashMap and
     63        made it a static variable local to this file instead of a static data member of Cache
     64        to hide its type from the header. Also made the LRUList type private to this file.
     65        (khtml::Cache::init): Create a HashMap instead of a QDict.
     66        (khtml::Cache::clear): To replace the use of setAutoDelete, write a loop to delete all the
     67        items in the cache map.
     68        (khtml::Cache::requestImage): Change code to use HashMap functions instead of QDict.
     69        (khtml::Cache::requestStyleSheet): Ditto.
     70        (khtml::Cache::preloadStyleSheet): Ditto.
     71        (khtml::Cache::requestScript): Ditto.
     72        (khtml::Cache::preloadScript): Ditto.
     73        (khtml::Cache::requestXSLStyleSheet): Ditto.
     74        (khtml::Cache::requestXBLDocument): Ditto.
     75        (khtml::Cache::removeCacheEntry): Ditto.
     76        (khtml::Cache::FastLog2): Fixed this for 64-bit compiles.
     77        (khtml::Cache::getStatistics): Ditto.
     78        (khtml::Cache::flushAll): Ditto.
     79        (khtml::Cache::get): Added. Function used by the loader.
     80
     81        * loader/CachedObject.h: Removed include of qdict.h.
     82
     83        * loader/DocLoader.h: Removed include of qdict.h.
     84        * loader/DocLoader.cpp: (khtml::DocLoader::needReload): Changed to use new get function of
     85        Cache instead of getting at the map directly. Also changed call to removeCacheEntry
     86        to remove because it was renamed.
     87
     88        * loader/CachedImage.cpp: (khtml::CachedImage::data): Changed call to removeCacheEntry
     89        to remove because it was renamed.
     90        * loader/CachedImageCallback.cpp: (khtml::CachedImageCallback::handleError): Ditto.
     91        * loader/loader.cpp:
     92        (khtml::Loader::slotFinished): Ditto.
     93        (khtml::Loader::cancelRequests): Ditto.
     94
    1952006-01-15  Alexander Kellett  <lypanov@kde.org>
    296
  • trunk/WebCore/WebCore.vcproj/WebCore/WebCore.vcproj

    r12102 r12114  
    208208                        </File>
    209209                        <File
    210                                 RelativePath="..\..\kwq\KWQDict.h"
    211                                 >
    212                         </File>
    213                         <File
    214                                 RelativePath="..\..\kwq\KWQDictImpl.h"
    215                                 >
    216                         </File>
    217                         <File
    218210                                RelativePath="..\..\kwq\KWQEditCommand.h"
    219211                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r12106 r12114  
    176176                93F1993208245E59001E9ABC /* KWQDateTime.h in Headers */ = {isa = PBXBuildFile; fileRef = F587868502DE3B8601EA4122 /* KWQDateTime.h */; };
    177177                93F1993308245E59001E9ABC /* KWQDef.h in Headers */ = {isa = PBXBuildFile; fileRef = F58784DA02DE375901EA4122 /* KWQDef.h */; };
    178                 93F1993408245E59001E9ABC /* KWQDict.h in Headers */ = {isa = PBXBuildFile; fileRef = F587868602DE3B8601EA4122 /* KWQDict.h */; };
    179                 93F1993508245E59001E9ABC /* KWQDictImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = F58784DB02DE375901EA4122 /* KWQDictImpl.h */; };
    180178                93F1993708245E59001E9ABC /* KWQEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = F587868802DE3B8601EA4122 /* KWQEvent.h */; };
    181179                93F1993808245E59001E9ABC /* KWQFile.h in Headers */ = {isa = PBXBuildFile; fileRef = F587868902DE3B8601EA4122 /* KWQFile.h */; };
     
    351349                93F19A1908245E59001E9ABC /* KWQCursor.mm in Sources */ = {isa = PBXBuildFile; fileRef = F58784D602DE375901EA4122 /* KWQCursor.mm */; };
    352350                93F19A1A08245E59001E9ABC /* KWQDateTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F58784D702DE375901EA4122 /* KWQDateTime.cpp */; };
    353                 93F19A1B08245E59001E9ABC /* KWQDictImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F58784DC02DE375901EA4122 /* KWQDictImpl.cpp */; };
    354351                93F19A1C08245E59001E9ABC /* KWQEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = F58784DE02DE375901EA4122 /* KWQEvent.mm */; };
    355352                93F19A1D08245E59001E9ABC /* KWQFile.mm in Sources */ = {isa = PBXBuildFile; fileRef = F58784DF02DE375901EA4122 /* KWQFile.mm */; };
     
    737734                A88AD1790952480A001DD196 /* KWQDateTime.h in Headers */ = {isa = PBXBuildFile; fileRef = F587868502DE3B8601EA4122 /* KWQDateTime.h */; };
    738735                A88AD17A0952480A001DD196 /* KWQDef.h in Headers */ = {isa = PBXBuildFile; fileRef = F58784DA02DE375901EA4122 /* KWQDef.h */; };
    739                 A88AD17B0952480A001DD196 /* KWQDict.h in Headers */ = {isa = PBXBuildFile; fileRef = F587868602DE3B8601EA4122 /* KWQDict.h */; };
    740                 A88AD17C0952480A001DD196 /* KWQDictImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = F58784DB02DE375901EA4122 /* KWQDictImpl.h */; };
    741736                A88AD17E0952480A001DD196 /* KWQEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = F587868802DE3B8601EA4122 /* KWQEvent.h */; };
    742737                A88AD17F0952480A001DD196 /* KWQFile.h in Headers */ = {isa = PBXBuildFile; fileRef = F587868902DE3B8601EA4122 /* KWQFile.h */; };
     
    954949                A88AD2760952480A001DD196 /* KWQCursor.mm in Sources */ = {isa = PBXBuildFile; fileRef = F58784D602DE375901EA4122 /* KWQCursor.mm */; };
    955950                A88AD2770952480A001DD196 /* KWQDateTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F58784D702DE375901EA4122 /* KWQDateTime.cpp */; };
    956                 A88AD2780952480A001DD196 /* KWQDictImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F58784DC02DE375901EA4122 /* KWQDictImpl.cpp */; };
    957951                A88AD2790952480A001DD196 /* KWQEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = F58784DE02DE375901EA4122 /* KWQEvent.mm */; };
    958952                A88AD27A0952480A001DD196 /* KWQFile.mm in Sources */ = {isa = PBXBuildFile; fileRef = F58784DF02DE375901EA4122 /* KWQFile.mm */; };
     
    27302724                F58784D702DE375901EA4122 /* KWQDateTime.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KWQDateTime.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    27312725                F58784DA02DE375901EA4122 /* KWQDef.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KWQDef.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    2732                 F58784DB02DE375901EA4122 /* KWQDictImpl.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KWQDictImpl.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    2733                 F58784DC02DE375901EA4122 /* KWQDictImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KWQDictImpl.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    27342726                F58784DE02DE375901EA4122 /* KWQEvent.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQEvent.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    27352727                F58784DF02DE375901EA4122 /* KWQFile.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQFile.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    28292821                F587868402DE3B8601EA4122 /* KWQCursor.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KWQCursor.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    28302822                F587868502DE3B8601EA4122 /* KWQDateTime.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KWQDateTime.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    2831                 F587868602DE3B8601EA4122 /* KWQDict.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KWQDict.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    28322823                F587868802DE3B8601EA4122 /* KWQEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KWQEvent.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    28332824                F587868902DE3B8601EA4122 /* KWQFile.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KWQFile.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    43674358                                F587868502DE3B8601EA4122 /* KWQDateTime.h */,
    43684359                                F58784D702DE375901EA4122 /* KWQDateTime.cpp */,
    4369                                 F587868602DE3B8601EA4122 /* KWQDict.h */,
    4370                                 F58784DB02DE375901EA4122 /* KWQDictImpl.h */,
    4371                                 F58784DC02DE375901EA4122 /* KWQDictImpl.cpp */,
    43724360                                F587868802DE3B8601EA4122 /* KWQEvent.h */,
    43734361                                F58784DE02DE375901EA4122 /* KWQEvent.mm */,
     
    45484536                                93F1993208245E59001E9ABC /* KWQDateTime.h in Headers */,
    45494537                                93F1993308245E59001E9ABC /* KWQDef.h in Headers */,
    4550                                 93F1993408245E59001E9ABC /* KWQDict.h in Headers */,
    4551                                 93F1993508245E59001E9ABC /* KWQDictImpl.h in Headers */,
    45524538                                93F1993708245E59001E9ABC /* KWQEvent.h in Headers */,
    45534539                                93F1993808245E59001E9ABC /* KWQFile.h in Headers */,
     
    50765062                                A88AD1790952480A001DD196 /* KWQDateTime.h in Headers */,
    50775063                                A88AD17A0952480A001DD196 /* KWQDef.h in Headers */,
    5078                                 A88AD17B0952480A001DD196 /* KWQDict.h in Headers */,
    5079                                 A88AD17C0952480A001DD196 /* KWQDictImpl.h in Headers */,
    50805064                                A88AD17E0952480A001DD196 /* KWQEvent.h in Headers */,
    50815065                                A88AD17F0952480A001DD196 /* KWQFile.h in Headers */,
     
    64186402                                93F19A1908245E59001E9ABC /* KWQCursor.mm in Sources */,
    64196403                                93F19A1A08245E59001E9ABC /* KWQDateTime.cpp in Sources */,
    6420                                 93F19A1B08245E59001E9ABC /* KWQDictImpl.cpp in Sources */,
    64216404                                93F19A1C08245E59001E9ABC /* KWQEvent.mm in Sources */,
    64226405                                93F19A1D08245E59001E9ABC /* KWQFile.mm in Sources */,
     
    68886871                                A88AD2760952480A001DD196 /* KWQCursor.mm in Sources */,
    68896872                                A88AD2770952480A001DD196 /* KWQDateTime.cpp in Sources */,
    6890                                 A88AD2780952480A001DD196 /* KWQDictImpl.cpp in Sources */,
    68916873                                A88AD2790952480A001DD196 /* KWQEvent.mm in Sources */,
    68926874                                A88AD27A0952480A001DD196 /* KWQFile.mm in Sources */,
  • trunk/WebCore/bridge/mac/MacFrame.h

    r12095 r12114  
    11/*
    2  * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
     2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828
    2929#include "Frame.h"
    30 
     30#include "KWQClipboard.h"
     31#include "KWQScrollBar.h"
     32#include "NodeImpl.h"
     33#include "WebCoreKeyboardAccess.h"
    3134#include "text_affinity.h"
    32 #include "NodeImpl.h"
    33 
    34 #include "WebCoreKeyboardAccess.h"
     35#include <kxmlcore/HashSet.h>
    3536
    3637#if __APPLE__
    3738#import <CoreFoundation/CoreFoundation.h>
    3839#endif
    39 
    40 #include "KWQDict.h"
    41 #include "KWQClipboard.h"
    42 #include "KWQScrollBar.h"
    4340
    4441class FramePrivate;
     
    263260    WebCoreKeyboardUIMode keyboardUIMode() const;
    264261
    265     void didTellBridgeAboutLoad(const QString &urlString);
    266     bool haveToldBridgeAboutLoad(const QString &urlString);
     262    void didTellBridgeAboutLoad(const DOM::DOMString& URL);
     263    bool haveToldBridgeAboutLoad(const DOM::DOMString& URL);
    267264
    268265    KJS::Bindings::Instance *getEmbedInstanceForWidget(QWidget*);
     
    366363    bool _haveUndoRedoOperations;
    367364   
    368     QDict<char> urlsBridgeKnowsAbout;
     365    HashSet<RefPtr<DOM::DOMStringImpl> > urlsBridgeKnowsAbout;
    369366
    370367    friend class Frame;
  • trunk/WebCore/bridge/mac/MacFrame.mm

    r12085 r12114  
    11/*
    2  * Copyright (C) 2004, 2005 Apple Computer, Inc.  All rights reserved.
     2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    30763076}
    30773077
    3078 void MacFrame::didTellBridgeAboutLoad(const QString &urlString)
    3079 {
    3080     static char dummy;
    3081     urlsBridgeKnowsAbout.insert(urlString, &dummy);
    3082 }
    3083 
    3084 bool MacFrame::haveToldBridgeAboutLoad(const QString &urlString)
    3085 {
    3086     return urlsBridgeKnowsAbout.find(urlString) != 0;
     3078void MacFrame::didTellBridgeAboutLoad(const DOM::DOMString& URL)
     3079{
     3080    urlsBridgeKnowsAbout.insert(URL.impl());
     3081}
     3082
     3083bool MacFrame::haveToldBridgeAboutLoad(const DOM::DOMString& URL)
     3084{
     3085    return urlsBridgeKnowsAbout.contains(URL.impl());
    30873086}
    30883087
  • trunk/WebCore/khtml/editing/jsediting.h

    r12020 r12114  
    11/*
    2  * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
     2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef __jsediting_h__
    27 #define __jsediting_h__
     26#ifndef jsediting_h__
     27#define jsediting_h__
    2828
    2929#include "dom_string.h"
    30 #include "qdict.h"
    3130
    3231class Frame;
  • trunk/WebCore/khtml/rendering/render_frames.cpp

    • Property allow-tabs deleted
    r12085 r12114  
    55 *           (C) 2000 Simon Hausmann <hausmann@kde.org>
    66 *           (C) 2000 Stefan Schimanski (1Stein@gmx.de)
    7  * Copyright (C) 2004 Apple Computer, Inc.
     7 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
    88 *
    99 * This library is free software; you can redistribute it and/or
     
    2323 *
    2424 */
    25 //#define DEBUG_LAYOUT
    2625
    2726#include "config.h"
    2827#include "render_frames.h"
    29 #include "render_canvas.h"
     28
     29#include "DocumentImpl.h"
     30#include "Frame.h"
     31#include "FrameView.h"
    3032#include "html/html_baseimpl.h"
    3133#include "html/html_objectimpl.h"
    3234#include "html/htmltokenizer.h"
     35#include "render_arena.h"
     36#include "render_canvas.h"
     37#include "xml/EventNames.h"
    3338#include "xml/dom2_eventsimpl.h"
    34 #include "DocumentImpl.h"
    3539#include "xml/dom_textimpl.h"
    36 #include "xml/EventNames.h"
    37 #include "FrameView.h"
    38 #include "Frame.h"
    39 #include "render_arena.h"
    40 
    4140#include <kcursor.h>
     41#include <kdebug.h>
    4242#include <klocale.h>
    43 #include <kdebug.h>
     43#include <qpainter.h>
    4444#include <qtimer.h>
    45 #include <qpainter.h>
    46 #include "qdict.h"
    47 
    48 using namespace khtml;
     45
    4946using namespace DOM;
    5047using namespace EventNames;
    5148using namespace HTMLNames;
     49
     50//#define DEBUG_LAYOUT
     51
     52namespace khtml {
    5253
    5354RenderFrameSet::RenderFrameSet( HTMLFrameSetElementImpl *frameSet)
     
    331332    RenderObject *child = firstChild();
    332333    if ( !child )
    333         goto end2;
     334        goto end2;
    334335
    335336    if(!m_hSplitVar && !m_vSplitVar)
     
    421422          child->setHeight( m_gridLayout[0][r] );
    422423          child->setNeedsLayout(true);
    423           child->layout();
     424          child->layout();
    424425      }
    425426
     
    652653{
    653654    if (m_widget && m_widget->inherits("KHTMLView")) {
    654         static_cast<KHTMLView *>(m_widget)->deref();
     655        static_cast<KHTMLView *>(m_widget)->deref();
    655656    }
    656657}
     
    663664   
    664665    if (widget == m_widget) {
    665         return;
     666        return;
    666667    }
    667668
    668669    if (m_widget && m_widget->inherits("KHTMLView")) {
    669         static_cast<KHTMLView *>(m_widget)->deref();
     670        static_cast<KHTMLView *>(m_widget)->deref();
    670671    }
    671672   
    672     if (widget && widget->inherits("KHTMLView")) {     
    673         static_cast<KHTMLView *>(widget)->ref();
    674         setQWidget( widget, false );
    675         connect( widget, SIGNAL( cleared() ), this, SLOT( slotViewCleared() ) );
     673    if (widget && widget->inherits("KHTMLView")) {
     674        static_cast<KHTMLView *>(widget)->ref();
     675        setQWidget( widget, false );
     676        connect( widget, SIGNAL( cleared() ), this, SLOT( slotViewCleared() ) );
    676677    } else {
    677         setQWidget( widget );
     678        setQWidget( widget );
    678679    }
    679680    setNeedsLayoutAndMinMaxRecalc();
     
    737738   
    738739    if (doc->frame()->topLevelFrameCount() >= 200)
    739         return false;
     740        return false;
    740741
    741742    // We allow one level of self-reference because some sites depend on that.
     
    833834      }
    834835     
    835       QDict<bool> uniqueParamNames(5, false);
     836      HashSet<DOMStringImpl*, CaseInsensitiveHash> uniqueParamNames;
    836837     
    837838      // Scan the PARAM children.
     
    841842      while (child && (url.isEmpty() || serviceType.isEmpty() || !embed)) {
    842843          if (child->hasTagName(paramTag)) {
    843               HTMLParamElementImpl *p = static_cast<HTMLParamElementImpl *>( child );
     844              HTMLParamElementImpl *p = static_cast<HTMLParamElementImpl *>(child);
    844845              DOMString name = p->name().lower();
    845846              if (url.isEmpty() && (name == "src" || name == "movie" || name == "code" || name == "url"))
     
    853854              }
    854855              if (!embed) {
    855                   bool dummyValue = true;
    856                   uniqueParamNames.insert(p->name().qstring(), &dummyValue);
     856                  uniqueParamNames.insert(p->name().impl());
    857857                  paramNames.append(p->name().qstring());
    858858                  paramValues.append(p->value().qstring());
     
    867867      // we have to explicitly suppress the tag's CODEBASE attribute if there is none in a PARAM,
    868868      // else our Java plugin will misinterpret it. [4004531]
     869      DOMString codebase;
    869870      if (!embed && serviceType.lower() == "application/x-java-applet") {
    870           bool dummyValue = true;
    871           uniqueParamNames.insert("codebase", &dummyValue); // pretend we found it in a PARAM already
     871          codebase = "codebase";
     872          uniqueParamNames.insert(codebase.impl()); // pretend we found it in a PARAM already
    872873      }
    873874     
     
    877878          for (unsigned i = 0; i < attributes->length(); ++i) {
    878879              AttributeImpl* it = attributes->attributeItem(i);
    879               QString name = it->name().localName().qstring();
    880               if (embed || uniqueParamNames.find(name) == 0) {
    881                   paramNames.append(name);
     880              const AtomicString& name = it->name().localName();
     881              if (embed || uniqueParamNames.contains(name.impl())) {
     882                  paramNames.append(name.qstring());
    882883                  paramValues.append(it->value().qstring());
    883884              }
     
    933934          return;
    934935      if (url.isEmpty())
    935           url = "about:blank";
     936          url = "about:blank";
    936937      KHTMLView *v = static_cast<KHTMLView *>(m_view);
    937938      bool requestSucceeded = v->frame()->requestFrame( this, url, o->m_name.qstring(), QStringList(), QStringList(), true );
    938939      if (requestSucceeded && url == "about:blank") {
    939           Frame *newPart = v->frame()->findFrame( o->m_name.qstring() );
    940           if (newPart && newPart->xmlDocImpl()) {
    941               newPart->xmlDocImpl()->setBaseURL( v->frame()->baseURL().url() );
    942           }
     940          Frame *newPart = v->frame()->findFrame( o->m_name.qstring() );
     941          if (newPart && newPart->xmlDocImpl()) {
     942              newPart->xmlDocImpl()->setBaseURL( v->frame()->baseURL().url() );
     943          }
    943944      }
    944945  }
     
    971972      int marginh = -1;
    972973      if (element()->hasTagName(iframeTag)) {
    973           HTMLIFrameElementImpl *frame = static_cast<HTMLIFrameElementImpl *>(element());
    974           if(frame->m_frameBorder)
    975               frameStyle = QFrame::Box;
     974          HTMLIFrameElementImpl *frame = static_cast<HTMLIFrameElementImpl *>(element());
     975          if(frame->m_frameBorder)
     976              frameStyle = QFrame::Box;
    976977          scroll = frame->m_scrolling;
    977           marginw = frame->m_marginWidth;
    978           marginh = frame->m_marginHeight;
     978          marginw = frame->m_marginWidth;
     979          marginh = frame->m_marginHeight;
    979980      }
    980981      view->setFrameStyle(frameStyle);
     
    10201021    }
    10211022}
     1023
     1024}
  • trunk/WebCore/khtml/xml/DocumentImpl.cpp

    • Property allow-tabs deleted
    r12090 r12114  
    268268
    269269    m_cssTarget = 0;
    270     m_accessKeyDictValid = false;
     270    m_accessKeyMapValid = false;
    271271
    272272    resetLinkColor();
     
    317317    KJS::ScriptInterpreter::forgetAllDOMNodesForDocument(this);
    318318
    319     if (changedDocuments && m_docChanged)
     319    if (m_docChanged && changedDocuments)
    320320        changedDocuments->remove(this);
    321321    delete m_tokenizer;
     
    498498            ElementImpl *oldElement = static_cast<ElementImpl *>(importedNode);
    499499            ElementImpl *newElement = createElementNS(oldElement->namespaceURI(), oldElement->tagName().toString(), exceptioncode);
    500                        
     500                       
    501501            if (exceptioncode != 0)
    502502                return 0;
     
    618618}
    619619
    620 ElementImpl *DocumentImpl::getElementById( const DOMString &elementId ) const
    621 {
    622     ElementImpl *element;
    623     QString qId = elementId.qstring();
    624 
    625     if (elementId.length() == 0) {
     620ElementImpl *DocumentImpl::getElementById(const DOMString& elementId) const
     621{
     622    if (elementId.length() == 0)
    626623        return 0;
    627     }
    628 
    629     element = m_elementsById.find(qId);
    630    
     624
     625    ElementImpl *element = m_elementsById.get(elementId.impl());
    631626    if (element)
    632627        return element;
    633628       
    634     if (int idCount = (int)m_idCount.find(qId)) {
     629    if (m_idCount.contains(elementId.impl())) {
    635630        for (NodeImpl *n = traverseNextNode(); n != 0; n = n->traverseNextNode()) {
     631            if (n->isElementNode()) {
     632                element = static_cast<ElementImpl*>(n);
     633                if (element->hasID() && element->getAttribute(idAttr) == elementId) {
     634                    m_idCount.remove(elementId.impl());
     635                    m_elementsById.set(elementId.impl(), element);
     636                    return element;
     637                }
     638            }
     639        }
     640    }
     641    return 0;
     642}
     643
     644ElementImpl *DocumentImpl::elementFromPoint( const int _x, const int _y ) const
     645{
     646    if (!m_render)
     647        return 0;
     648   
     649    RenderObject::NodeInfo nodeInfo(true, true);
     650    m_render->layer()->hitTest(nodeInfo, _x, _y);
     651
     652    NodeImpl* n = nodeInfo.innerNode();
     653    while (n && !n->isElementNode())
     654        n = n->parentNode();
     655    return static_cast<ElementImpl*>(n);
     656}
     657
     658void DocumentImpl::addElementById(const DOMString& elementId, ElementImpl* element)
     659{
     660    if (!m_elementsById.contains(elementId.impl()))
     661        m_elementsById.set(elementId.impl(), element);
     662    else
     663        m_idCount.insert(elementId.impl());
     664}
     665
     666void DocumentImpl::removeElementById(const DOMString& elementId, ElementImpl* element)
     667{
     668    if (m_elementsById.get(elementId.impl()) == element)
     669        m_elementsById.remove(elementId.impl());
     670    else
     671        m_idCount.remove(elementId.impl());
     672}
     673
     674ElementImpl* DocumentImpl::getElementByAccessKey(const DOMString& key)
     675{
     676    if (!key.length())
     677        return 0;
     678    if (!m_accessKeyMapValid) {
     679        for (NodeImpl* n = this; n; n = n->traverseNextNode()) {
    636680            if (!n->isElementNode())
    637681                continue;
    638            
    639             element = static_cast<ElementImpl *>(n);
    640            
    641             if (element->hasID() && element->getAttribute(idAttr) == elementId) {
    642                 if (idCount == 1)
    643                     m_idCount.remove(qId);
    644                 else
    645                     m_idCount.insert(qId, (char *)idCount - 1);
    646                
    647                 m_elementsById.insert(qId, element);
    648                 return element;
    649             }
    650         }
    651     }
    652     return 0;
    653 }
    654 
    655 ElementImpl *DocumentImpl::elementFromPoint( const int _x, const int _y ) const
    656 {
    657     if (!m_render) return 0;
    658    
    659     RenderObject::NodeInfo nodeInfo(true, true);
    660     m_render->layer()->hitTest(nodeInfo, _x, _y);
    661     NodeImpl* n = nodeInfo.innerNode();
    662 
    663     while ( n && !n->isElementNode() ) {
    664         n = n->parentNode();
    665     }
    666    
    667     return static_cast<ElementImpl*>(n);
    668 }
    669 
    670 void DocumentImpl::addElementById(const DOMString &elementId, ElementImpl *element)
    671 {
    672     QString qId = elementId.qstring();
    673    
    674     if (m_elementsById.find(qId) == NULL) {
    675         m_elementsById.insert(qId, element);
    676         m_accessKeyDictValid = false;
    677     } else {
    678         int idCount = (int)m_idCount.find(qId);
    679         m_idCount.insert(qId, (char *)(idCount + 1));
    680     }
    681 }
    682 
    683 void DocumentImpl::removeElementById(const DOMString &elementId, ElementImpl *element)
    684 {
    685     QString qId = elementId.qstring();
    686 
    687     if (m_elementsById.find(qId) == element) {
    688         m_elementsById.remove(qId);
    689         m_accessKeyDictValid = false;
    690     } else {
    691         int idCount = (int)m_idCount.find(qId);       
    692         assert(idCount > 0);
    693         if (idCount == 1)
    694             m_idCount.remove(qId);
    695         else
    696             m_idCount.insert(qId, (char *)(idCount - 1));
    697     }
    698 }
    699 
    700 ElementImpl *DocumentImpl::getElementByAccessKey( const DOMString &key )
    701 {
    702     if (!key.length())
    703         return 0;
    704 
    705     if (!m_accessKeyDictValid) {
    706         m_elementsByAccessKey.clear();
    707    
    708         const NodeImpl *n;
    709         for (n = this; n != 0; n = n->traverseNextNode()) {
    710             if (!n->isElementNode())
    711                 continue;
    712             const ElementImpl *elementImpl = static_cast<const ElementImpl *>(n);
    713             DOMString accessKey(elementImpl->getAttribute(accesskeyAttr));;
    714             if (!accessKey.isEmpty()) {
    715                 QString ak = accessKey.qstring().lower();
    716                 if (m_elementsByAccessKey.find(ak) == NULL)
    717                     m_elementsByAccessKey.insert(ak, elementImpl);
    718             }
    719         }
    720         m_accessKeyDictValid = true;
    721     }
    722     return m_elementsByAccessKey.find(key.qstring());
     682            ElementImpl* element = static_cast<ElementImpl *>(n);
     683            const AtomicString& accessKey = element->getAttribute(accesskeyAttr);
     684            if (!accessKey.isEmpty())
     685                m_elementsByAccessKey.set(accessKey.impl(), element);
     686        }
     687        m_accessKeyMapValid = true;
     688    }
     689    return m_elementsByAccessKey.get(key.impl());
    723690}
    724691
     
    828795void DocumentImpl::setDocumentChanged(bool b)
    829796{
    830     if (!changedDocuments)
    831         changedDocuments = new QPtrList<DocumentImpl>;
    832 
    833     if (b && !m_docChanged)
    834         changedDocuments->append(this);
    835     else if (!b && m_docChanged)
    836         changedDocuments->remove(this);
     797    if (b) {
     798        if (!m_docChanged) {
     799            if (!changedDocuments)
     800                changedDocuments = new QPtrList<DocumentImpl>;
     801            changedDocuments->append(this);
     802        }
     803        if (m_accessKeyMapValid) {
     804            m_accessKeyMapValid = false;
     805            m_elementsByAccessKey.clear();
     806        }
     807    } else {
     808        if (m_docChanged && changedDocuments)
     809            changedDocuments->remove(this);
     810    }
     811
    837812    m_docChanged = b;
    838    
    839     if (m_docChanged)
    840         m_accessKeyDictValid = false;
    841813}
    842814
    843815void DocumentImpl::recalcStyle( StyleChange change )
    844816{
    845 //     qDebug("recalcStyle(%p)", this);
    846 //     QTime qt;
    847 //     qt.start();
    848817    if (m_inStyleRecalc)
    849818        return; // Guard against re-entrancy. -dwh
     
    882851        }
    883852
    884         //kdDebug() << "DocumentImpl::attach: setting to charset " << settings->charset() << endl;
    885853        _style->setFontDef(fontDef);
    886854        _style->htmlFont().update( paintDeviceMetrics() );
     
    903871        if ( change>= Inherit || n->hasChangedChild() || n->changed() )
    904872            n->recalcStyle( change );
    905     //kdDebug( 6020 ) << "TIME: recalcStyle() dt=" << qt.elapsed() << endl;
    906873
    907874    if (changed() && m_view)
    908         m_view->layout();
     875        m_view->layout();
    909876
    910877bail_out:
     
    924891void DocumentImpl::updateRendering()
    925892{
    926     if (!hasChangedChild()) return;
    927 
    928 //     QTime time;
    929 //     time.start();
    930 //     kdDebug() << "UPDATERENDERING: "<<endl;
    931 
    932     StyleChange change = NoChange;
    933     recalcStyle( change );
    934 
    935 //    kdDebug() << "UPDATERENDERING time used="<<time.elapsed()<<endl;
     893    if (hasChangedChild())
     894        recalcStyle(NoChange);
    936895}
    937896
     
    949908void DocumentImpl::updateLayout()
    950909{
    951     // FIXME: Dave's pretty sure we can remove this because
    952     // layout calls recalcStyle as needed.
     910    // FIXME: Dave Hyatt's pretty sure we can remove this because layout calls recalcStyle as needed.
    953911    updateRendering();
    954912
    955913    // Only do a layout if changes have occurred that make it necessary.     
    956914    if (m_view && renderer() && renderer()->needsLayout())
    957         m_view->layout();
     915        m_view->layout();
    958916}
    959917
     
    970928    if (!haveStylesheetsLoaded()) {
    971929        m_ignorePendingStylesheets = true;
    972         updateStyleSelector();   
     930        updateStyleSelector();   
    973931    }
    974932
     
    14181376    if ( m_usersheet != sheet ) {
    14191377        m_usersheet = sheet;
    1420         updateStyleSelector();
     1378        updateStyleSelector();
    14211379    }
    14221380}
     
    14451403
    14461404    if (!fromNode) {
    1447         // No starting node supplied; begin with the top of the document
    1448         NodeImpl *n;
    1449 
    1450         int lowestTabIndex = 65535;
    1451         for (n = this; n != 0; n = n->traverseNextNode()) {
    1452             if (n->isKeyboardFocusable()) {
    1453                 if ((n->tabIndex() > 0) && (n->tabIndex() < lowestTabIndex))
    1454                     lowestTabIndex = n->tabIndex();
    1455             }
    1456         }
    1457 
    1458         if (lowestTabIndex == 65535)
    1459             lowestTabIndex = 0;
    1460 
    1461         // Go to the first node in the document that has the desired tab index
    1462         for (n = this; n != 0; n = n->traverseNextNode()) {
    1463             if (n->isKeyboardFocusable() && (n->tabIndex() == lowestTabIndex))
    1464                 return n;
    1465         }
    1466 
    1467         return 0;
     1405        // No starting node supplied; begin with the top of the document
     1406        NodeImpl *n;
     1407
     1408        int lowestTabIndex = 65535;
     1409        for (n = this; n != 0; n = n->traverseNextNode()) {
     1410            if (n->isKeyboardFocusable()) {
     1411                if ((n->tabIndex() > 0) && (n->tabIndex() < lowestTabIndex))
     1412                    lowestTabIndex = n->tabIndex();
     1413            }
     1414        }
     1415
     1416        if (lowestTabIndex == 65535)
     1417            lowestTabIndex = 0;
     1418
     1419        // Go to the first node in the document that has the desired tab index
     1420        for (n = this; n != 0; n = n->traverseNextNode()) {
     1421            if (n->isKeyboardFocusable() && (n->tabIndex() == lowestTabIndex))
     1422                return n;
     1423        }
     1424
     1425        return 0;
    14681426    }
    14691427    else {
    1470         fromTabIndex = fromNode->tabIndex();
     1428        fromTabIndex = fromNode->tabIndex();
    14711429    }
    14721430
    14731431    if (fromTabIndex == 0) {
    1474         // Just need to find the next selectable node after fromNode (in document order) that doesn't have a tab index
    1475         NodeImpl *n = fromNode->traverseNextNode();
    1476         while (n && !(n->isKeyboardFocusable() && n->tabIndex() == 0))
    1477             n = n->traverseNextNode();
    1478         return n;
     1432        // Just need to find the next selectable node after fromNode (in document order) that doesn't have a tab index
     1433        NodeImpl *n = fromNode->traverseNextNode();
     1434        while (n && !(n->isKeyboardFocusable() && n->tabIndex() == 0))
     1435            n = n->traverseNextNode();
     1436        return n;
    14791437    }
    14801438    else {
    1481         // Find the lowest tab index out of all the nodes except fromNode, that is greater than or equal to fromNode's
    1482         // tab index. For nodes with the same tab index as fromNode, we are only interested in those that come after
    1483         // fromNode in document order.
    1484         // If we don't find a suitable tab index, the next focus node will be one with a tab index of 0.
    1485         unsigned short lowestSuitableTabIndex = 65535;
    1486         NodeImpl *n;
    1487 
    1488         bool reachedFromNode = false;
    1489         for (n = this; n != 0; n = n->traverseNextNode()) {
    1490             if (n->isKeyboardFocusable() &&
    1491                 ((reachedFromNode && (n->tabIndex() >= fromTabIndex)) ||
    1492                 (!reachedFromNode && (n->tabIndex() > fromTabIndex))) &&
    1493                 (n->tabIndex() < lowestSuitableTabIndex) &&
    1494                 (n != fromNode)) {
    1495 
    1496                 // We found a selectable node with a tab index at least as high as fromNode's. Keep searching though,
    1497                 // as there may be another node which has a lower tab index but is still suitable for use.
    1498                 lowestSuitableTabIndex = n->tabIndex();
    1499             }
    1500 
    1501             if (n == fromNode)
    1502                 reachedFromNode = true;
    1503         }
    1504 
    1505         if (lowestSuitableTabIndex == 65535) {
    1506             // No next node with a tab index -> just take first node with tab index of 0
    1507             NodeImpl *n = this;
    1508             while (n && !(n->isKeyboardFocusable() && n->tabIndex() == 0))
    1509                 n = n->traverseNextNode();
    1510             return n;
    1511         }
    1512 
    1513         // Search forwards from fromNode
    1514         for (n = fromNode->traverseNextNode(); n != 0; n = n->traverseNextNode()) {
    1515             if (n->isKeyboardFocusable() && (n->tabIndex() == lowestSuitableTabIndex))
    1516                 return n;
    1517         }
    1518 
    1519         // The next node isn't after fromNode, start from the beginning of the document
    1520         for (n = this; n != fromNode; n = n->traverseNextNode()) {
    1521             if (n->isKeyboardFocusable() && (n->tabIndex() == lowestSuitableTabIndex))
    1522                 return n;
    1523         }
    1524 
    1525         assert(false); // should never get here
    1526         return 0;
     1439        // Find the lowest tab index out of all the nodes except fromNode, that is greater than or equal to fromNode's
     1440        // tab index. For nodes with the same tab index as fromNode, we are only interested in those that come after
     1441        // fromNode in document order.
     1442        // If we don't find a suitable tab index, the next focus node will be one with a tab index of 0.
     1443        unsigned short lowestSuitableTabIndex = 65535;
     1444        NodeImpl *n;
     1445
     1446        bool reachedFromNode = false;
     1447        for (n = this; n != 0; n = n->traverseNextNode()) {
     1448            if (n->isKeyboardFocusable() &&
     1449                ((reachedFromNode && (n->tabIndex() >= fromTabIndex)) ||
     1450                (!reachedFromNode && (n->tabIndex() > fromTabIndex))) &&
     1451                (n->tabIndex() < lowestSuitableTabIndex) &&
     1452                (n != fromNode)) {
     1453
     1454                // We found a selectable node with a tab index at least as high as fromNode's. Keep searching though,
     1455                // as there may be another node which has a lower tab index but is still suitable for use.
     1456                lowestSuitableTabIndex = n->tabIndex();
     1457            }
     1458
     1459            if (n == fromNode)
     1460                reachedFromNode = true;
     1461        }
     1462
     1463        if (lowestSuitableTabIndex == 65535) {
     1464            // No next node with a tab index -> just take first node with tab index of 0
     1465            NodeImpl *n = this;
     1466            while (n && !(n->isKeyboardFocusable() && n->tabIndex() == 0))
     1467                n = n->traverseNextNode();
     1468            return n;
     1469        }
     1470
     1471        // Search forwards from fromNode
     1472        for (n = fromNode->traverseNextNode(); n != 0; n = n->traverseNextNode()) {
     1473            if (n->isKeyboardFocusable() && (n->tabIndex() == lowestSuitableTabIndex))
     1474                return n;
     1475        }
     1476
     1477        // The next node isn't after fromNode, start from the beginning of the document
     1478        for (n = this; n != fromNode; n = n->traverseNextNode()) {
     1479            if (n->isKeyboardFocusable() && (n->tabIndex() == lowestSuitableTabIndex))
     1480                return n;
     1481        }
     1482
     1483        assert(false); // should never get here
     1484        return 0;
    15271485    }
    15281486}
     
    15321490    NodeImpl *lastNode = this;
    15331491    while (lastNode->lastChild())
    1534         lastNode = lastNode->lastChild();
     1492        lastNode = lastNode->lastChild();
    15351493
    15361494    if (!fromNode) {
    1537         // No starting node supplied; begin with the very last node in the document
    1538         NodeImpl *n;
    1539 
    1540         int highestTabIndex = 0;
    1541         for (n = lastNode; n != 0; n = n->traversePreviousNode()) {
    1542             if (n->isKeyboardFocusable()) {
    1543                 if (n->tabIndex() == 0)
    1544                     return n;
    1545                 else if (n->tabIndex() > highestTabIndex)
    1546                     highestTabIndex = n->tabIndex();
    1547             }
    1548         }
    1549 
    1550         // No node with a tab index of 0; just go to the last node with the highest tab index
    1551         for (n = lastNode; n != 0; n = n->traversePreviousNode()) {
    1552             if (n->isKeyboardFocusable() && (n->tabIndex() == highestTabIndex))
    1553                 return n;
    1554         }
    1555 
    1556         return 0;
     1495        // No starting node supplied; begin with the very last node in the document
     1496        NodeImpl *n;
     1497
     1498        int highestTabIndex = 0;
     1499        for (n = lastNode; n != 0; n = n->traversePreviousNode()) {
     1500            if (n->isKeyboardFocusable()) {
     1501                if (n->tabIndex() == 0)
     1502                    return n;
     1503                else if (n->tabIndex() > highestTabIndex)
     1504                    highestTabIndex = n->tabIndex();
     1505            }
     1506        }
     1507
     1508        // No node with a tab index of 0; just go to the last node with the highest tab index
     1509        for (n = lastNode; n != 0; n = n->traversePreviousNode()) {
     1510            if (n->isKeyboardFocusable() && (n->tabIndex() == highestTabIndex))
     1511                return n;
     1512        }
     1513
     1514        return 0;
    15571515    }
    15581516    else {
    1559         unsigned short fromTabIndex = fromNode->tabIndex();
    1560 
    1561         if (fromTabIndex == 0) {
    1562             // Find the previous selectable node before fromNode (in document order) that doesn't have a tab index
    1563             NodeImpl *n = fromNode->traversePreviousNode();
    1564             while (n && !(n->isKeyboardFocusable() && n->tabIndex() == 0))
    1565                 n = n->traversePreviousNode();
    1566             if (n)
    1567                 return n;
    1568 
    1569             // No previous nodes with a 0 tab index, go to the last node in the document that has the highest tab index
    1570             int highestTabIndex = 0;
    1571             for (n = this; n != 0; n = n->traverseNextNode()) {
    1572                 if (n->isKeyboardFocusable() && (n->tabIndex() > highestTabIndex))
    1573                     highestTabIndex = n->tabIndex();
    1574             }
    1575 
    1576             if (highestTabIndex == 0)
    1577                 return 0;
    1578 
    1579             for (n = lastNode; n != 0; n = n->traversePreviousNode()) {
    1580                 if (n->isKeyboardFocusable() && (n->tabIndex() == highestTabIndex))
    1581                     return n;
    1582             }
    1583 
    1584             assert(false); // should never get here
    1585             return 0;
    1586         }
    1587         else {
    1588             // Find the lowest tab index out of all the nodes except fromNode, that is less than or equal to fromNode's
    1589             // tab index. For nodes with the same tab index as fromNode, we are only interested in those before
    1590             // fromNode.
    1591             // If we don't find a suitable tab index, then there will be no previous focus node.
    1592             unsigned short highestSuitableTabIndex = 0;
    1593             NodeImpl *n;
    1594 
    1595             bool reachedFromNode = false;
    1596             for (n = this; n != 0; n = n->traverseNextNode()) {
    1597                 if (n->isKeyboardFocusable() &&
    1598                     ((!reachedFromNode && (n->tabIndex() <= fromTabIndex)) ||
    1599                      (reachedFromNode && (n->tabIndex() < fromTabIndex)))  &&
    1600                     (n->tabIndex() > highestSuitableTabIndex) &&
    1601                     (n != fromNode)) {
    1602 
    1603                     // We found a selectable node with a tab index no higher than fromNode's. Keep searching though, as
    1604                     // there may be another node which has a higher tab index but is still suitable for use.
    1605                     highestSuitableTabIndex = n->tabIndex();
    1606                 }
    1607 
    1608                 if (n == fromNode)
    1609                     reachedFromNode = true;
    1610             }
    1611 
    1612             if (highestSuitableTabIndex == 0) {
    1613                 // No previous node with a tab index. Since the order specified by HTML is nodes with tab index > 0
    1614                 // first, this means that there is no previous node.
    1615                 return 0;
    1616             }
    1617 
    1618             // Search backwards from fromNode
    1619             for (n = fromNode->traversePreviousNode(); n != 0; n = n->traversePreviousNode()) {
    1620                 if (n->isKeyboardFocusable() && (n->tabIndex() == highestSuitableTabIndex))
    1621                     return n;
    1622             }
    1623             // The previous node isn't before fromNode, start from the end of the document
    1624             for (n = lastNode; n != fromNode; n = n->traversePreviousNode()) {
    1625                 if (n->isKeyboardFocusable() && (n->tabIndex() == highestSuitableTabIndex))
    1626                     return n;
    1627             }
    1628 
    1629             assert(false); // should never get here
    1630             return 0;
    1631         }
     1517        unsigned short fromTabIndex = fromNode->tabIndex();
     1518
     1519        if (fromTabIndex == 0) {
     1520            // Find the previous selectable node before fromNode (in document order) that doesn't have a tab index
     1521            NodeImpl *n = fromNode->traversePreviousNode();
     1522            while (n && !(n->isKeyboardFocusable() && n->tabIndex() == 0))
     1523                n = n->traversePreviousNode();
     1524            if (n)
     1525                return n;
     1526
     1527            // No previous nodes with a 0 tab index, go to the last node in the document that has the highest tab index
     1528            int highestTabIndex = 0;
     1529            for (n = this; n != 0; n = n->traverseNextNode()) {
     1530                if (n->isKeyboardFocusable() && (n->tabIndex() > highestTabIndex))
     1531                    highestTabIndex = n->tabIndex();
     1532            }
     1533
     1534            if (highestTabIndex == 0)
     1535                return 0;
     1536
     1537            for (n = lastNode; n != 0; n = n->traversePreviousNode()) {
     1538                if (n->isKeyboardFocusable() && (n->tabIndex() == highestTabIndex))
     1539                    return n;
     1540            }
     1541
     1542            assert(false); // should never get here
     1543            return 0;
     1544        }
     1545        else {
     1546            // Find the lowest tab index out of all the nodes except fromNode, that is less than or equal to fromNode's
     1547            // tab index. For nodes with the same tab index as fromNode, we are only interested in those before
     1548            // fromNode.
     1549            // If we don't find a suitable tab index, then there will be no previous focus node.
     1550            unsigned short highestSuitableTabIndex = 0;
     1551            NodeImpl *n;
     1552
     1553            bool reachedFromNode = false;
     1554            for (n = this; n != 0; n = n->traverseNextNode()) {
     1555                if (n->isKeyboardFocusable() &&
     1556                    ((!reachedFromNode && (n->tabIndex() <= fromTabIndex)) ||
     1557                     (reachedFromNode && (n->tabIndex() < fromTabIndex)))  &&
     1558                    (n->tabIndex() > highestSuitableTabIndex) &&
     1559                    (n != fromNode)) {
     1560
     1561                    // We found a selectable node with a tab index no higher than fromNode's. Keep searching though, as
     1562                    // there may be another node which has a higher tab index but is still suitable for use.
     1563                    highestSuitableTabIndex = n->tabIndex();
     1564                }
     1565
     1566                if (n == fromNode)
     1567                    reachedFromNode = true;
     1568            }
     1569
     1570            if (highestSuitableTabIndex == 0) {
     1571                // No previous node with a tab index. Since the order specified by HTML is nodes with tab index > 0
     1572                // first, this means that there is no previous node.
     1573                return 0;
     1574            }
     1575
     1576            // Search backwards from fromNode
     1577            for (n = fromNode->traversePreviousNode(); n != 0; n = n->traversePreviousNode()) {
     1578                if (n->isKeyboardFocusable() && (n->tabIndex() == highestSuitableTabIndex))
     1579                    return n;
     1580            }
     1581            // The previous node isn't before fromNode, start from the end of the document
     1582            for (n = lastNode; n != fromNode; n = n->traversePreviousNode()) {
     1583                if (n->isKeyboardFocusable() && (n->tabIndex() == highestSuitableTabIndex))
     1584                    return n;
     1585            }
     1586
     1587            assert(false); // should never get here
     1588            return 0;
     1589        }
    16321590    }
    16331591}
     
    16391597    int absIndex = 0;
    16401598    for (NodeImpl *n = node; n && n != this; n = n->traversePreviousNode())
    1641         absIndex++;
     1599        absIndex++;
    16421600    return absIndex;
    16431601}
     
    16471605    NodeImpl *n = this;
    16481606    for (int i = 0; n && (i < absIndex); i++) {
    1649         n = n->traverseNextNode();
     1607        n = n->traverseNextNode();
    16501608    }
    16511609    return n;
     
    16811639            bool ok = false;
    16821640            int delay = 0;
    1683             delay = str.toInt(&ok);
    1684             // We want a new history item if the refresh timeout > 1 second
    1685             if(ok && frame) frame->scheduleRedirection(delay, frame->url().url(), delay <= 1);
     1641            delay = str.toInt(&ok);
     1642            // We want a new history item if the refresh timeout > 1 second
     1643            if(ok && frame) frame->scheduleRedirection(delay, frame->url().url(), delay <= 1);
    16861644        } else {
    16871645            double delay = 0;
    16881646            bool ok = false;
    1689             delay = str.left(pos).stripWhiteSpace().toDouble(&ok);
     1647            delay = str.left(pos).stripWhiteSpace().toDouble(&ok);
    16901648
    16911649            pos++;
     
    18841842    NodeImpl *n;
    18851843    for (n = this; n; n = n->traverseNextNode()) {
    1886         StyleSheetImpl *sheet = 0;
     1844        StyleSheetImpl *sheet = 0;
    18871845
    18881846        if (n->nodeType() == Node::PROCESSING_INSTRUCTION_NODE)
     
    20061964    QPtrListIterator<StyleSheetImpl> it(oldStyleSheets);
    20071965    for (; it.current(); ++it)
    2008         it.current()->deref();
     1966        it.current()->deref();
    20091967
    20101968    // Create a new style selector
     
    20121970    QString usersheet = m_usersheet;
    20131971    if ( m_view && m_view->mediaType() == "print" )
    2014         usersheet += m_printSheet;
     1972        usersheet += m_printSheet;
    20151973    m_styleSelector = new CSSStyleSelector(this, usersheet, m_styleSheets, !inCompatMode());
    20161974    m_styleSelector->setEncodedURL(m_url);
     
    22742232    // If we already have it we don't want removeWindowEventListener to delete it
    22752233    if (listener)
    2276         listener->ref();
     2234        listener->ref();
    22772235    removeHTMLWindowEventListener(eventType);
    22782236    if (listener) {
    2279         addWindowEventListener(eventType, listener, false);
    2280         listener->deref();
     2237        addWindowEventListener(eventType, listener, false);
     2238        listener->deref();
    22812239    }
    22822240}
     
    22862244    QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);
    22872245    for (; it.current(); ++it)
    2288         if (it.current()->eventType() == eventType && it.current()->listener()->eventListenerType() == "_khtml_HTMLEventListener")
    2289             return it.current()->listener();
     2246        if (it.current()->eventType() == eventType && it.current()->listener()->eventListenerType() == "_khtml_HTMLEventListener")
     2247            return it.current()->listener();
    22902248    return 0;
    22912249}
     
    22952253    QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);
    22962254    for (; it.current(); ++it)
    2297         if (it.current()->eventType() == eventType && it.current()->listener()->eventListenerType() == "_khtml_HTMLEventListener") {
    2298             m_windowEventListeners.removeRef(it.current());
    2299             return;
    2300         }
     2255        if (it.current()->eventType() == eventType && it.current()->listener()->eventListenerType() == "_khtml_HTMLEventListener") {
     2256            m_windowEventListeners.removeRef(it.current());
     2257            return;
     2258        }
    23012259}
    23022260
     
    23282286    QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);
    23292287    for (; it.current(); ++it) {
    2330         if (it.current()->eventType() == eventType) {
    2331             return true;
    2332         }
     2288        if (it.current()->eventType() == eventType) {
     2289            return true;
     2290        }
    23332291    }
    23342292
     
    23392297{
    23402298    if (frame()) {
    2341         return frame()->createHTMLEventListener(code, node);
     2299        return frame()->createHTMLEventListener(code, node);
    23422300    } else {
    2343         return NULL;
     2301        return NULL;
    23442302    }
    23452303}
     
    26542612
    26552613    for (NodeImpl *child = firstChild(); child != NULL; child = child->nextSibling()) {
    2656         result += child->toString();
     2614        result += child->toString();
    26572615    }
    26582616
  • trunk/WebCore/khtml/xml/DocumentImpl.h

    r12101 r12114  
    2727#define DOM_DocumentImpl_h
    2828
     29#include "KWQSignal.h"
     30#include "Shared.h"
     31#include "decoder.h"
     32#include "xml/dom2_traversalimpl.h"
    2933#include "xml/dom_elementimpl.h"
    30 #include "xml/dom2_traversalimpl.h"
    31 #include "Shared.h"
    32 
     34#include <kurl.h>
     35#include <kxmlcore/HashCountedSet.h>
     36#include <kxmlcore/HashMap.h>
     37#include <qcolor.h>
     38#include <qdatetime.h>
     39#include <qmap.h>
     40#include <qobject.h>
     41#include <qptrdict.h>
     42#include <qptrlist.h>
    3343#include <qstringlist.h>
    34 #include <qptrlist.h>
    35 #include <qobject.h>
    36 #include <qdict.h>
    37 #include <qptrdict.h>
    38 #include <qmap.h>
    39 #include <qdatetime.h>
    40 #include <qcolor.h>
    41 
    42 #include <kurl.h>
    43 
    44 #include "KWQSignal.h"
    45 #include "decoder.h"
    46 
    47 #include <kxmlcore/HashMap.h>
    48 
     44
     45class Frame;
     46class KHTMLView;
     47class KWQAccObjectCache;
    4948class QPaintDevice;
    5049class QPaintDeviceMetrics;
    51 class KHTMLView;
    52 class Frame;
    5350class RenderArena;
    54 
    55 class KWQAccObjectCache;
    5651
    5752namespace khtml {
    5853    class CSSStyleSelector;
    59     struct DashboardRegionValue;
    6054    class DocLoader;
    6155    class Tokenizer;
     56    struct DashboardRegionValue;
    6257}
    6358
     
    742737    RefPtr<khtml::Decoder> m_decoder;
    743738
    744     mutable QDict<ElementImpl> m_elementsById;
    745     mutable QDict<char> m_idCount;
    746    
    747     QDict<ElementImpl> m_elementsByAccessKey;
    748     bool m_accessKeyDictValid;
     739    mutable HashMap<DOMStringImpl*, ElementImpl*> m_elementsById;
     740    mutable HashCountedSet<DOMStringImpl*> m_idCount;
     741   
     742    HashMap<DOMStringImpl*, ElementImpl*, CaseInsensitiveHash> m_elementsByAccessKey;
     743    bool m_accessKeyMapValid;
    749744 
    750745    bool m_createRenderers;
  • trunk/WebCore/ksvg2/svg/SVGDocumentImpl.cpp

    r12101 r12114  
    2323#include "config.h"
    2424#include <assert.h>
    25 
    26 #include <q3dict.h>
    2725
    2826#include <kurl.h>
  • trunk/WebCore/kwq/KWQKURL.h

    r11990 r12114  
    5252    bool hasPath() const;
    5353
    54     QString canonicalURL() const;
    5554    QString url() const { return urlString; }
    5655
     
    9493    void parse(const char *url, const QString *originalString);
    9594
    96 #ifdef CONSTRUCT_CANONICAL_STRING
    97     QString _path() const;
    98     QString _user() const;
    99     QString _pass() const;
    100     QString _host() const;
    101 #endif
    102    
    10395    QString urlString;
    10496    bool m_isValid;
  • trunk/WebCore/kwq/KWQKURL.mm

    • Property allow-tabs deleted
    r12086 r12114  
    238238KURL::KURL(const char *url)
    239239{
    240     if (url != NULL && url[0] == '/') {
     240    if (url && url[0] == '/') {
    241241        char staticBuffer[2048];
    242242        char *buffer;
     
    254254        buffer[4] = ':';
    255255        memcpy(&buffer[5], url, urlLength);
    256         parse(buffer, NULL);
     256        parse(buffer, 0);
    257257        if (buffer != staticBuffer) {
    258258            fastFree(buffer);
    259259        }
    260260    } else {
    261         parse(url, NULL);
     261        parse(url, 0);
    262262    }
    263263}
     
    280280        buffer[4] = ':';
    281281        url.copyLatin1(&buffer[5]);
    282         parse(buffer, NULL);
     282        parse(buffer, 0);
    283283        if (buffer != staticBuffer) {
    284284            fastFree(buffer);
    285285        }
    286286    } else {
    287         parse(url.ascii(), &url);
     287        parse(url.ascii(), &url);
    288288    }
    289289}
     
    292292{
    293293    if (url) {
    294         CFIndex bytesLength = CFURLGetBytes((CFURLRef)url, NULL, 0);
     294        CFIndex bytesLength = CFURLGetBytes((CFURLRef)url, 0, 0);
    295295        size_t bufferLength = bytesLength + 6; // 5 for "file:", 1 for NUL terminator
    296296        char staticBuffer[2048];
     
    303303        char *bytes = &buffer[5];
    304304        CFURLGetBytes((CFURLRef)url, (UInt8 *)bytes, bytesLength);
    305         bytes[bytesLength] = '\0';
     305        bytes[bytesLength] = '\0';
    306306        if (bytes[0] == '/') {
    307307            buffer[0] = 'f';
     
    310310            buffer[3] = 'e';
    311311            buffer[4] = ':';
    312             parse(buffer, NULL);
     312            parse(buffer, 0);
    313313        } else {
    314             parse(bytes, NULL);
     314            parse(bytes, 0);
    315315        }
    316316        if (buffer != staticBuffer) {
     
    319319    }
    320320    else {
    321         parse("", NULL);
     321        parse("", 0);
    322322    }
    323323}
     
    337337    bool containsBackslash = relative.contains('\\');
    338338    if (containsBackslash) {
    339         substitutedRelative = substituteBackslashes(relative);
     339        substitutedRelative = substituteBackslashes(relative);
    340340    }
    341341
     
    397397
    398398    if (absolute) {
    399         parse(str, (allASCII && !strippedStart && (charsToChopOffEnd == 0)) ? &rel : 0);
     399        parse(str, (allASCII && !strippedStart && (charsToChopOffEnd == 0)) ? &rel : 0);
    400400    } else {
    401         // if the base is invalid, just append the relative
    402         // portion. The RFC does not specify what to do in this case.
    403         if (!base.m_isValid) {
    404             QString newURL = base.urlString + str;
    405             parse(newURL.ascii(), &newURL);
     401        // if the base is invalid, just append the relative
     402        // portion. The RFC does not specify what to do in this case.
     403        if (!base.m_isValid) {
     404            QString newURL = base.urlString + str;
     405            parse(newURL.ascii(), &newURL);
    406406            if (strBuffer) {
    407407                fastFree(strBuffer);
    408408            }
    409409            return;
    410         }
    411 
    412         switch(str[0]) {
    413         case '\0':
    414             // the reference must be empty - the RFC says this is a
    415             // reference to the same document
    416             {
    417                 *this = base;
    418                 break;
    419             }
    420         case '#':
    421             // must be fragment-only reference
    422             {
    423                 QString newURL = base.urlString.left(base.queryEndPos) + str;
    424                 parse(newURL.ascii(), &newURL);
    425                 break;
    426             }
    427         case '?':
     410        }
     411
     412        switch(str[0]) {
     413        case '\0':
     414            // the reference must be empty - the RFC says this is a
     415            // reference to the same document
     416            {
     417                *this = base;
     418                break;
     419            }
     420        case '#':
     421            // must be fragment-only reference
     422            {
     423                QString newURL = base.urlString.left(base.queryEndPos) + str;
     424                parse(newURL.ascii(), &newURL);
     425                break;
     426            }
     427        case '?':
    428428            // query-only reference, special case needed for non-URL results
    429             {
    430                 QString newURL = base.urlString.left(base.pathEndPos) + str;
    431                 parse(newURL.ascii(), &newURL);
    432                 break;
    433             }
    434         case '/':
    435             // must be net-path or absolute-path reference
    436             {
    437                 if (str[1] == '/') {
    438                     // net-path
    439                     QString newURL = base.urlString.left(base.schemeEndPos + 1) + str;
    440                     parse(newURL.ascii(), &newURL);
    441                 } else {
    442                     // abs-path
    443                     QString newURL = base.urlString.left(base.portEndPos) + str;
    444                     parse(newURL.ascii(), &newURL);
    445                 }
    446                 break;
    447             }
    448         default:
    449             {
    450                 // must be relative-path reference
    451 
    452                 char staticBuffer[2048];
    453                 char *buffer;
    454                
     429            {
     430                QString newURL = base.urlString.left(base.pathEndPos) + str;
     431                parse(newURL.ascii(), &newURL);
     432                break;
     433            }
     434        case '/':
     435            // must be net-path or absolute-path reference
     436            {
     437                if (str[1] == '/') {
     438                    // net-path
     439                    QString newURL = base.urlString.left(base.schemeEndPos + 1) + str;
     440                    parse(newURL.ascii(), &newURL);
     441                } else {
     442                    // abs-path
     443                    QString newURL = base.urlString.left(base.portEndPos) + str;
     444                    parse(newURL.ascii(), &newURL);
     445                }
     446                break;
     447            }
     448        default:
     449            {
     450                // must be relative-path reference
     451
     452                char staticBuffer[2048];
     453                char *buffer;
     454               
    455455                // Base part plus relative part plus one possible slash added in between plus terminating \0 byte.
    456                 size_t bufferLength = base.pathEndPos + 1 + strlen(str) + 1;
    457 
    458                 if (bufferLength > sizeof(staticBuffer)) {
    459                     buffer = (char *)fastMalloc(bufferLength);
    460                 } else {
    461                     buffer = staticBuffer;
    462                 }
    463                
    464                 char *bufferPos = buffer;
    465                
    466                 // first copy everything before the path from the base
    467                 const char *baseString = base.urlString.ascii();
    468                 const char *baseStringStart = baseString;
    469                 const char *pathStart = baseStringStart + base.portEndPos;
    470                 while (baseStringStart < pathStart) {
    471                     *bufferPos++ = *baseStringStart++;
    472                 }
     456                size_t bufferLength = base.pathEndPos + 1 + strlen(str) + 1;
     457
     458                if (bufferLength > sizeof(staticBuffer)) {
     459                    buffer = (char *)fastMalloc(bufferLength);
     460                } else {
     461                    buffer = staticBuffer;
     462                }
     463               
     464                char *bufferPos = buffer;
     465               
     466                // first copy everything before the path from the base
     467                const char *baseString = base.urlString.ascii();
     468                const char *baseStringStart = baseString;
     469                const char *pathStart = baseStringStart + base.portEndPos;
     470                while (baseStringStart < pathStart) {
     471                    *bufferPos++ = *baseStringStart++;
     472                }
    473473                char *bufferPathStart = bufferPos;
    474474
    475                 // now copy the base path
    476                 const char *baseStringEnd = baseString + base.pathEndPos;
    477                
    478                 // go back to the last slash
    479                 while (baseStringEnd > baseStringStart && baseStringEnd[-1] != '/') {
    480                     baseStringEnd--;
    481                 }
    482                
    483                 if (baseStringEnd == baseStringStart) {
     475                // now copy the base path
     476                const char *baseStringEnd = baseString + base.pathEndPos;
     477               
     478                // go back to the last slash
     479                while (baseStringEnd > baseStringStart && baseStringEnd[-1] != '/') {
     480                    baseStringEnd--;
     481                }
     482               
     483                if (baseStringEnd == baseStringStart) {
    484484                    // no path in base, add a path separator if necessary
    485485                    if (base.schemeEndPos + 1 != base.pathEndPos && *str != '\0' && *str != '?' && *str != '#') {
     
    490490                }
    491491
    492                 const char *relStringStart = str;
    493                 const char *relStringPos = relStringStart;
    494                
    495                 while (*relStringPos != '\0' && *relStringPos != '?' && *relStringPos != '#') {
    496                     if (relStringPos[0] == '.' && bufferPos[-1] == '/') {
    497                         if (isPathSegmentEndChar(relStringPos[1])) {
    498                             // skip over "." segment
    499                             relStringPos += 1;
    500                             if (relStringPos[0] == '/') {
    501                                 relStringPos++;
    502                             }
    503                             continue;
    504                         } else if (relStringPos[1] == '.' && isPathSegmentEndChar(relStringPos[2])) {
    505                             // skip over ".." segment and rewind the last segment
    506                             // the RFC leaves it up to the app to decide what to do with excess
    507                             // ".." segments - we choose to drop them since some web content
    508                             // relies on this.
    509                             relStringPos += 2;
    510                             if (relStringPos[0] == '/') {
    511                                 relStringPos++;
    512                             }
    513                             if (bufferPos > bufferPathStart + 1) {
    514                                 bufferPos--;
    515                             }
    516                             while (bufferPos > bufferPathStart + 1  && bufferPos[-1] != '/') {
    517                                 bufferPos--;
    518                             }
    519                             continue;
    520                         }
    521                     }
    522                    
    523                     *bufferPos = *relStringPos;
    524                     relStringPos++;
    525                     bufferPos++;
    526                 }
    527 
    528                 // all done with the path work, now copy any remainder
    529                 // of the relative reference; this will also add a null terminator
    530                 strcpy(bufferPos, relStringPos);
    531 
    532                 parse(buffer, NULL);
     492                const char *relStringStart = str;
     493                const char *relStringPos = relStringStart;
     494               
     495                while (*relStringPos != '\0' && *relStringPos != '?' && *relStringPos != '#') {
     496                    if (relStringPos[0] == '.' && bufferPos[-1] == '/') {
     497                        if (isPathSegmentEndChar(relStringPos[1])) {
     498                            // skip over "." segment
     499                            relStringPos += 1;
     500                            if (relStringPos[0] == '/') {
     501                                relStringPos++;
     502                            }
     503                            continue;
     504                        } else if (relStringPos[1] == '.' && isPathSegmentEndChar(relStringPos[2])) {
     505                            // skip over ".." segment and rewind the last segment
     506                            // the RFC leaves it up to the app to decide what to do with excess
     507                            // ".." segments - we choose to drop them since some web content
     508                            // relies on this.
     509                            relStringPos += 2;
     510                            if (relStringPos[0] == '/') {
     511                                relStringPos++;
     512                            }
     513                            if (bufferPos > bufferPathStart + 1) {
     514                                bufferPos--;
     515                            }
     516                            while (bufferPos > bufferPathStart + 1  && bufferPos[-1] != '/') {
     517                                bufferPos--;
     518                            }
     519                            continue;
     520                        }
     521                    }
     522                   
     523                    *bufferPos = *relStringPos;
     524                    relStringPos++;
     525                    bufferPos++;
     526                }
     527
     528                // all done with the path work, now copy any remainder
     529                // of the relative reference; this will also add a null terminator
     530                strcpy(bufferPos, relStringPos);
     531
     532                parse(buffer, 0);
    533533               
    534534                ASSERT(strlen(buffer) + 1 <= bufferLength);
    535                
    536                 if (buffer != staticBuffer) {
    537                     fastFree(buffer);
    538                 }
    539                
    540                 break;
    541             }
    542         }
     535               
     536                if (buffer != staticBuffer) {
     537                    fastFree(buffer);
     538                }
     539               
     540                break;
     541            }
     542        }
    543543    }
    544544   
     
    556556{
    557557    if (!m_isValid) {
    558         return QString();
     558        return QString();
    559559    }
    560560
     
    565565{
    566566    if (!m_isValid) {
    567         return QString();
     567        return QString();
    568568    }
    569569
     
    575575{
    576576    if (!m_isValid) {
    577         return 0;
     577        return 0;
    578578    }
    579579
    580580    if (hostEndPos != portEndPos) {
    581         bool ok;
    582         unsigned short result = urlString.mid(hostEndPos + 1, portEndPos - hostEndPos - 1).toUShort(&ok);
    583         if (!ok) {
    584             result = 0;
    585         }
    586         return result;
     581        bool ok;
     582        unsigned short result = urlString.mid(hostEndPos + 1, portEndPos - hostEndPos - 1).toUShort(&ok);
     583        if (!ok) {
     584            result = 0;
     585        }
     586        return result;
    587587    }
    588588
     
    593593{
    594594    if (!m_isValid) {
    595         return QString();
     595        return QString();
    596596    }
    597597
    598598    if (passwordEndPos == userEndPos) {
    599         return QString();
     599        return QString();
    600600    }
    601601
     
    606606{
    607607    if (!m_isValid) {
    608         return QString();
     608        return QString();
    609609    }
    610610
     
    615615{
    616616    if (!m_isValid || fragmentEndPos == queryEndPos) {
    617         return QString();
     617        return QString();
    618618    }
    619619
     
    629629{
    630630    if (!m_isValid) {
    631         return QString();
     631        return QString();
    632632    }
    633633
     
    638638{
    639639    if (!m_isValid) {
    640         return QString();
     640        return QString();
    641641    }
    642642
     
    644644}
    645645
    646 #ifdef CONSTRUCT_CANONICAL_STRING
    647 QString KURL::_path() const
     646void KURL::setProtocol(const QString &s)
    648647{
    649648    if (!m_isValid) {
    650         return QString();
    651     }
    652 
    653     return urlString.mid(portEndPos, pathEndPos - portEndPos);
    654 }
    655 
    656 QString KURL::_user() const
    657 {
    658     if (!m_isValid) {
    659         return QString();
    660     }
    661 
    662     return urlString.mid(userStartPos, userEndPos - userStartPos);
    663 }
    664 
    665 QString KURL::_pass() const
    666 {
    667     if (!m_isValid) {
    668         return QString();
    669     }
    670 
    671     if (passwordEndPos == userEndPos) {
    672         return QString();
    673     }
    674 
    675     return urlString.mid(userEndPos + 1, passwordEndPos - userEndPos - 1);
    676 }
    677 
    678 QString KURL::_host() const
    679 {
    680     if (!m_isValid) {
    681         return QString();
    682     }
    683 
    684     int start = (passwordEndPos == userStartPos) ? passwordEndPos : passwordEndPos + 1;
    685     return urlString.mid(start, hostEndPos - start);
    686 }
    687 
    688 #endif
    689 
    690 void KURL::setProtocol(const QString &s)
    691 {
    692     if (!m_isValid) {
    693         QString newURL = s + ":" + urlString;
    694         parse(newURL.ascii(), &newURL);
    695         return;
     649        QString newURL = s + ":" + urlString;
     650        parse(newURL.ascii(), &newURL);
     651        return;
    696652    }
    697653
     
    703659{
    704660    if (m_isValid) {
    705         bool slashSlashNeeded = userStartPos == schemeEndPos + 1;
    706         int hostStart = (passwordEndPos == userStartPos) ? passwordEndPos : passwordEndPos + 1;
    707        
    708         QString newURL = urlString.left(hostStart) + (slashSlashNeeded ? "//" : QString()) + s + urlString.mid(hostEndPos);
    709         parse(newURL.ascii(), &newURL);
     661        bool slashSlashNeeded = userStartPos == schemeEndPos + 1;
     662        int hostStart = (passwordEndPos == userStartPos) ? passwordEndPos : passwordEndPos + 1;
     663       
     664        QString newURL = urlString.left(hostStart) + (slashSlashNeeded ? "//" : QString()) + s + urlString.mid(hostEndPos);
     665        parse(newURL.ascii(), &newURL);
    710666    }
    711667}
     
    714670{
    715671    if (m_isValid) {
    716         bool colonNeeded = portEndPos == hostEndPos;
    717         int portStart = (colonNeeded ? hostEndPos : hostEndPos + 1);
    718         QString newURL = urlString.left(portStart) + (colonNeeded ? ":" : QString()) + QString::number(i) + urlString.mid(portEndPos);
    719         parse(newURL.ascii(), &newURL);
     672        bool colonNeeded = portEndPos == hostEndPos;
     673        int portStart = (colonNeeded ? hostEndPos : hostEndPos + 1);
     674        QString newURL = urlString.left(portStart) + (colonNeeded ? ":" : QString()) + QString::number(i) + urlString.mid(portEndPos);
     675        parse(newURL.ascii(), &newURL);
    720676    }
    721677}
     
    782738{
    783739    if (m_isValid) {
    784         QString newURL = urlString.left(queryEndPos) + (s.isEmpty() ? QString() : "#" + s);
    785         parse(newURL.ascii(), &newURL);
     740        QString newURL = urlString.left(queryEndPos) + (s.isEmpty() ? QString() : "#" + s);
     741        parse(newURL.ascii(), &newURL);
    786742    }
    787743}
     
    791747    if (m_isValid) {
    792748        QString q;
    793         if (!query.isEmpty() && query[0] != '?') {
    794             q = "?" + query;
    795         } else {
    796             q = query;
    797         }
     749        if (!query.isEmpty() && query[0] != '?') {
     750            q = "?" + query;
     751        } else {
     752            q = query;
     753        }
    798754
    799755        QString newURL = urlString.left(pathEndPos) + q + urlString.mid(queryEndPos);
    800         parse(newURL.ascii(), &newURL);
     756        parse(newURL.ascii(), &newURL);
    801757    }
    802758}
     
    805761{
    806762    if (m_isValid) {
    807         QString newURL = urlString.left(portEndPos) + encode_string(s) + urlString.mid(pathEndPos);
    808         parse(newURL.ascii(), &newURL);
    809     }
    810 }
    811 
    812 QString KURL::canonicalURL() const
    813 {
    814 #ifdef CONSTRUCT_CANONICAL_STRING
    815     bool hadPrePathComponent = false;
    816     QString canonicalURL;
    817    
    818     if (!protocol().isEmpty()) {
    819         canonicalURL += protocol();
    820         canonicalURL += "://";
    821         hadPrePathComponent = true;
    822     }
    823     if (!_user().isEmpty()) {
    824         canonicalURL += _user();
    825         if (!_pass().isEmpty()){
    826             canonicalURL += ":";
    827             canonicalURL += _pass();
    828         }
    829         canonicalURL += "@";
    830         hadPrePathComponent = true;
    831     }
    832     if (!_host().isEmpty()) {
    833         canonicalURL += _host();
    834         unsigned short int p = port();
    835         if (p != 0) {
    836             canonicalURL += ":";
    837             canonicalURL += QString::number(p);
    838         }
    839         hadPrePathComponent = true;
    840     }
    841     if (hadPrePathComponent && (strncasecmp ("http", url, schemeEnd) == 0 ||
    842         strncasecmp ("https", url, schemeEnd) == 0) && _path().isEmpty()) {
    843         canonicalURL += "/";
    844     }
    845     if (!_path().isEmpty()) {
    846         canonicalURL += _path();
    847     }
    848     if (!query().isEmpty()) {
    849         canonicalURL += "?";
    850         canonicalURL += query();
    851     }
    852     if (!ref().isEmpty()) {
    853         canonicalURL += "#";
    854         canonicalURL += ref();
    855     }
    856     return canonicalURL;
    857 #else
    858     return urlString;
    859 #endif
    860 }
    861 
     763        QString newURL = urlString.left(portEndPos) + encode_string(s) + urlString.mid(pathEndPos);
     764        parse(newURL.ascii(), &newURL);
     765    }
     766}
    862767
    863768QString KURL::prettyURL() const
     
    872777
    873778    if (hostEndPos != passwordEndPos) {
    874         if (userEndPos != userStartPos) {
    875             authority += user();
    876             authority += "@";
    877         }
    878         authority += host();
    879         if (port() != 0) {
    880             authority += ":";
    881             authority += QString::number(port());
    882         }
     779        if (userEndPos != userStartPos) {
     780            authority += user();
     781            authority += "@";
     782        }
     783        authority += host();
     784        if (port() != 0) {
     785            authority += ":";
     786            authority += QString::number(port());
     787        }
    883788    }
    884789
     
    976881    const char *strEnd = strStart + length;
    977882    while (str < strEnd) {
    978         unsigned char c = *str++;
     883        unsigned char c = *str++;
    979884        if (isBadChar(c)) {
    980885            if (c == '%' && strEnd - str >= 2 && isHexDigit(str[0]) && isHexDigit(str[1])) {
     
    989894                *p++ = hexDigits[c & 0xF];
    990895            }
    991         } else {
    992             *p++ = c;
    993         }
     896        } else {
     897            *p++ = c;
     898        }
    994899    }
    995900   
     
    1078983    m_isValid = true;
    1079984
    1080     if (url == NULL || url[0] == '\0') {
    1081         // valid URL must be non-empty
    1082         m_isValid = false;
    1083         urlString = url;
    1084         return;
     985    if (!url || url[0] == '\0') {
     986        // valid URL must be non-empty
     987        m_isValid = false;
     988        urlString = url;
     989        return;
    1085990    }
    1086991
    1087992    if (!isSchemeFirstChar(url[0])) {
    1088         // scheme must start with an alphabetic character
    1089         m_isValid = false;
    1090         urlString = url;
    1091         return;
     993        // scheme must start with an alphabetic character
     994        m_isValid = false;
     995        urlString = url;
     996        return;
    1092997    }
    1093998
     
    10951000 
    10961001    while (isSchemeChar(url[schemeEnd])) {
    1097         schemeEnd++;
     1002        schemeEnd++;
    10981003    }
    10991004
    11001005    if (url[schemeEnd] != ':') {
    1101         m_isValid = false;
    1102         urlString = url;
    1103         return;
     1006        m_isValid = false;
     1007        urlString = url;
     1008        return;
    11041009    }
    11051010
     
    11161021
    11171022    if (hierarchical && url[schemeEnd + 2] == '/') {
    1118         // part after the scheme must be a net_path, parse the authority section
    1119 
    1120         // FIXME: authority characters may be scanned twice
    1121         userStart += 2;
    1122         userEnd = userStart;
    1123 
    1124         int colonPos = 0;
    1125         while (isUserInfoChar(url[userEnd])) {
    1126             if (url[userEnd] == ':' && colonPos == 0) {
    1127                 colonPos = userEnd;
    1128             }
    1129             userEnd++;
    1130         }
    1131        
    1132         if (url[userEnd] == '@') {
    1133             // actual end of the userinfo, start on the host
    1134             if (colonPos != 0) {
    1135                 passwordEnd = userEnd;
    1136                 userEnd = colonPos;
    1137                 passwordStart = colonPos + 1;
    1138             } else {
    1139                 passwordStart = passwordEnd = userEnd;
    1140             }
    1141             hostStart = passwordEnd + 1;
    1142         } else if (url[userEnd] == '[' || isPathSegmentEndChar(url[userEnd])) {
    1143             // hit the end of the authority, must have been no user
    1144             // or looks like an IPv6 hostname
    1145             // either way, try to parse it as a hostname
    1146             userEnd = userStart;
    1147             passwordStart = passwordEnd = userEnd;
    1148             hostStart = userStart;
    1149         } else {
    1150             // invalid character
    1151             m_isValid = false;
    1152             urlString = url;
    1153             return;
    1154         }
    1155 
    1156         hostEnd = hostStart;
    1157 
    1158         // IPV6 IP address
    1159         if (url[hostEnd] == '[') {
    1160             hostEnd++;
    1161             while (isIPv6Char(url[hostEnd])) {
    1162                 hostEnd++;
    1163             }
    1164             if (url[hostEnd] == ']') {
    1165                 hostEnd++;
    1166             } else {
    1167                 // invalid character
    1168                 m_isValid = false;
    1169                 urlString = url;
    1170                 return;
    1171             }
    1172         } else {
    1173             while (isHostnameChar(url[hostEnd])) {
    1174                 hostEnd++;
    1175             }
    1176         }
    1177        
    1178         if (url[hostEnd] == ':') {
    1179             portStart = portEnd = hostEnd + 1;
     1023        // part after the scheme must be a net_path, parse the authority section
     1024
     1025        // FIXME: authority characters may be scanned twice
     1026        userStart += 2;
     1027        userEnd = userStart;
     1028
     1029        int colonPos = 0;
     1030        while (isUserInfoChar(url[userEnd])) {
     1031            if (url[userEnd] == ':' && colonPos == 0) {
     1032                colonPos = userEnd;
     1033            }
     1034            userEnd++;
     1035        }
     1036       
     1037        if (url[userEnd] == '@') {
     1038            // actual end of the userinfo, start on the host
     1039            if (colonPos != 0) {
     1040                passwordEnd = userEnd;
     1041                userEnd = colonPos;
     1042                passwordStart = colonPos + 1;
     1043            } else {
     1044                passwordStart = passwordEnd = userEnd;
     1045            }
     1046            hostStart = passwordEnd + 1;
     1047        } else if (url[userEnd] == '[' || isPathSegmentEndChar(url[userEnd])) {
     1048            // hit the end of the authority, must have been no user
     1049            // or looks like an IPv6 hostname
     1050            // either way, try to parse it as a hostname
     1051            userEnd = userStart;
     1052            passwordStart = passwordEnd = userEnd;
     1053            hostStart = userStart;
     1054        } else {
     1055            // invalid character
     1056            m_isValid = false;
     1057            urlString = url;
     1058            return;
     1059        }
     1060
     1061        hostEnd = hostStart;
     1062
     1063        // IPV6 IP address
     1064        if (url[hostEnd] == '[') {
     1065            hostEnd++;
     1066            while (isIPv6Char(url[hostEnd])) {
     1067                hostEnd++;
     1068            }
     1069            if (url[hostEnd] == ']') {
     1070                hostEnd++;
     1071            } else {
     1072                // invalid character
     1073                m_isValid = false;
     1074                urlString = url;
     1075                return;
     1076            }
     1077        } else {
     1078            while (isHostnameChar(url[hostEnd])) {
     1079                hostEnd++;
     1080            }
     1081        }
     1082       
     1083        if (url[hostEnd] == ':') {
     1084            portStart = portEnd = hostEnd + 1;
    11801085 
    1181             // possible start of port
    1182             portEnd = portStart;
    1183             while (isdigit(url[portEnd])) {
    1184                 portEnd++;
    1185             }
    1186         } else {
    1187             portStart = portEnd = hostEnd;
    1188         }
    1189 
    1190         if (!isPathSegmentEndChar(url[portEnd])) {
    1191             // invalid character
    1192             m_isValid = false;
    1193             urlString = url;
    1194             return;
    1195         }
     1086            // possible start of port
     1087            portEnd = portStart;
     1088            while (isdigit(url[portEnd])) {
     1089                portEnd++;
     1090            }
     1091        } else {
     1092            portStart = portEnd = hostEnd;
     1093        }
     1094
     1095        if (!isPathSegmentEndChar(url[portEnd])) {
     1096            // invalid character
     1097            m_isValid = false;
     1098            urlString = url;
     1099            return;
     1100        }
    11961101    } else {
    1197         // the part after the scheme must be an opaque_part or an abs_path
    1198         userEnd = userStart;
    1199         passwordStart = passwordEnd = userEnd;
    1200         hostStart = hostEnd = passwordEnd;
    1201         portStart = portEnd = hostEnd;
    1202     }
    1203        
     1102        // the part after the scheme must be an opaque_part or an abs_path
     1103        userEnd = userStart;
     1104        passwordStart = passwordEnd = userEnd;
     1105        hostStart = hostEnd = passwordEnd;
     1106        portStart = portEnd = hostEnd;
     1107    }
     1108       
    12041109    int pathStart = portEnd;
    12051110    int pathEnd = pathStart;
     
    12131118            pathEnd++;
    12141119        }
    1215         queryStart = queryEnd = pathEnd;
     1120        queryStart = queryEnd = pathEnd;
    12161121
    12171122        while (url[queryEnd] != '\0') {
     
    12191124        }
    12201125
    1221         fragmentStart = fragmentEnd = queryEnd;
     1126        fragmentStart = fragmentEnd = queryEnd;
    12221127    }
    12231128    else {
     
    12511156    uint bufferLength = fragmentEnd * 3 + 1;
    12521157    if (bufferLength <= sizeof(staticBuffer)) {
    1253         buffer = staticBuffer;
     1158        buffer = staticBuffer;
    12541159    } else {
    1255         buffer = (char *)fastMalloc(bufferLength);
     1160        buffer = (char *)fastMalloc(bufferLength);
    12561161    }
    12571162
     
    12621167    const char *schemeEndPtr = url + schemeEnd;
    12631168    while (strPtr < schemeEndPtr) {
    1264         *p++ = *strPtr++;
     1169        *p++ = *strPtr++;
    12651170    }
    12661171    schemeEndPos = p - buffer;
     
    13121217
    13131218        *p++ = '/';
    1314         *p++ = '/';
    1315 
    1316         userStartPos = p - buffer;
    1317 
    1318         // copy in the user
    1319         strPtr = url + userStart;
    1320         const char *userEndPtr = url + userEnd;
    1321         while (strPtr < userEndPtr) {
    1322             *p++ = *strPtr++;
    1323         }
    1324         userEndPos = p - buffer;
    1325        
    1326         // copy in the password
    1327         if (passwordEnd != passwordStart) {
    1328             *p++ = ':';
    1329             strPtr = url + passwordStart;
    1330             const char *passwordEndPtr = url + passwordEnd;
    1331             while (strPtr < passwordEndPtr) {
    1332                 *p++ = *strPtr++;
    1333             }
    1334         }
    1335         passwordEndPos = p - buffer;
    1336        
    1337         // If we had any user info, add "@"
    1338         if (p - buffer != userStartPos) {
    1339             *p++ = '@';
    1340         }
    1341        
    1342         // copy in the host, except in the case of a file URL with authority="localhost"
    1343         if (!(isFile && hostIsLocalHost && !haveNonHostAuthorityPart)) {
     1219        *p++ = '/';
     1220
     1221        userStartPos = p - buffer;
     1222
     1223        // copy in the user
     1224        strPtr = url + userStart;
     1225        const char *userEndPtr = url + userEnd;
     1226        while (strPtr < userEndPtr) {
     1227            *p++ = *strPtr++;
     1228        }
     1229        userEndPos = p - buffer;
     1230       
     1231        // copy in the password
     1232        if (passwordEnd != passwordStart) {
     1233            *p++ = ':';
     1234            strPtr = url + passwordStart;
     1235            const char *passwordEndPtr = url + passwordEnd;
     1236            while (strPtr < passwordEndPtr) {
     1237                *p++ = *strPtr++;
     1238            }
     1239        }
     1240        passwordEndPos = p - buffer;
     1241       
     1242        // If we had any user info, add "@"
     1243        if (p - buffer != userStartPos) {
     1244            *p++ = '@';
     1245        }
     1246       
     1247        // copy in the host, except in the case of a file URL with authority="localhost"
     1248        if (!(isFile && hostIsLocalHost && !haveNonHostAuthorityPart)) {
    13441249            strPtr = url + hostStart;
    13451250            const char *hostEndPtr = url + hostEnd;
     
    13481253            }
    13491254        }
    1350         hostEndPos = p - buffer;
    1351        
    1352         // copy in the port
    1353         if (portEnd != portStart) {
    1354             *p++ = ':';
    1355             strPtr = url + portStart;
    1356             const char *portEndPtr = url + portEnd;
    1357             while (strPtr < portEndPtr) {
    1358                 *p++ = *strPtr++;
    1359             }
    1360         }
    1361         portEndPos = p - buffer;
     1255        hostEndPos = p - buffer;
     1256       
     1257        // copy in the port
     1258        if (portEnd != portStart) {
     1259            *p++ = ':';
     1260            strPtr = url + portStart;
     1261            const char *portEndPtr = url + portEnd;
     1262            while (strPtr < portEndPtr) {
     1263                *p++ = *strPtr++;
     1264            }
     1265        }
     1266        portEndPos = p - buffer;
    13621267    } else {
    1363         userStartPos = userEndPos = passwordEndPos = hostEndPos = portEndPos = p - buffer;
     1268        userStartPos = userEndPos = passwordEndPos = hostEndPos = portEndPos = p - buffer;
    13641269    }
    13651270
     
    13991304    // add fragment, escaping bad characters
    14001305    if (fragmentEnd != queryEnd) {
    1401         *p++ = '#';
    1402         appendEscapingBadChars(p, url + fragmentStart, fragmentEnd - fragmentStart);
     1306        *p++ = '#';
     1307        appendEscapingBadChars(p, url + fragmentStart, fragmentEnd - fragmentStart);
    14031308    }
    14041309    fragmentEndPos = p - buffer;
     
    14071312    // it started as a QString, just reuse it, to avoid extra
    14081313    // allocation.
    1409     if (originalString != NULL && strncmp(buffer, url, fragmentEndPos) == 0) {
    1410         urlString = *originalString;
     1314    if (originalString && strncmp(buffer, url, fragmentEndPos) == 0) {
     1315        urlString = *originalString;
    14111316    } else {
    1412         urlString = QString(buffer, fragmentEndPos);
     1317        urlString = QString(buffer, fragmentEndPos);
    14131318    }
    14141319
    14151320    ASSERT(p - buffer <= (int)bufferLength);
    1416                
     1321               
    14171322    if (buffer != staticBuffer) {
    1418         fastFree(buffer);
     1323        fastFree(buffer);
    14191324    }
    14201325}
     
    14451350    uint bufferLength = asUTF8.length() * 3 + 1;
    14461351    if (bufferLength <= sizeof(staticBuffer)) {
    1447         buffer = staticBuffer;
     1352        buffer = staticBuffer;
    14481353    } else {
    1449         buffer = (char *)fastMalloc(bufferLength);
     1354        buffer = (char *)fastMalloc(bufferLength);
    14501355    }
    14511356   
     
    14551360    const char *strEnd = str + asUTF8.length();
    14561361    while (str < strEnd) {
    1457         unsigned char c = *str++;
     1362        unsigned char c = *str++;
    14581363        if (isBadChar(c)) {
    14591364            *p++ = '%';
    14601365            *p++ = hexDigits[c >> 4];
    14611366            *p++ = hexDigits[c & 0xF];
    1462         } else {
    1463             *p++ = c;
    1464         }
     1367        } else {
     1368            *p++ = c;
     1369        }
    14651370    }
    14661371   
     
    14681373   
    14691374    ASSERT(p - buffer <= (int)bufferLength);
    1470                
     1375               
    14711376    if (buffer != staticBuffer) {
    1472         fastFree(buffer);
     1377        fastFree(buffer);
    14731378    }
    14741379
     
    15071412    UErrorCode error = U_ZERO_ERROR;
    15081413    int32_t numCharactersConverted = uidna_IDNToASCII
    1509         (reinterpret_cast<const UChar *>(s.unicode()), s.length(), buffer, hostnameBufferLength, UIDNA_ALLOW_UNASSIGNED, NULL, &error);
     1414        (reinterpret_cast<const UChar *>(s.unicode()), s.length(), buffer, hostnameBufferLength, UIDNA_ALLOW_UNASSIGNED, 0, &error);
    15101415    if (error != U_ZERO_ERROR) {
    15111416        return s;
     
    17301635   
    17311636    if (hashPos >= 0 && (questionPos < 0 || questionPos > hashPos)) {
    1732         pathEnd = hashPos;
     1637        pathEnd = hashPos;
    17331638    } else if (questionPos >= 0) {
    1734         pathEnd = questionPos;
     1639        pathEnd = questionPos;
    17351640    } else {
    1736         pathEnd = string.length();
     1641        pathEnd = string.length();
    17371642    }
    17381643
  • trunk/WebCore/kwq/KWQLoader.mm

    • Property allow-tabs deleted
    r12086 r12114  
    6868
    6969    while (NSString *line = (NSString *)[e nextObject]) {
    70         if ([line length]) {
     70        if ([line length]) {
    7171            unichar firstChar = [line characterAtIndex:0];
    7272            if ((firstChar == ' ' || firstChar == '\t') && lastHeaderName != nil) {
     
    7979                continue;
    8080            }
    81         }
    82 
    83         NSRange colonRange = [line rangeOfString:@":"];
    84         if (colonRange.location != NSNotFound) {
    85             // don't worry about case, assume lower levels will take care of it
    86 
    87             NSString *headerName = [[line substringToIndex:colonRange.location] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \t"]];
    88             NSString *headerValue = [[line substringFromIndex:colonRange.location + 1] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \t"]];
    89            
    90             NSString *oldVal = [headers objectForKey:headerName];
    91             if (oldVal) {
    92                 headerValue = [NSString stringWithFormat:@"%@, %@", oldVal, headerValue];
    93             }
    94 
    95             [headers setObject:headerValue forKey:headerName];
    96            
    97             lastHeaderName = headerName;
    98         }
     81        }
     82
     83        NSRange colonRange = [line rangeOfString:@":"];
     84        if (colonRange.location != NSNotFound) {
     85            // don't worry about case, assume lower levels will take care of it
     86
     87            NSString *headerName = [[line substringToIndex:colonRange.location] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \t"]];
     88            NSString *headerValue = [[line substringFromIndex:colonRange.location + 1] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \t"]];
     89           
     90            NSString *oldVal = [headers objectForKey:headerName];
     91            if (oldVal) {
     92                headerValue = [NSString stringWithFormat:@"%@, %@", oldVal, headerValue];
     93            }
     94
     95            [headers setObject:headerValue forKey:headerName];
     96           
     97            lastHeaderName = headerName;
     98        }
    9999    }
    100100
     
    124124
    125125    if (!headerString.isEmpty()) {
    126         headerDict = [NSDictionary _webcore_dictionaryWithHeaderString:headerString.getNSString()];
     126        headerDict = [NSDictionary _webcore_dictionaryWithHeaderString:headerString.getNSString()];
    127127    }
    128128
    129129    if (job->method() == "POST") {
    130         handle = [bridge startLoadingResource:resourceLoader withURL:job->url().getNSURL() customHeaders:headerDict
     130        handle = [bridge startLoadingResource:resourceLoader withURL:job->url().getNSURL() customHeaders:headerDict
    131131            postData:arrayFromFormData(job->postData())];
    132132    } else {
    133         handle = [bridge startLoadingResource:resourceLoader withURL:job->url().getNSURL() customHeaders:headerDict];
     133        handle = [bridge startLoadingResource:resourceLoader withURL:job->url().getNSURL() customHeaders:headerDict];
    134134    }
    135135    [resourceLoader setHandle:handle];
     
    152152   
    153153    while ((key = [e nextObject]) != nil) {
    154         if (first) {
    155             first = false;
    156         } else {
    157             [headerString appendString:@"\n"];
    158         }
    159         [headerString appendString:key];
    160         [headerString appendString:@": "];
    161         [headerString appendString:[headers objectForKey:key]];
    162     }
    163        
     154        if (first) {
     155            first = false;
     156        } else {
     157            [headerString appendString:@"\n"];
     158        }
     159        [headerString appendString:key];
     160        [headerString appendString:@": "];
     161        [headerString appendString:[headers objectForKey:key]];
     162    }
     163       
    164164    return headerString;
    165165}
     
    178178
    179179    if (!headerString.isEmpty()) {
    180         headerDict = [[NSDictionary _webcore_dictionaryWithHeaderString:headerString.getNSString()] retain];
     180        headerDict = [[NSDictionary _webcore_dictionaryWithHeaderString:headerString.getNSString()] retain];
    181181    }
    182182
    183183    NSArray *postData = nil;
    184184    if (job->method() == "POST") {
    185         postData = arrayFromFormData(job->postData());
     185        postData = arrayFromFormData(job->postData());
    186186    }
    187187
     
    244244    MacFrame *frame = static_cast<MacFrame *>(loader->frame());
    245245
    246     if (!frame->haveToldBridgeAboutLoad(cachedObject->url().qstring())) {
     246    if (!frame->haveToldBridgeAboutLoad(cachedObject->url())) {
    247247        WebCoreFrameBridge *bridge = frame->bridge();
    248248       
     
    253253        KWQ_UNBLOCK_EXCEPTIONS;
    254254
    255         frame->didTellBridgeAboutLoad(cachedObject->url().qstring());
     255        frame->didTellBridgeAboutLoad(cachedObject->url());
    256256    }
    257257}
     
    282282    bool ret = false;
    283283    if(!memcmp(urlStringCharacters, m_url.unicode(), m_url.length()*sizeof(QChar)))
    284         ret = true;
     284        ret = true;
    285285   
    286286    if (urlStringCharacters != _buffer)
  • trunk/WebCore/loader/Cache.cpp

    r12089 r12114  
    2828#include "config.h"
    2929#include "Cache.h"
     30
     31#include "CachedCSSStyleSheet.h"
    3032#include "CachedImage.h"
    3133#include "CachedScript.h"
    3234#include "CachedXSLStyleSheet.h"
    33 #include "CachedCSSStyleSheet.h"
    3435#include "DocLoader.h"
     36#include "DocumentImpl.h"
    3537#include "loader.h"
    36 #include "DocumentImpl.h"
    37 
    38 #include <qpixmap.h>
    39 
    40 // up to which size is a picture for sure cacheable
    41 #define MAXCACHEABLE 40*1024
    42 // default cache size
    43 #define DEFCACHESIZE 4096*1024
    44 
    4538#include <kio/job.h>
    4639#include <kio/jobclasses.h>
    47 
    4840#include <kxmlcore/Assertions.h>
    49 
    50 using namespace khtml;
     41#include <qpixmap.h>
     42
    5143using namespace DOM;
    5244
     45namespace khtml {
     46
     47const int defaultCacheSize = 4096 * 1024;
     48
     49// maxCacheableObjectSize is cache size divided by 128, but with this as a minimum
     50const int minMaxCacheableObjectSize = 40 * 1024;
     51
     52const int maxLRULists = 20;
     53   
     54struct LRUList {
     55    CachedObject* m_head;
     56    CachedObject* m_tail;
     57    LRUList() : m_head(0), m_tail(0) { }
     58};
     59
    5360static bool cacheDisabled;
    5461
    55 LRUList::LRUList() :m_head(0), m_tail(0)
    56 {
    57 }
    58 
    59 LRUList::~LRUList()
    60 {
    61 }
    62 
    63 QDict<CachedObject> *Cache::cache = 0;
     62typedef HashMap<RefPtr<DOMStringImpl>, CachedObject*> CacheMap;
     63
     64static CacheMap* cache = 0;
     65
    6466QPtrList<DocLoader>* Cache::docloader = 0;
    6567Loader *Cache::m_loader = 0;
    6668
    67 int Cache::maxSize = DEFCACHESIZE;
    68 int Cache::maxCacheable = MAXCACHEABLE;
     69int Cache::maxSize = defaultCacheSize;
     70int Cache::maxCacheable = minMaxCacheableObjectSize;
    6971int Cache::flushCount = 0;
    7072
     
    7981void Cache::init()
    8082{
    81     if ( !cache )
    82         cache = new QDict<CachedObject>(401, true);
     83    if (!cache)
     84        cache = new CacheMap;
    8385
    8486    if ( !docloader )
     
    100102        return;
    101103
    102     cache->setAutoDelete( true );
     104    CacheMap::iterator e = cache->end();
     105    for (CacheMap::iterator i = cache->begin(); i != e; ++i)
     106        delete i->second;
     107
    103108    delete cache; cache = 0;
    104109    delete nullPixmap; nullPixmap = 0;
     
    135140    CachedObject *o = 0;
    136141    if (!reload)
    137         o = cache->find(url.url());
     142        o = cache->get(DOMString(url.url()).impl());
    138143    if(!o)
    139144    {
     
    146151            im->setFree(true);
    147152        else {
    148         cache->insert( url.url(), im );
    149         moveToHeadOfLRUList(im);
     153            cache->set(DOMString(url.url()).impl(), im);
     154            moveToHeadOfLRUList(im);
    150155        }
    151156        o = im;
     
    195200    // Checking if the URL is malformed is lots of extra work for little benefit.
    196201
    197     CachedObject *o = cache->find(kurl.url());
     202    CachedObject *o = cache->get(DOMString(kurl.url()).impl());
    198203    if(!o)
    199204    {
     
    205210            sheet->setFree(true);
    206211        else {
    207         cache->insert( kurl.url(), sheet );
    208         moveToHeadOfLRUList(sheet);
     212            cache->set(DOMString(kurl.url()).impl(), sheet);
     213            moveToHeadOfLRUList(sheet);
    209214        }
    210215        o = sheet;
     
    236241}
    237242
    238 void Cache::preloadStyleSheet( const QString &url, const QString &stylesheet_data)
    239 {
    240     CachedObject *o = cache->find(url);
    241     if(o)
    242         removeCacheEntry(o);
    243 
    244     CachedCSSStyleSheet *stylesheet = new CachedCSSStyleSheet(url, stylesheet_data);
    245     cache->insert( url, stylesheet );
     243void Cache::preloadStyleSheet(const QString &url, const QString &stylesheet_data)
     244{
     245    CachedObject *o = cache->get(DOMString(url).impl());
     246    if (o)
     247        remove(o);
     248    cache->set(DOMString(url).impl(), new CachedCSSStyleSheet(url, stylesheet_data));
    246249}
    247250
     
    264267    // Checking if the URL is malformed is lots of extra work for little benefit.
    265268
    266     CachedObject *o = cache->find(kurl.url());
     269    CachedObject *o = cache->get(DOMString(kurl.url()).impl());
    267270    if(!o)
    268271    {
     
    274277            script->setFree(true);
    275278        else {
    276         cache->insert( kurl.url(), script );
    277         moveToHeadOfLRUList(script);
     279            cache->set(DOMString(kurl.url()).impl(), script );
     280            moveToHeadOfLRUList(script);
    278281        }
    279282        o = script;
     
    306309}
    307310
    308 void Cache::preloadScript( const QString &url, const QString &script_data)
    309 {
    310     CachedObject *o = cache->find(url);
     311void Cache::preloadScript(const QString &url, const QString &script_data)
     312{
     313    CachedObject *o = cache->get(DOMString(url).impl());
    311314    if(o)
    312         removeCacheEntry(o);
    313 
    314     CachedScript *script = new CachedScript(url, script_data);
    315     cache->insert( url, script );
     315        remove(o);
     316    cache->set(DOMString(url).impl(), new CachedScript(url, script_data));
    316317}
    317318
     
    334335    // Checking if the URL is malformed is lots of extra work for little benefit.
    335336   
    336     CachedObject *o = cache->find(kurl.url());
     337    CachedObject *o = cache->get(DOMString(kurl.url()).impl());
    337338    if (!o) {
    338339#ifdef CACHE_DEBUG
     
    343344            doc->setFree(true);
    344345        else {
    345             cache->insert(kurl.url(), doc);
     346            cache->set(DOMString(kurl.url()).impl(), doc);
    346347            moveToHeadOfLRUList(doc);
    347348        }
     
    392393    // Checking if the URL is malformed is lots of extra work for little benefit.
    393394   
    394     CachedObject *o = cache->find(kurl.url());
     395    CachedObject *o = cache->get(DOMString(kurl.url()).impl());
    395396    if(!o)
    396397    {
     
    402403            doc->setFree(true);
    403404        else {
    404             cache->insert(kurl.url(), doc);
     405            cache->set(DOMString(kurl.url()).impl(), doc);
    405406            moveToHeadOfLRUList(doc);
    406407        }
     
    445446
    446447    while (m_headOfUncacheableList)
    447         removeCacheEntry(m_headOfUncacheableList);
    448 
    449     for (int i = MAX_LRU_LISTS-1; i>=0; i--) {
     448        remove(m_headOfUncacheableList);
     449
     450    for (int i = maxLRULists-1; i>=0; i--) {
    450451        if (m_totalSizeOfLRULists <= maxSize)
    451452            break;
    452453           
    453454        while (m_totalSizeOfLRULists > maxSize && m_LRULists[i].m_tail)
    454             removeCacheEntry(m_LRULists[i].m_tail);
     455            remove(m_LRULists[i].m_tail);
    455456    }
    456457
     
    459460
    460461
    461 void Cache::setSize( int bytes )
     462void Cache::setSize(int bytes)
    462463{
    463464    maxSize = bytes;
    464     maxCacheable = kMax(maxSize / 128, MAXCACHEABLE);
     465    maxCacheable = kMax(maxSize / 128, minMaxCacheableObjectSize);
    465466
    466467    // may be we need to clear parts of the cache
     
    469470}
    470471
    471 void Cache::removeCacheEntry( CachedObject *object )
    472 {
    473   QString key = object->url().qstring();
    474 
     472void Cache::remove( CachedObject *object )
     473{
    475474  // this indicates the deref() method of CachedObject to delete itself when the reference counter
    476475  // drops down to zero
    477   object->setFree( true );
    478 
    479   cache->remove( key );
     476  object->setFree(true);
     477
     478  cache->remove(object->url().impl());
    480479  removeFromLRUList(object);
    481480
     
    488487}
    489488
    490 #define FAST_LOG2(_log2,_n)   \
    491       unsigned int j_ = (unsigned int)(_n);   \
    492       (_log2) = 0;                    \
    493       if ((j_) & ((j_)-1))            \
    494       (_log2) += 1;               \
    495       if ((j_) >> 16)                 \
    496       (_log2) += 16, (j_) >>= 16; \
    497       if ((j_) >> 8)                  \
    498       (_log2) += 8, (j_) >>= 8;   \
    499       if ((j_) >> 4)                  \
    500       (_log2) += 4, (j_) >>= 4;   \
    501       if ((j_) >> 2)                  \
    502       (_log2) += 2, (j_) >>= 2;   \
    503       if ((j_) >> 1)                  \
    504       (_log2) += 1;
    505 
    506 static int FastLog2(unsigned int i) {
    507     int log2;
    508     FAST_LOG2(log2,i);
     489static inline int FastLog2(uint32_t i)
     490{
     491    int log2 = 0;
     492    if (i & (i - 1))
     493        log2 += 1;
     494    if (i >> 16)
     495        log2 += 16, i >>= 16;
     496    if (i >> 8)
     497        log2 += 8, i >>= 8;
     498    if (i >> 4)
     499        log2 += 4, i >>= 4;
     500    if (i >> 2)
     501        log2 += 2, i >>= 2;
     502    if (i >> 1)
     503        log2 += 1;
    509504    return log2;
    510505}
     
    518513    } else {
    519514        int sizeLog = FastLog2(o->size());
    520         queueIndex = sizeLog/o->accessCount() - 1;
     515        queueIndex = sizeLog / o->accessCount() - 1;
    521516        if (queueIndex < 0)
    522517            queueIndex = 0;
    523         if (queueIndex >= MAX_LRU_LISTS)
    524             queueIndex = MAX_LRU_LISTS-1;
    525     }
    526     if (m_LRULists == 0) {
    527         m_LRULists = new LRUList [MAX_LRU_LISTS];
    528     }
     518        if (queueIndex >= maxLRULists)
     519            queueIndex = maxLRULists-1;
     520    }
     521    if (!m_LRULists)
     522        m_LRULists = new LRUList [maxLRULists];
    529523    return &m_LRULists[queueIndex];
    530524}
     
    613607        return stats;
    614608
    615     QDictIterator<CachedObject> i(*cache);
    616     for (i.toFirst(); i.current(); ++i) {
    617         CachedObject *o = i.current();
     609    CacheMap::iterator e = cache->end();
     610    for (CacheMap::iterator i = cache->begin(); i != e; ++i) {
     611        CachedObject *o = i->second;
    618612        switch (o->type()) {
    619613            case CachedObject::Image:
     
    658652
    659653    for (;;) {
    660         QDictIterator<CachedObject> i(*cache);
    661         CachedObject *o = i.toFirst();
    662         if (!o)
     654        CacheMap::iterator i = cache->begin();
     655        if (i == cache->end())
    663656            break;
    664         removeCacheEntry(o);
     657        remove(i->second);
    665658    }
    666659}
     
    672665        flushAll();
    673666}
     667
     668CachedObject* Cache::get(const DOMString& s)
     669{
     670    return (cache && s.impl()) ? cache->get(s.impl()) : 0;
     671}
     672
     673}
  • trunk/WebCore/loader/Cache.h

    • Property allow-tabs deleted
    r12089 r12114  
    2424    pages from the web. It has a memory cache for these objects.
    2525*/
     26
    2627#ifndef KHTML_Cache_h
    2728#define KHTML_Cache_h
    2829
    29 #include <qptrdict.h>
     30#include "dom/dom_string.h"
     31#include <kio/global.h>
    3032#include <qptrlist.h>
    31 #include <qdict.h>
    3233#include <qstring.h>
    33 
    34 #include <kio/global.h>
    35 
    36 #include <dom/dom_string.h>
    3734
    3835class QPixmap;
     
    4138namespace khtml
    4239{
     40    class CachedCSSStyleSheet;
     41    class CachedImage;
    4342    class CachedObject;
    44     class CachedImage;
    4543    class CachedScript;
    46     class CachedCSSStyleSheet;
    4744    class CachedXSLStyleSheet;
     45    class DocLoader;
    4846    class Loader;
    49     class DocLoader;
    50 
    51 #define MAX_LRU_LISTS 20
    52    
    53     struct LRUList {
    54         CachedObject* m_head;
    55         CachedObject* m_tail;
    56    
    57         LRUList();
    58         ~LRUList();
    59     };
     47    struct LRUList;
    6048   
    6149    /**
     
    6553    class Cache
    6654    {
    67         friend class DocLoader;
     55        friend class DocLoader;
    6856    public:
    69         /**
    70         * init the cache in case it's not already. This needs to get called once
    71         * before using it.
    72         */
    73         static void init();
     57        /**
     58        * init the cache in case it's not already. This needs to get called once
     59        * before using it.
     60        */
     61        static void init();
    7462       
    75         /**
    76         * Ask the cache for some url. Will return a cachedObject, and
    77         * load the requested data in case it's not cahced
     63        /**
     64        * Ask the cache for some url. Will return a cachedObject, and
     65        * load the requested data in case it's not cahced
    7866         * if the DocLoader is zero, the url must be full-qualified.
    7967         * Otherwise, it is automatically base-url expanded
    80         */
    81         static CachedImage *requestImage( DocLoader* l, const DOM::DOMString &url, bool reload=false, time_t _expireDate=0);
    82         static CachedImage *requestImage( DocLoader* l, const KURL &url, bool reload=false, time_t _expireDate=0);
     68        */
     69        static CachedImage* requestImage(DocLoader*, const DOM::DOMString& URL, bool reload = false, time_t expireDate = 0);
     70        static CachedImage* requestImage(DocLoader*, const KURL& url, bool reload = false, time_t expireDate = 0);
    8371
    84         /**
    85          * Ask the cache for some url. Will return a cachedObject, and
    86          * load the requested data in case it's not cached
    87          */
    88         static CachedCSSStyleSheet *requestStyleSheet( DocLoader* l, const DOM::DOMString &url, bool reload=false, time_t _expireDate=0, const QString& charset = QString::null);
    89 
    90 #ifdef KHTML_XSLT
    91         // Ask the cache for an XSL stylesheet.
    92         static CachedXSLStyleSheet* requestXSLStyleSheet(DocLoader* l, const DOM::DOMString &url,
    93                                                          bool reload=false, time_t _expireDate=0);
    94 #endif
    95 #ifndef KHTML_NO_XBL
    96         // Ask the cache for an XBL document.
    97         static CachedXBLDocument* requestXBLDocument(DocLoader* l, const DOM::DOMString &url,
    98                                                      bool reload=false, time_t _expireDate=0);
    99 #endif
     72        /**
     73         * Ask the cache for some url. Will return a cachedObject, and
     74         * load the requested data in case it's not cached
     75         */
     76        static CachedCSSStyleSheet* requestStyleSheet(DocLoader*, const DOM::DOMString& URL, bool reload = false, time_t expireDate = 0, const QString& charset = QString::null);
    10077
    10178        /**
    10279         * Pre-loads a stylesheet into the cache.
    10380         */
    104         static void preloadStyleSheet(const QString &url, const QString &stylesheet_data);
     81        static void preloadStyleSheet(const QString &url, const QString& stylesheetData);
    10582
    106         /**
    107         * Ask the cache for some url. Will return a cachedObject, and
    108         * load the requested data in case it's not cahced
    109         */
    110         static CachedScript *requestScript( DocLoader* l, const DOM::DOMString &url, bool reload=false, time_t _expireDate=0, const QString& charset=QString::null);
     83        /**
     84        * Ask the cache for some url. Will return a cachedObject, and
     85        * load the requested data in case it's not cahced
     86        */
     87        static CachedScript* requestScript(DocLoader*, const DOM::DOMString& URL, bool reload = false, time_t expireDate = 0, const QString& charset = QString::null);
    11188
    11289        /**
    11390         * Pre-loads a script into the cache.
    11491         */
    115         static void preloadScript(const QString &url, const QString &script_data);
     92        static void preloadScript(const QString &url, const QString& scriptData);
    11693
    117         /**
    118          * sets the size of the cache. This will only hod approximately, since the size some
    119          * cached objects (like stylesheets) take up in memory is not exaclty known.
    120          */
    121         static void setSize( int bytes );
    122         /**
    123          * returns the size of the cache
    124          */
    125         static int size() { return maxSize; };
     94#ifdef KHTML_XSLT
     95        // Ask the cache for an XSL stylesheet.
     96        static CachedXSLStyleSheet* requestXSLStyleSheet(DocLoader*, const DOM::DOMString& URL, bool reload = false, time_t expireDate = 0);
     97#endif
     98
     99#ifndef KHTML_NO_XBL
     100        // Ask the cache for an XBL document.
     101        static CachedXBLDocument* requestXBLDocument(DocLoader*, const DOM::DOMString& URL, bool reload = false, time_t expireDate = 0);
     102#endif
     103
     104        /**
     105         * Sets the size of the cache. This will only hod approximately, since the size some
     106         * cached objects (like stylesheets) take up in memory is not exaclty known.
     107         */
     108        static void setSize(int bytes);
     109        /**
     110         * returns the size of the cache
     111         */
     112        static int size() { return maxSize; };
    126113
    127114        static int maxCacheableObjectSize() { return maxCacheable; }
    128115
    129         /**
    130          * clean up cache
    131          */
    132         static void flush(bool force=false);
     116        // Get an existing cache entry by URL.
     117        static CachedObject* get(const DOM::DOMString& URL);
    133118
    134         /**
    135          * clears the cache
    136          * Warning: call this only at the end of your program, to clean
    137          * up memory (useful for finding memory holes)
    138          */
    139         static void clear();
     119        // Remove an existing cache entry.
     120        static void remove(CachedObject*);
    140121
    141         static Loader *loader() { return m_loader; }
     122        /**
     123         * clean up cache
     124         */
     125        static void flush(bool force = false);
    142126
    143         static QPixmap *nullPixmap;
    144         static QPixmap *brokenPixmap;
     127        /**
     128         * clears the cache
     129         * Warning: call this only at the end of your program, to clean
     130         * up memory (useful for finding memory holes)
     131         */
     132        static void clear();
    145133
    146         static void removeCacheEntry( CachedObject *object );
     134        static Loader* loader() { return m_loader; }
     135
     136        static QPixmap* nullPixmap;
     137        static QPixmap* brokenPixmap;
    147138
    148139        struct TypeStatistic {
     
    170161        static void setCacheDisabled(bool);
    171162
    172         static void insertInLRUList(CachedObject *);
    173         static void removeFromLRUList(CachedObject *);
    174         static bool adjustSize(CachedObject *, int sizeDelta);
     163        static void insertInLRUList(CachedObject*);
     164        static void removeFromLRUList(CachedObject*);
     165        static bool adjustSize(CachedObject*, int sizeDelta);
    175166       
    176         static LRUList* getLRUListFor(CachedObject* o);
     167        static LRUList* getLRUListFor(CachedObject*);
    177168       
    178169        static void checkLRUAndUncacheableListIntegrity();
    179170
    180     protected:
    181         static QDict<CachedObject> *cache;
     171    private:
    182172        static QPtrList<DocLoader>* docloader;
    183173   
     
    186176        static int flushCount;
    187177   
    188         static Loader *m_loader;
     178        static Loader* m_loader;
    189179   
    190         static void moveToHeadOfLRUList(CachedObject *);
     180        static void moveToHeadOfLRUList(CachedObject*);
    191181   
    192         static LRUList *m_LRULists;
     182        static LRUList* m_LRULists;
    193183        static int m_totalSizeOfLRULists;
    194184           
    195         static CachedObject *m_headOfUncacheableList;
     185        static CachedObject* m_headOfUncacheableList;
    196186           
    197187        static int m_countOfLRUAndUncacheableLists;
    198188    };
    199 };
     189}
    200190
    201191#endif
  • trunk/WebCore/loader/CachedImage.cpp

    r12089 r12114  
    2828#include "config.h"
    2929#include "CachedImage.h"
     30
     31#include "Cache.h"
    3032#include "CachedImageCallback.h"
    3133#include "CachedObjectClientWalker.h"
    32 #include "Cache.h"
    3334#include "DocLoader.h"
    3435#include "KWQLoader.h"
     
    7879    Cache::flush();
    7980    CachedObject::deref(c);
    80     if ( canDelete() && m_free )
     81    if (canDelete() && m_free)
    8182        delete this;
    8283}
     
    135136}
    136137
    137 void CachedImage::data ( QBuffer &_buffer, bool eof )
     138void CachedImage::data(QBuffer& _buffer, bool eof)
    138139{
    139140#ifdef CACHE_DEBUG
     
    170171                errorOccured = true;
    171172                QPixmap ep = pixmap();
    172                 do_notify (ep, ep.rect());
    173                 Cache::removeCacheEntry (this);
     173                do_notify(ep, ep.rect());
     174                Cache::remove(this);
    174175            }
    175176            else
     
    205206}
    206207
    207 };
     208}
  • trunk/WebCore/loader/CachedImageCallback.cpp

    r12090 r12114  
    2828#include "config.h"
    2929#include "CachedImageCallback.h"
     30
    3031#include "Cache.h"
    31 #include "loader.h"
    3232#include "CachedImage.h"
    3333#include "Request.h"
    34 
    35 #include <qpainter.h>
    36 
     34#include "loader.h"
     35#include <kdebug.h>
    3736#include <kio/job.h>
    3837#include <kio/jobclasses.h>
    39 #include <kdebug.h>
    40 #include "decoder.h"
     38#include <qpainter.h>
    4139
    4240using namespace DOM;
     
    4745{
    4846    if (cachedImage) {
    49         cachedImage->do_notify (cachedImage->pixmap(), cachedImage->pixmap().rect());
     47        cachedImage->do_notify(cachedImage->pixmap(), cachedImage->pixmap().rect());
    5048        IntSize s = cachedImage->pixmap_size();
    5149        cachedImage->setSize(s.width() * s.height() * 2);
     
    8078{
    8179    if (cachedImage) {
    82         cachedImage->do_notify (cachedImage->pixmap(), cachedImage->pixmap().rect());
     80        cachedImage->do_notify(cachedImage->pixmap(), cachedImage->pixmap().rect());
    8381        cachedImage->m_loading = false;
    8482        cachedImage->checkNotify();
     
    110108        cachedImage->errorOccured = true;
    111109        QPixmap ep = cachedImage->pixmap();
    112         cachedImage->do_notify (ep, ep.rect());
    113         Cache::removeCacheEntry (cachedImage);
     110        cachedImage->do_notify(ep, ep.rect());
     111        Cache::remove(cachedImage);
    114112
    115113        clear();
     
    133131}
    134132
    135 };
     133}
  • trunk/WebCore/loader/CachedObject.h

    r12092 r12114  
    2424    pages from the web. It has a memory cache for these objects.
    2525*/
     26
    2627#ifndef KHTML_CachedObject_h
    2728#define KHTML_CachedObject_h
     
    3536#include <qobject.h>
    3637#include <qptrdict.h>
    37 #include <qdict.h>
    3838#include <qpixmap.h>
    3939#include <qbuffer.h>
     
    226226    };
    227227
    228 };
    229 
    230 #endif
     228}
     229
     230#endif
  • trunk/WebCore/loader/DocLoader.cpp

    r12089 r12114  
    7575       if (!m_reloadedURLs.contains(fullURL.url()))
    7676       {
    77           CachedObject *existing = Cache::cache->find(fullURL.url());
     77          CachedObject* existing = Cache::get(fullURL.url());
    7878          if (existing && existing->isExpired())
    7979          {
    80              Cache::removeCacheEntry(existing);
     80             Cache::remove(existing);
    8181             m_reloadedURLs.append(fullURL.url());
    8282             reload = true;
     
    8888       if (!m_reloadedURLs.contains(fullURL.url()))
    8989       {
    90           CachedObject *existing = Cache::cache->find(fullURL.url());
     90          CachedObject* existing = Cache::get(fullURL.url());
    9191          if (existing)
    92           {
    93              Cache::removeCacheEntry(existing);
    94           }
     92             Cache::remove(existing);
    9593          m_reloadedURLs.append(fullURL.url());
    9694          reload = true;
     
    10098}
    10199
    102 CachedImage *DocLoader::requestImage( const DOM::DOMString &url)
     100CachedImage *DocLoader::requestImage(const DOM::DOMString &url)
    103101{
    104102    KURL fullURL = m_doc->completeURL(url.qstring());
  • trunk/WebCore/loader/DocLoader.h

    r12089 r12114  
    2424    pages from the web. It has a memory cache for these objects.
    2525*/
     26
    2627#ifndef KHTML_DocLoader_h
    2728#define KHTML_DocLoader_h
    2829
    2930#include <qptrlist.h>
    30 #include <qdict.h>
    3131#include <qbuffer.h>
    3232#include <qstringlist.h>
     
    107107    };
    108108
    109 };
     109}
    110110
    111111#endif
  • trunk/WebCore/loader/loader.cpp

    r12089 r12114  
    55    Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
    66    Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
    7     Copyright (C) 2004 Apple Computer, Inc.
     7    Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
    88
    99    This library is free software; you can redistribute it and/or
     
    2828#include "config.h"
    2929#include "loader.h"
     30
    3031#include "Cache.h"
    31 #include "DocLoader.h"
    32 #include "CachedObject.h"
    3332#include "CachedImage.h"
    3433#include "CachedImageCallback.h"
    35 
     34#include "CachedObject.h"
     35#include "DocLoader.h"
     36#include "Frame.h"
     37#include "KWQLoader.h"
     38#include "html_documentimpl.h"
    3639#include <kio/job.h>
    3740#include <kio/jobclasses.h>
    38 
    3941#include <kxmlcore/Assertions.h>
    40 #include "KWQLoader.h"
    41 #include "html_documentimpl.h"
    42 #include "Frame.h"
    4342
    4443using namespace DOM;
     
    160159            docLoader->setLoadInProgress(false);
    161160            emit requestFailed( docLoader, object );
    162             Cache::removeCacheEntry( object );
     161            Cache::remove( object );
    163162        }
    164163    }
     
    262261    {
    263262        if (pIt.current()->m_docLoader == dl) {
    264             Cache::removeCacheEntry( pIt.current()->object );
     263            Cache::remove( pIt.current()->object );
    265264            m_requestsPending.remove( pIt );
    266265        }
     
    274273        if (lIt.current()->m_docLoader == dl) {
    275274            KIO::Job *job = static_cast<KIO::Job *>( lIt.currentKey() );
    276             Cache::removeCacheEntry( lIt.current()->object );
     275            Cache::remove( lIt.current()->object );
    277276            m_requestsLoading.remove( lIt.currentKey() );
    278277            job->kill();
     
    285284    while (bdIt.current()) {
    286285        if (bdIt.current()->m_docLoader == dl) {
    287             Cache::removeCacheEntry( bdIt.current()->object );
     286            Cache::remove( bdIt.current()->object );
    288287            m_requestsBackgroundDecoding.remove( bdIt );
    289288        }
Note: See TracChangeset for help on using the changeset viewer.