Skip to content
Permalink
Browse files
2011-05-17 MORITA Hajime <morrita@google.com>
        Reviewed by Tony Chang.

        [Refactoring] Member variables of DocumentMarker should be encapsulated.
        https://bugs.webkit.org/show_bug.cgi?id=56814

        - Moved DocumentMarker's member variables to private and added getters for them.
        - Added DocumentMarker setters and constructors, which contain assertions against m_type values
          because description and activeMatch are used with specific type of MarkerType.
        - Moved chromium's WebKit::WebFrameImpl::addMarker() to DocumentMarkerController::addTextMatchMarker()
          because it accesses DocumentMarker internals.
        - Moved a version of DMC::addMarker() to private and add alternatives that hide
          internals of DocumentMarker. (The internal will be renewed by upcoming change.)

        * dom/DocumentMarker.h:
        (WebCore::DocumentMarker::type):
        (WebCore::DocumentMarker::startOffset):
        (WebCore::DocumentMarker::endOffset):
        (WebCore::DocumentMarker::description):
        (WebCore::DocumentMarker::hasDescription):
        (WebCore::DocumentMarker::activeMatch):
        (WebCore::DocumentMarker::clearDescription):
        (WebCore::DocumentMarker::setStartOffset):
        (WebCore::DocumentMarker::setEndOffset):
        (WebCore::DocumentMarker::operator==):
        (WebCore::DocumentMarker::DocumentMarker):
        (WebCore::DocumentMarker::shiftOffsets):
        (WebCore::DocumentMarker::setActiveMatch):
        * dom/DocumentMarkerController.cpp:
        (WebCore::DocumentMarkerController::addMarker):
        (WebCore::DocumentMarkerController::addTextMatchMarker):
        (WebCore::DocumentMarkerController::copyMarkers):
        (WebCore::DocumentMarkerController::removeMarkers):
        (WebCore::DocumentMarkerController::markerContainingPoint):
        (WebCore::DocumentMarkerController::markersInRange):
        (WebCore::DocumentMarkerController::renderedRectsForMarkers):
        (WebCore::DocumentMarkerController::removeMarkersFromList):
        (WebCore::DocumentMarkerController::repaintMarkers):
        (WebCore::DocumentMarkerController::shiftMarkers):
        (WebCore::DocumentMarkerController::setMarkersActive):
        (WebCore::DocumentMarkerController::hasMarkers):
        (WebCore::DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange):
        (WebCore::DocumentMarkerController::showMarkers):
        * dom/DocumentMarkerController.h:
        * editing/CompositeEditCommand.cpp:
        (WebCore::CompositeEditCommand::replaceTextInNodePreservingMarkers):
        * editing/DeleteSelectionCommand.cpp:
        (WebCore::DeleteSelectionCommand::originalStringForAutocorrectionAtBeginningOfSelection):
        * editing/Editor.cpp:
        (WebCore::Editor::selectionStartHasMarkerFor):
        * editing/SpellingCorrectionController.cpp:
        (WebCore::SpellingCorrectionController::respondToChangedSelection):
        * editing/SpellingCorrectionController.h:
        (WebCore::SpellingCorrectionController::shouldStartTimerFor):
        * rendering/HitTestResult.cpp:
        (WebCore::HitTestResult::spellingToolTip):
        (WebCore::HitTestResult::replacedString):
        * rendering/InlineTextBox.cpp:
        (WebCore::InlineTextBox::paintSpellingOrGrammarMarker):
        (WebCore::InlineTextBox::paintTextMatchMarker):
        (WebCore::InlineTextBox::computeRectForReplacementMarker):
        (WebCore::InlineTextBox::paintDocumentMarkers):
        * rendering/svg/SVGInlineFlowBox.cpp:
        (WebCore::SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer):
2011-05-17  MORITA Hajime  <morrita@google.com>

        Reviewed by Tony Chang.

        [Refactoring] Member variables of DocumentMarker should be encapsulated.
        https://bugs.webkit.org/show_bug.cgi?id=56814

        Moved addMarker() implementation to
        WebCore::DocumentMarkerController::addTextMatchMarker().

        * src/WebFrameImpl.cpp:
        (WebKit::WebFrameImpl::addMarker):

Canonical link: https://commits.webkit.org/76455@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@86813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
omo committed May 19, 2011
1 parent 889c3b5 commit ac3be99c7eca00a2cdd4cdbd7ff13df7507a2214
@@ -1,3 +1,69 @@
2011-05-17 MORITA Hajime <morrita@google.com>

Reviewed by Tony Chang.

[Refactoring] Member variables of DocumentMarker should be encapsulated.
https://bugs.webkit.org/show_bug.cgi?id=56814

- Moved DocumentMarker's member variables to private and added getters for them.
- Added DocumentMarker setters and constructors, which contain assertions against m_type values
because description and activeMatch are used with specific type of MarkerType.
- Moved chromium's WebKit::WebFrameImpl::addMarker() to DocumentMarkerController::addTextMatchMarker()
because it accesses DocumentMarker internals.
- Moved a version of DMC::addMarker() to private and add alternatives that hide
internals of DocumentMarker. (The internal will be renewed by upcoming change.)

