Changeset 92441 in webkit


Ignore:
Timestamp:
Aug 4, 2011 8:25:53 PM (13 years ago)
Author:
morrita@google.com
Message:

Reviewed by Ryosuke Niwa.

DocumentMarker: Type specific details should be separately held by other object.
https://bugs.webkit.org/show_bug.cgi?id=59855

  • Introduced DocumentMarkerDetails abstract class and two its subclasses DocumentMarkerDescription and DocumentMarkerActiveMatch,
  • Replacing DocumentMarker::m_description and DocumentMarker::m_activeMatch with these new details classes.

No new tests. No behavior change.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/DOMAllInOne.cpp:
  • dom/DocumentMarker.cpp: Added.

(WebCore::emptyDescription):
(WebCore::DocumentMarkerDetails::DocumentMarkerDetails):
(WebCore::DocumentMarkerDetails::~DocumentMarkerDetails):
(WebCore::DocumentMarkerDescription::description):
(WebCore::DocumentMarkerDescription::isDescription):
(WebCore::DocumentMarkerDescription::DocumentMarkerDescription):
(WebCore::DocumentMarkerDescription::createUnlessEmpty):
(WebCore::DocumentMarkerDescription::compatibleTypes):
(WebCore::DocumentMarkerTextMatch::activeMatch):
(WebCore::DocumentMarkerTextMatch::isTextMatch):
(WebCore::DocumentMarkerTextMatch::DocumentMarkerTextMatch):
(WebCore::DocumentMarkerTextMatch::instanceFor):
(WebCore::DocumentMarkerTextMatch::compatibleTypes):
(WebCore::DocumentMarker::DocumentMarker):
(WebCore::DocumentMarker::shiftOffsets):
(WebCore::DocumentMarker::setActiveMatch):
(WebCore::DocumentMarker::description):
(WebCore::DocumentMarker::activeMatch):

  • dom/DocumentMarker.h:

(WebCore::DocumentMarker::details):
(WebCore::DocumentMarker::clearDetails):
(WebCore::DocumentMarkerDetails::isDescription):
(WebCore::DocumentMarkerDetails::isTextMatch):
(WebCore::DocumentMarkerDetails::isAllowedFor):

  • dom/DocumentMarkerController.cpp:

(WebCore::DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange):

  • editing/CompositeEditCommand.cpp:

(WebCore::CompositeEditCommand::replaceTextInNodePreservingMarkers):

