diff options
Diffstat (limited to 'Source/WebKit')
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 38 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.h | 2 |
2 files changed, 38 insertions, 2 deletions
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 734eb76..dc4f70c 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -838,7 +838,8 @@ BaseLayerAndroid* WebViewCore::createBaseLayer(GraphicsLayerAndroid* root) Color viewBackground = view->baseBackgroundColor(); background = bodyHasCSSBackground ? viewBackground.blend(background) : viewBackground; } - bodyHasFixedBackgroundImage = style->hasFixedBackgroundImage(); + bodyHasFixedBackgroundImage = style->hasFixedBackgroundImage() + && FixedBackgroundImageLayerAndroid::GetCachedImage(style); } PicturePileLayerContent* content = new PicturePileLayerContent(m_content); @@ -1685,6 +1686,35 @@ IntPoint WebViewCore::convertGlobalContentToFrameContent(const IntPoint& point, return IntPoint(point.x() + frameOffset.x(), point.y() + frameOffset.y()); } +Position WebViewCore::trimSelectionPosition(const Position &start, const Position& stop) +{ + int direction = comparePositions(start, stop); + if (direction == 0) + return start; + bool forward = direction < 0; + EAffinity affinity = forward ? DOWNSTREAM : UPSTREAM; + bool move; + Position pos = start; + bool movedTooFar = false; + do { + move = true; + Node* node = pos.anchorNode(); + if (node && node->isTextNode() && node->renderer()) { + RenderText *textRenderer = toRenderText(node->renderer()); + move = !textRenderer->textLength(); + } + if (move) { + Position nextPos = forward ? pos.next() : pos.previous(); + movedTooFar = nextPos.isNull() || pos == nextPos + || ((comparePositions(nextPos, stop) < 0) != forward); + pos = nextPos; + } + } while (move && !movedTooFar); + if (movedTooFar) + pos = stop; + return pos; +} + void WebViewCore::selectText(int startX, int startY, int endX, int endY) { SelectionController* sc = focusedFrame()->selection(); @@ -1721,7 +1751,11 @@ void WebViewCore::selectText(int startX, int startY, int endX, int endY) endPosition = prevEndPosition; } - VisibleSelection selection(startPosition, endPosition); + Position start = startPosition.deepEquivalent(); + Position end = endPosition.deepEquivalent(); + start = trimSelectionPosition(start, end); + end = trimSelectionPosition(end, start); + VisibleSelection selection(start, end); // Only allow changes between caret positions or to text selection. bool selectChangeAllowed = (!selection.isCaret() || sc->isCaret()); if (selectChangeAllowed && sc->shouldChangeSelection(selection)) diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index b43262c..c6b26c6 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -734,6 +734,8 @@ namespace android { static WebCore::IntRect positionToTextRect(const WebCore::Position& position, WebCore::EAffinity affinity); static bool isLtr(const WebCore::Position& position); + static WebCore::Position trimSelectionPosition( + const WebCore::Position& start, const WebCore::Position& stop); // called from constructor, to add this to a global list static void addInstance(WebViewCore*); |