* dom/DocumentMarker.h:
(WebCore::DocumentMarker::type):
(WebCore::DocumentMarker::startOffset):
(WebCore::DocumentMarker::endOffset):
(WebCore::DocumentMarker::description):
(WebCore::DocumentMarker::hasDescription):
(WebCore::DocumentMarker::activeMatch):
(WebCore::DocumentMarker::clearDescription):
(WebCore::DocumentMarker::setStartOffset):
(WebCore::DocumentMarker::setEndOffset):
(WebCore::DocumentMarker::operator==):
(WebCore::DocumentMarker::DocumentMarker):
(WebCore::DocumentMarker::shiftOffsets):
(WebCore::DocumentMarker::setActiveMatch):
* dom/DocumentMarkerController.cpp:
(WebCore::DocumentMarkerController::addMarker):
(WebCore::DocumentMarkerController::addTextMatchMarker):
(WebCore::DocumentMarkerController::copyMarkers):
(WebCore::DocumentMarkerController::removeMarkers):
(WebCore::DocumentMarkerController::markerContainingPoint):
(WebCore::DocumentMarkerController::markersInRange):
(WebCore::DocumentMarkerController::renderedRectsForMarkers):
(WebCore::DocumentMarkerController::removeMarkersFromList):
(WebCore::DocumentMarkerController::repaintMarkers):
(WebCore::DocumentMarkerController::shiftMarkers):
(WebCore::DocumentMarkerController::setMarkersActive):
(WebCore::DocumentMarkerController::hasMarkers):
(WebCore::DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange):
(WebCore::DocumentMarkerController::showMarkers):
* dom/DocumentMarkerController.h:
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::replaceTextInNodePreservingMarkers):
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::originalStringForAutocorrectionAtBeginningOfSelection):
* editing/Editor.cpp:
(WebCore::Editor::selectionStartHasMarkerFor):
* editing/SpellingCorrectionController.cpp:
(WebCore::SpellingCorrectionController::respondToChangedSelection):
* editing/SpellingCorrectionController.h:
(WebCore::SpellingCorrectionController::shouldStartTimerFor):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::spellingToolTip):
(WebCore::HitTestResult::replacedString):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paintSpellingOrGrammarMarker):
(WebCore::InlineTextBox::paintTextMatchMarker):
(WebCore::InlineTextBox::computeRectForReplacementMarker):
(WebCore::InlineTextBox::paintDocumentMarkers):
* rendering/svg/SVGInlineFlowBox.cpp:
(WebCore::SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer):

2011-05-18 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.
@@ -33,7 +33,8 @@ namespace WebCore {
// It optionally includes a description that could be displayed in the user interface.
// It also optionally includes a flag specifying whether the match is active, which is ignored
// for all types other than type TextMatch.
struct DocumentMarker {
class DocumentMarker {
public:
enum MarkerType {
Spelling = 1 << 0,
Grammar = 1 << 1,
@@ -84,24 +85,79 @@ struct DocumentMarker {
{
}
};

MarkerType type;
unsigned startOffset;
unsigned endOffset;
String description;
bool activeMatch;

DocumentMarker();
DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset);
DocumentMarker(MarkerType, unsigned startOffset, unsigned endOffset, const String& description);
DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch);

MarkerType type() const { return m_type; }
unsigned startOffset() const { return m_startOffset; }
unsigned endOffset() const { return m_endOffset; }
const String& description() const { return m_description; }
bool hasDescription() const { return !m_description.isEmpty(); }
bool activeMatch() const { return m_activeMatch; }

void setActiveMatch(bool);
void clearDescription() { m_description = String(); }

// Offset modifications are done by DocumentMarkerController.
// Other classes should not call following setters.
void setStartOffset(unsigned offset) { m_startOffset = offset; }
void setEndOffset(unsigned offset) { m_endOffset = offset; }
void shiftOffsets(int delta);

bool operator==(const DocumentMarker& o) const
{
return type == o.type && startOffset == o.startOffset && endOffset == o.endOffset;
return type() == o.type() && startOffset() == o.startOffset() && endOffset() == o.endOffset();
}

bool operator!=(const DocumentMarker& o) const
{
return !(*this == o);
}

private:
MarkerType m_type;
unsigned m_startOffset;
unsigned m_endOffset;
String m_description;
bool m_activeMatch;
};

inline DocumentMarker::DocumentMarker()
: m_type(Spelling), m_startOffset(0), m_endOffset(0), m_activeMatch(false)
{
}

inline DocumentMarker::DocumentMarker(MarkerType type, unsigned startOffset, unsigned endOffset)
: m_type(type), m_startOffset(startOffset), m_endOffset(endOffset), m_activeMatch(false)
{
}

inline DocumentMarker::DocumentMarker(MarkerType type, unsigned startOffset, unsigned endOffset, const String& description)
: m_type(type), m_startOffset(startOffset), m_endOffset(endOffset), m_description(description), m_activeMatch(false)
{
ASSERT(type == DocumentMarker::Grammar || DocumentMarker::Autocorrected);
}

inline DocumentMarker::DocumentMarker(unsigned startOffset, unsigned endOffset, bool activeMatch)
: m_type(DocumentMarker::TextMatch), m_startOffset(startOffset), m_endOffset(endOffset), m_activeMatch(activeMatch)
{
}

inline void DocumentMarker::shiftOffsets(int delta)
{
m_startOffset += delta;
m_endOffset += delta;
}

inline void DocumentMarker::setActiveMatch(bool active)
{
ASSERT(m_type == DocumentMarker::TextMatch);
m_activeMatch = active;
}

} // namespace WebCore

#endif // DocumentMarker_h

0 comments on commit ac3be99

Please sign in to comment.