Location:
trunk/Source/WebCore
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r92375 r92441  
    516516    dom/Document.cpp
    517517    dom/DocumentMarkerController.cpp
     518    dom/DocumentMarker.cpp
    518519    dom/DocumentFragment.cpp
    519520    dom/DocumentParser.cpp
  • trunk/Source/WebCore/ChangeLog

    r92439 r92441  
     12011-08-04  MORITA Hajime  <morrita@google.com>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        DocumentMarker: Type specific details should be separately held by other object.
     6        https://bugs.webkit.org/show_bug.cgi?id=59855
     7
     8        - Introduced DocumentMarkerDetails abstract class and two its subclasses
     9          DocumentMarkerDescription and DocumentMarkerActiveMatch,
     10       
     11        - Replacing DocumentMarker::m_description and
     12          DocumentMarker::m_activeMatch with these new details classes.
     13       
     14        No new tests. No behavior change.
     15
     16        * CMakeLists.txt:
     17        * GNUmakefile.list.am:
     18        * WebCore.gypi:
     19        * WebCore.pro:
     20        * WebCore.vcproj/WebCore.vcproj:
     21        * WebCore.xcodeproj/project.pbxproj:
     22        * dom/DOMAllInOne.cpp:
     23        * dom/DocumentMarker.cpp: Added.
     24        (WebCore::emptyDescription):
     25        (WebCore::DocumentMarkerDetails::DocumentMarkerDetails):
     26        (WebCore::DocumentMarkerDetails::~DocumentMarkerDetails):
     27        (WebCore::DocumentMarkerDescription::description):
     28        (WebCore::DocumentMarkerDescription::isDescription):       
     29        (WebCore::DocumentMarkerDescription::DocumentMarkerDescription):
     30        (WebCore::DocumentMarkerDescription::createUnlessEmpty):
     31        (WebCore::DocumentMarkerDescription::compatibleTypes):
     32        (WebCore::DocumentMarkerTextMatch::activeMatch):   
     33        (WebCore::DocumentMarkerTextMatch::isTextMatch):
     34        (WebCore::DocumentMarkerTextMatch::DocumentMarkerTextMatch):
     35        (WebCore::DocumentMarkerTextMatch::instanceFor):
     36        (WebCore::DocumentMarkerTextMatch::compatibleTypes):
     37        (WebCore::DocumentMarker::DocumentMarker):
     38        (WebCore::DocumentMarker::shiftOffsets):
     39        (WebCore::DocumentMarker::setActiveMatch):
     40        (WebCore::DocumentMarker::description):
     41        (WebCore::DocumentMarker::activeMatch):
     42        * dom/DocumentMarker.h:
     43        (WebCore::DocumentMarker::details):
     44        (WebCore::DocumentMarker::clearDetails):
     45        (WebCore::DocumentMarkerDetails::isDescription):
     46        (WebCore::DocumentMarkerDetails::isTextMatch):
     47        (WebCore::DocumentMarkerDetails::isAllowedFor):
     48        * dom/DocumentMarkerController.cpp:
     49        (WebCore::DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange):
     50        * editing/CompositeEditCommand.cpp:
     51        (WebCore::CompositeEditCommand::replaceTextInNodePreservingMarkers):
     52
    1532011-08-04  Scott Graham  <scottmg@chromium.org>
    254
  • trunk/Source/WebCore/GNUmakefile.list.am

    r92375 r92441  
    11331133        Source/WebCore/dom/DocumentMarkerController.cpp \
    11341134        Source/WebCore/dom/DocumentMarkerController.h \
     1135        Source/WebCore/dom/DocumentMarker.cpp \
    11351136        Source/WebCore/dom/DocumentMarker.h \
    11361137        Source/WebCore/dom/DocumentOrderedMap.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r92390 r92441  
    52675267            'dom/DocumentFragment.cpp',
    52685268            'dom/DocumentMarkerController.cpp',
     5269            'dom/DocumentMarker.cpp',
    52695270            'dom/DocumentOrderedMap.cpp',
    52705271            'dom/DocumentParser.cpp',
  • trunk/Source/WebCore/WebCore.pro

    r92375 r92441  
    479479    dom/DocumentFragment.cpp \
    480480    dom/DocumentMarkerController.cpp \
     481    dom/DocumentMarker.cpp \
    481482    dom/DocumentOrderedMap.cpp \
    482483    dom/DocumentParser.cpp \
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r92390 r92441  
    4475144751                        </File>
    4475244752                        <File
     44753                                RelativePath="..\dom\DocumentMarker.cpp"
     44754                                >
     44755                                <FileConfiguration
     44756                                        Name="Debug|Win32"
     44757                                        ExcludedFromBuild="true"
     44758                                        >
     44759                                        <Tool
     44760                                                Name="VCCLCompilerTool"
     44761                                        />
     44762                                </FileConfiguration>
     44763                                <FileConfiguration
     44764                                        Name="Release|Win32"
     44765                                        ExcludedFromBuild="true"
     44766                                        >
     44767                                        <Tool
     44768                                                Name="VCCLCompilerTool"
     44769                                        />
     44770                                </FileConfiguration>
     44771                                <FileConfiguration
     44772                                        Name="Debug_Cairo_CFLite|Win32"
     44773                                        ExcludedFromBuild="true"
     44774                                        >
     44775                                        <Tool
     44776                                                Name="VCCLCompilerTool"
     44777                                        />
     44778                                </FileConfiguration>
     44779                                <FileConfiguration
     44780                                        Name="Release_Cairo_CFLite|Win32"
     44781                                        ExcludedFromBuild="true"
     44782                                        >
     44783                                        <Tool
     44784                                                Name="VCCLCompilerTool"
     44785                                        />
     44786                                </FileConfiguration>
     44787                                <FileConfiguration
     44788                                        Name="Debug_All|Win32"
     44789                                        ExcludedFromBuild="true"
     44790                                        >
     44791                                        <Tool
     44792                                                Name="VCCLCompilerTool"
     44793                                        />
     44794                                </FileConfiguration>
     44795                                <FileConfiguration
     44796                                        Name="Production|Win32"
     44797                                        ExcludedFromBuild="true"
     44798                                        >
     44799                                        <Tool
     44800                                                Name="VCCLCompilerTool"
     44801                                        />
     44802                                </FileConfiguration>
     44803                        </File>
     44804                        <File
    4475344805                                RelativePath="..\dom\DocumentOrderedMap.cpp"
    4475444806                                >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r92375 r92441  
    33743374                A77B41A012E675A90054343D /* TextEventInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = A77B419F12E675A90054343D /* TextEventInputType.h */; settings = {ATTRIBUTES = (Private, ); }; };
    33753375                A77D0012133B0AEB00D6658C /* TextChecking.h in Headers */ = {isa = PBXBuildFile; fileRef = A77D0011133B0AEB00D6658C /* TextChecking.h */; settings = {ATTRIBUTES = (Private, ); }; };
     3376                A781C6A713828B5D0012A62A /* DocumentMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A781C6A613828B5D0012A62A /* DocumentMarker.cpp */; };
    33763377                A784941B0B5FE507001E237A /* Clipboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A784941A0B5FE507001E237A /* Clipboard.cpp */; };
    33773378                A78E526F1346BD1700AD9C31 /* MeterShadowElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A78E526D1346BD1700AD9C31 /* MeterShadowElement.cpp */; };
     
    99699970                A77B419F12E675A90054343D /* TextEventInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEventInputType.h; sourceTree = "<group>"; };
    99709971                A77D0011133B0AEB00D6658C /* TextChecking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextChecking.h; sourceTree = "<group>"; };
     9972                A781C6A613828B5D0012A62A /* DocumentMarker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentMarker.cpp; sourceTree = "<group>"; };
    99719973                A784941A0B5FE507001E237A /* Clipboard.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Clipboard.cpp; sourceTree = "<group>"; };
    99729974                A78E526D1346BD1700AD9C31 /* MeterShadowElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MeterShadowElement.cpp; sourceTree = "<group>"; };
     
    1977419776                                490C47CD13E82D1800F7AB82 /* DispatchTask.h */,
    1977519777                                A8185F3409765765005826D9 /* Document.cpp */,
     19778                                A781C6A613828B5D0012A62A /* DocumentMarker.cpp */,
    1977619779                                A8185F3809765765005826D9 /* Document.h */,
    1977719780                                6548E24809E1E04D00AF8020 /* Document.idl */,
     
    2394223945                                93E227E00AF589AD00D48324 /* DocumentLoader.cpp in Sources */,
    2394323946                                1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */,
     23947                                A781C6A713828B5D0012A62A /* DocumentMarker.cpp in Sources */,
    2394423948                                CE057FA51220731100A476D5 /* DocumentMarkerController.cpp in Sources */,
    2394523949                                14947FFD12F80CD200A0F631 /* DocumentOrderedMap.cpp in Sources */,
  • trunk/Source/WebCore/dom/DOMAllInOne.cpp

    r92365 r92441  
    5959#include "Document.cpp"
    6060#include "DocumentFragment.cpp"
     61#include "DocumentMarker.cpp"
    6162#include "DocumentMarkerController.cpp"
    6263#include "DocumentOrderedMap.cpp"
  • trunk/Source/WebCore/dom/DocumentMarker.h

    r89452 r92441  
    2626#include "PlatformString.h"
    2727#include <wtf/Forward.h>
     28#include <wtf/RefCounted.h>
     29#include <wtf/RefPtr.h>
    2830
    2931
    3032namespace WebCore {
     33
     34class DocumentMarkerDetails;
    3135
    3236// A range of a node within a document that is "marked", such as the range of a misspelled word.
     
    9599    unsigned startOffset() const { return m_startOffset; }
    96100    unsigned endOffset() const { return m_endOffset; }
    97     const String& description() const { return m_description; }
    98     bool hasDescription() const { return !m_description.isEmpty(); }
    99     bool activeMatch() const { return m_activeMatch; }
     101
     102    const String& description() const;
     103    bool activeMatch() const;
     104    DocumentMarkerDetails* details() const;
    100105
    101106    void setActiveMatch(bool);
    102     void clearDescription() { m_description = String(); }
     107    void clearDetails() { m_details.clear(); }
    103108
    104109    // Offset modifications are done by DocumentMarkerController.
     
    122127    unsigned m_startOffset;
    123128    unsigned m_endOffset;
    124     String m_description;
    125     bool m_activeMatch;
     129    RefPtr<DocumentMarkerDetails> m_details;
    126130};
    127131
    128 inline DocumentMarker::DocumentMarker()
    129     : m_type(Spelling), m_startOffset(0), m_endOffset(0), m_activeMatch(false)
     132inline DocumentMarkerDetails* DocumentMarker::details() const
    130133{
     134    return m_details.get();
    131135}
    132136
    133 inline DocumentMarker::DocumentMarker(MarkerType type, unsigned startOffset, unsigned endOffset)
    134     : m_type(type), m_startOffset(startOffset), m_endOffset(endOffset), m_activeMatch(false)
     137class DocumentMarkerDetails : public RefCounted<DocumentMarkerDetails>
    135138{
    136 }
    137 
    138 inline DocumentMarker::DocumentMarker(MarkerType type, unsigned startOffset, unsigned endOffset, const String& description)
    139     : m_type(type), m_startOffset(startOffset), m_endOffset(endOffset), m_description(description), m_activeMatch(false)
    140 {
    141     ASSERT(type == DocumentMarker::Grammar || DocumentMarker::Autocorrected);
    142 }
    143 
    144 inline DocumentMarker::DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch)
    145     : m_type(DocumentMarker::TextMatch), m_startOffset(startOffset), m_endOffset(endOffset), m_activeMatch(activeMatch)
    146 {
    147 }
    148 
    149 inline void DocumentMarker::shiftOffsets(int delta)
    150 {
    151     m_startOffset += delta;
    152     m_endOffset +=  delta;
    153 }
    154 
    155 inline void DocumentMarker::setActiveMatch(bool active)
    156 {
    157     ASSERT(m_type == DocumentMarker::TextMatch);
    158     m_activeMatch = active;
    159 }
     139public:
     140    DocumentMarkerDetails() { }
     141    virtual ~DocumentMarkerDetails();
     142    virtual bool isDescription() const { return false; }
     143    virtual bool isTextMatch() const { return false; }
     144};
    160145
    161146} // namespace WebCore
  • trunk/Source/WebCore/dom/DocumentMarkerController.cpp

    r89513 r92441  
    653653            }
    654654
    655             marker.clearDescription();
     655            marker.clearDetails();
    656656        }
    657657    }
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r91308 r92441  
    354354    replaceTextInNode(node, offset, count, replacementText);
    355355    RefPtr<Range> newRange = Range::create(document(), node, offset, node, offset + replacementText.length());
    356     for (size_t i = 0; i < markers.size(); ++i) {
    357         if (markers[i].hasDescription())
    358             markerController->addMarker(newRange.get(), markers[i].type(), markers[i].description());
    359         else
    360             markerController->addMarker(newRange.get(), markers[i].type());
    361     }
     356    for (size_t i = 0; i < markers.size(); ++i)
     357        markerController->addMarker(newRange.get(), markers[i].type(), markers[i].description());
    362358}
    363359
Note: See TracChangeset for help on using the changeset viewer.