| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) | 2 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "core/dom/Node.h" | 25 #include "core/dom/Node.h" |
| 26 #include "core/dom/NodeComputedStyle.h" | 26 #include "core/dom/NodeComputedStyle.h" |
| 27 #include "core/dom/Text.h" | 27 #include "core/dom/Text.h" |
| 28 #include "core/editing/Editor.h" | 28 #include "core/editing/Editor.h" |
| 29 #include "core/frame/FrameView.h" | 29 #include "core/frame/FrameView.h" |
| 30 #include "core/frame/LocalFrame.h" | 30 #include "core/frame/LocalFrame.h" |
| 31 #include "core/html/HTMLFrameOwnerElement.h" | 31 #include "core/html/HTMLFrameOwnerElement.h" |
| 32 #include "core/layout/LayoutBox.h" | 32 #include "core/layout/LayoutBox.h" |
| 33 #include "core/layout/LayoutObject.h" | 33 #include "core/layout/LayoutObject.h" |
| 34 #include "core/layout/LayoutText.h" | 34 #include "core/layout/LayoutText.h" |
| 35 #include "core/layout/api/SelectionState.h" |
| 35 #include "core/style/ComputedStyle.h" | 36 #include "core/style/ComputedStyle.h" |
| 36 #include "platform/geometry/FloatPoint.h" | 37 #include "platform/geometry/FloatPoint.h" |
| 37 #include "platform/geometry/FloatQuad.h" | 38 #include "platform/geometry/FloatQuad.h" |
| 38 #include "platform/geometry/IntSize.h" | 39 #include "platform/geometry/IntSize.h" |
| 39 #include "platform/text/TextBreakIterator.h" | 40 #include "platform/text/TextBreakIterator.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 namespace TouchAdjustment { | 44 namespace TouchAdjustment { |
| 44 | 45 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 if (node->layoutObject()->isImage()) | 125 if (node->layoutObject()->isImage()) |
| 125 return true; | 126 return true; |
| 126 if (node->layoutObject()->isMedia()) | 127 if (node->layoutObject()->isMedia()) |
| 127 return true; | 128 return true; |
| 128 if (node->layoutObject()->canBeSelectionLeaf()) { | 129 if (node->layoutObject()->canBeSelectionLeaf()) { |
| 129 // If the context menu gesture will trigger a selection all selectable n
odes are valid targets. | 130 // If the context menu gesture will trigger a selection all selectable n
odes are valid targets. |
| 130 if (node->layoutObject()->frame()->editor().behavior().shouldSelectOnCon
textualMenuClick()) | 131 if (node->layoutObject()->frame()->editor().behavior().shouldSelectOnCon
textualMenuClick()) |
| 131 return true; | 132 return true; |
| 132 // Only the selected part of the layoutObject is a valid target, but thi
s will be corrected in | 133 // Only the selected part of the layoutObject is a valid target, but thi
s will be corrected in |
| 133 // appendContextSubtargetsForNode. | 134 // appendContextSubtargetsForNode. |
| 134 if (node->layoutObject()->selectionState() != LayoutObject::SelectionNon
e) | 135 if (node->layoutObject()->selectionState() != SelectionNone) |
| 135 return true; | 136 return true; |
| 136 } | 137 } |
| 137 return false; | 138 return false; |
| 138 } | 139 } |
| 139 | 140 |
| 140 static inline void appendQuadsToSubtargetList(Vector<FloatQuad>& quads, Node* no
de, SubtargetGeometryList& subtargets) | 141 static inline void appendQuadsToSubtargetList(Vector<FloatQuad>& quads, Node* no
de, SubtargetGeometryList& subtargets) |
| 141 { | 142 { |
| 142 Vector<FloatQuad>::const_iterator it = quads.begin(); | 143 Vector<FloatQuad>::const_iterator it = quads.begin(); |
| 143 const Vector<FloatQuad>::const_iterator end = quads.end(); | 144 const Vector<FloatQuad>::const_iterator end = quads.end(); |
| 144 for (; it != end; ++it) | 145 for (; it != end; ++it) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 int offset; | 179 int offset; |
| 179 while ((offset = wordIterator->next()) != -1) { | 180 while ((offset = wordIterator->next()) != -1) { |
| 180 if (isWordTextBreak(wordIterator)) { | 181 if (isWordTextBreak(wordIterator)) { |
| 181 Vector<FloatQuad> quads; | 182 Vector<FloatQuad> quads; |
| 182 textLayoutObject->absoluteQuadsForRange(quads, lastOffset, offse
t); | 183 textLayoutObject->absoluteQuadsForRange(quads, lastOffset, offse
t); |
| 183 appendQuadsToSubtargetList(quads, textNode, subtargets); | 184 appendQuadsToSubtargetList(quads, textNode, subtargets); |
| 184 } | 185 } |
| 185 lastOffset = offset; | 186 lastOffset = offset; |
| 186 } | 187 } |
| 187 } else { | 188 } else { |
| 188 if (textLayoutObject->selectionState() == LayoutObject::SelectionNone) | 189 if (textLayoutObject->selectionState() == SelectionNone) |
| 189 return appendBasicSubtargetsForNode(node, subtargets); | 190 return appendBasicSubtargetsForNode(node, subtargets); |
| 190 // If selected, make subtargets out of only the selected part of the tex
t. | 191 // If selected, make subtargets out of only the selected part of the tex
t. |
| 191 int startPos, endPos; | 192 int startPos, endPos; |
| 192 switch (textLayoutObject->selectionState()) { | 193 switch (textLayoutObject->selectionState()) { |
| 193 case LayoutObject::SelectionInside: | 194 case SelectionInside: |
| 194 startPos = 0; | 195 startPos = 0; |
| 195 endPos = textLayoutObject->textLength(); | 196 endPos = textLayoutObject->textLength(); |
| 196 break; | 197 break; |
| 197 case LayoutObject::SelectionStart: | 198 case SelectionStart: |
| 198 textLayoutObject->selectionStartEnd(startPos, endPos); | 199 textLayoutObject->selectionStartEnd(startPos, endPos); |
| 199 endPos = textLayoutObject->textLength(); | 200 endPos = textLayoutObject->textLength(); |
| 200 break; | 201 break; |
| 201 case LayoutObject::SelectionEnd: | 202 case SelectionEnd: |
| 202 textLayoutObject->selectionStartEnd(startPos, endPos); | 203 textLayoutObject->selectionStartEnd(startPos, endPos); |
| 203 startPos = 0; | 204 startPos = 0; |
| 204 break; | 205 break; |
| 205 case LayoutObject::SelectionBoth: | 206 case SelectionBoth: |
| 206 textLayoutObject->selectionStartEnd(startPos, endPos); | 207 textLayoutObject->selectionStartEnd(startPos, endPos); |
| 207 break; | 208 break; |
| 208 default: | 209 default: |
| 209 ASSERT_NOT_REACHED(); | 210 ASSERT_NOT_REACHED(); |
| 210 return; | 211 return; |
| 211 } | 212 } |
| 212 Vector<FloatQuad> quads; | 213 Vector<FloatQuad> quads; |
| 213 textLayoutObject->absoluteQuadsForRange(quads, startPos, endPos); | 214 textLayoutObject->absoluteQuadsForRange(quads, startPos, endPos); |
| 214 appendQuadsToSubtargetList(quads, textNode, subtargets); | 215 appendQuadsToSubtargetList(quads, textNode, subtargets); |
| 215 } | 216 } |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 499 |
| 499 bool findBestZoomableArea(Node*& targetNode, IntRect& targetArea, const IntPoint
& touchHotspot, const IntRect& touchArea, const WillBeHeapVector<RefPtrWillBeMem
ber<Node>>& nodes) | 500 bool findBestZoomableArea(Node*& targetNode, IntRect& targetArea, const IntPoint
& touchHotspot, const IntRect& touchArea, const WillBeHeapVector<RefPtrWillBeMem
ber<Node>>& nodes) |
| 500 { | 501 { |
| 501 IntPoint targetPoint; | 502 IntPoint targetPoint; |
| 502 TouchAdjustment::SubtargetGeometryList subtargets; | 503 TouchAdjustment::SubtargetGeometryList subtargets; |
| 503 TouchAdjustment::compileZoomableSubtargets(nodes, subtargets); | 504 TouchAdjustment::compileZoomableSubtargets(nodes, subtargets); |
| 504 return TouchAdjustment::findNodeWithLowestDistanceMetric(targetNode, targetP
oint, targetArea, touchHotspot, touchArea, subtargets, TouchAdjustment::zoomable
IntersectionQuotient); | 505 return TouchAdjustment::findNodeWithLowestDistanceMetric(targetNode, targetP
oint, targetArea, touchHotspot, touchArea, subtargets, TouchAdjustment::zoomable
IntersectionQuotient); |
| 505 } | 506 } |
| 506 | 507 |
| 507 } // namespace blink | 508 } // namespace blink |
| OLD | NEW |