SelectionHandler.h [plain text]
#ifndef SelectionHandler_h
#define SelectionHandler_h
#include "BlackBerryPlatformIntRectRegion.h"
#include "BlackBerryPlatformPrimitives.h"
#include "BlackBerryPlatformStopWatch.h"
#include "Color.h"
#include "TextGranularity.h"
#include <wtf/Vector.h>
namespace WTF {
class String;
}
namespace WebCore {
class FloatQuad;
class IntPoint;
class IntRect;
class Node;
class VisiblePosition;
class VisibleSelection;
}
namespace BlackBerry {
namespace Platform {
class String;
}
namespace WebKit {
class FatFingersResult;
class WebPagePrivate;
class SelectionHandler {
public:
SelectionHandler(WebPagePrivate*);
~SelectionHandler();
bool isSelectionActive() { return m_selectionActive; }
void setSelectionActive(bool active) { m_selectionActive = active; }
void cancelSelection();
BlackBerry::Platform::String selectedText() const;
bool selectionContains(const WebCore::IntPoint&);
void setSelection(WebCore::IntPoint start, WebCore::IntPoint end);
void selectAtPoint(const WebCore::IntPoint&, SelectionExpansionType);
void selectObject(const WebCore::IntPoint&, WebCore::TextGranularity);
void selectObject(WebCore::TextGranularity);
void selectObject(WebCore::Node*);
void selectionPositionChanged(bool forceUpdateWithoutChange = false);
void setCaretPosition(const WebCore::IntPoint&);
bool lastUpdatedEndPointIsValid() const { return m_lastUpdatedEndPointIsValid; }
void inputHandlerDidFinishProcessingChange();
void expandSelection(bool isScrollStarted);
void setOverlayExpansionHeight(int dy) { m_overlayExpansionHeight = dy; }
void setParagraphExpansionScrollMargin(const WebCore::IntSize&);
void setSelectionViewportSize(const WebCore::IntSize& selectionViewportSize) { m_selectionViewportSize = selectionViewportSize; }
void setSelectionSubframeViewportRect(const WebCore::IntRect& selectionSubframeViewportRect) { m_selectionSubframeViewportRect = selectionSubframeViewportRect; }
WebCore::IntRect selectionViewportRect() const;
private:
void notifyCaretPositionChangedIfNeeded(bool userTouchTriggeredOnTextField);
void caretPositionChanged(bool userTouchTriggered);
void regionForTextQuads(WTF::Vector<WebCore::FloatQuad>&, BlackBerry::Platform::IntRectRegion&, bool shouldClipToVisibleContent = true) const;
WebCore::IntRect clippingRectForVisibleContent() const;
bool updateOrHandleInputSelection(WebCore::VisibleSelection& newSelection, const WebCore::IntPoint& relativeStart, const WebCore::IntPoint& relativeEnd);
WebCore::Node* DOMContainerNodeForVisiblePosition(const WebCore::VisiblePosition&) const;
bool shouldUpdateSelectionOrCaretForPoint(const WebCore::IntPoint&, const WebCore::IntRect&, bool startCaret = true) const;
unsigned extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection);
WebCore::IntPoint clipPointToVisibleContainer(const WebCore::IntPoint&) const;
void selectNextParagraph();
void drawAnimationOverlay(BlackBerry::Platform::IntRectRegion, bool isExpandingOverlayAtConstantRate, bool isStartOfSelection = false);
Platform::IntRectRegion regionForSelectionQuads(WebCore::VisibleSelection);
bool findNextAnimationOverlayRegion();
bool ensureSelectedTextVisible(const WebCore::IntPoint&, bool scrollIfNeeded);
bool expandSelectionToGranularity(WebCore::Frame*, WebCore::VisibleSelection, WebCore::TextGranularity, bool isInputMode);
bool inputNodeOverridesTouch() const;
BlackBerry::Platform::RequestedHandlePosition requestedSelectionHandlePosition(const WebCore::VisibleSelection&) const;
bool selectNodeIfFatFingersResultIsLink(FatFingersResult);
WebCore::IntRect startCaretViewportRect(const WebCore::IntPoint& frameOffset) const;
WebPagePrivate* m_webPage;
bool m_selectionActive;
bool m_caretActive;
bool m_lastUpdatedEndPointIsValid;
bool m_didSuppressCaretPositionChangedNotification;
BlackBerry::Platform::IntRectRegion m_lastSelectionRegion;
WebCore::VisiblePosition m_animationOverlayStartPos;
WebCore::VisiblePosition m_animationOverlayEndPos;
BlackBerry::Platform::IntRectRegion m_currentAnimationOverlayRegion;
BlackBerry::Platform::IntRectRegion m_nextAnimationOverlayRegion;
int m_overlayExpansionHeight;
WebCore::Color m_animationHighlightColor;
BlackBerry::Platform::StopWatch m_timer;
WebCore::IntSize m_scrollMargin;
WebCore::IntSize m_selectionViewportSize;
WebCore::IntRect m_selectionSubframeViewportRect;
WebCore::VisibleSelection m_lastSelection;
};
}
}
#endif // SelectionHandler_h