OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #include "public/web/WebSurroundingText.h" | 26 #include "public/web/WebSurroundingText.h" |
27 | 27 |
28 #include "core/dom/Element.h" | 28 #include "core/dom/Element.h" |
29 #include "core/dom/Node.h" | 29 #include "core/dom/Node.h" |
30 #include "core/dom/Range.h" | 30 #include "core/dom/Range.h" |
31 #include "core/dom/Text.h" | 31 #include "core/dom/Text.h" |
32 #include "core/editing/FrameSelection.h" | 32 #include "core/editing/FrameSelection.h" |
33 #include "core/editing/SurroundingText.h" | 33 #include "core/editing/SurroundingText.h" |
34 #include "core/editing/VisiblePosition.h" | 34 #include "core/editing/VisiblePosition.h" |
| 35 #include "core/frame/LocalFrame.h" |
| 36 #include "core/frame/WebLocalFrameBase.h" |
35 #include "core/layout/LayoutObject.h" | 37 #include "core/layout/LayoutObject.h" |
36 #include "public/platform/WebPoint.h" | 38 #include "public/platform/WebPoint.h" |
37 #include "public/web/WebHitTestResult.h" | 39 #include "public/web/WebHitTestResult.h" |
38 #include "web/WebLocalFrameImpl.h" | |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
41 | 42 |
42 WebSurroundingText::WebSurroundingText() {} | 43 WebSurroundingText::WebSurroundingText() {} |
43 | 44 |
44 WebSurroundingText::~WebSurroundingText() {} | 45 WebSurroundingText::~WebSurroundingText() {} |
45 | 46 |
46 void WebSurroundingText::Initialize(const WebNode& web_node, | 47 void WebSurroundingText::Initialize(const WebNode& web_node, |
47 const WebPoint& node_point, | 48 const WebPoint& node_point, |
48 size_t max_length) { | 49 size_t max_length) { |
(...skipping 14 matching lines...) Expand all Loading... |
63 private_.reset(new SurroundingText( | 64 private_.reset(new SurroundingText( |
64 CreateVisiblePosition(node->GetLayoutObject()->PositionForPoint( | 65 CreateVisiblePosition(node->GetLayoutObject()->PositionForPoint( |
65 static_cast<IntPoint>(node_point))) | 66 static_cast<IntPoint>(node_point))) |
66 .DeepEquivalent() | 67 .DeepEquivalent() |
67 .ParentAnchoredEquivalent(), | 68 .ParentAnchoredEquivalent(), |
68 max_length)); | 69 max_length)); |
69 } | 70 } |
70 | 71 |
71 void WebSurroundingText::InitializeFromCurrentSelection(WebLocalFrame* frame, | 72 void WebSurroundingText::InitializeFromCurrentSelection(WebLocalFrame* frame, |
72 size_t max_length) { | 73 size_t max_length) { |
73 LocalFrame* web_frame = ToWebLocalFrameImpl(frame)->GetFrame(); | 74 LocalFrame* web_frame = ToWebLocalFrameBase(frame)->GetFrame(); |
74 | 75 |
75 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets | 76 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets |
76 // needs to be audited. See http://crbug.com/590369 for more details. | 77 // needs to be audited. See http://crbug.com/590369 for more details. |
77 web_frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); | 78 web_frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); |
78 | 79 |
79 if (Range* range = | 80 if (Range* range = |
80 CreateRange(web_frame->Selection() | 81 CreateRange(web_frame->Selection() |
81 .ComputeVisibleSelectionInDOMTreeDeprecated() | 82 .ComputeVisibleSelectionInDOMTreeDeprecated() |
82 .ToNormalizedEphemeralRange())) { | 83 .ToNormalizedEphemeralRange())) { |
83 // TODO(xiaochengh): The followinng SurroundingText can hold a null Range, | 84 // TODO(xiaochengh): The followinng SurroundingText can hold a null Range, |
(...skipping 17 matching lines...) Expand all Loading... |
101 | 102 |
102 size_t WebSurroundingText::EndOffsetInTextContent() const { | 103 size_t WebSurroundingText::EndOffsetInTextContent() const { |
103 return private_->EndOffsetInContent(); | 104 return private_->EndOffsetInContent(); |
104 } | 105 } |
105 | 106 |
106 bool WebSurroundingText::IsNull() const { | 107 bool WebSurroundingText::IsNull() const { |
107 return !private_.get(); | 108 return !private_.get(); |
108 } | 109 } |
109 | 110 |
110 } // namespace blink | 111 } // namespace blink |
OLD | NEW |