Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1407)

Side by Side Diff: Source/web/WebLocalFrameImpl.cpp

Issue 294073005: Extend WebSurroundingText to accept a WebRange. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase and use int Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 #include "core/dom/IconURL.h" 87 #include "core/dom/IconURL.h"
88 #include "core/dom/MessagePort.h" 88 #include "core/dom/MessagePort.h"
89 #include "core/dom/Node.h" 89 #include "core/dom/Node.h"
90 #include "core/dom/NodeTraversal.h" 90 #include "core/dom/NodeTraversal.h"
91 #include "core/dom/shadow/ShadowRoot.h" 91 #include "core/dom/shadow/ShadowRoot.h"
92 #include "core/editing/Editor.h" 92 #include "core/editing/Editor.h"
93 #include "core/editing/FrameSelection.h" 93 #include "core/editing/FrameSelection.h"
94 #include "core/editing/InputMethodController.h" 94 #include "core/editing/InputMethodController.h"
95 #include "core/editing/PlainTextRange.h" 95 #include "core/editing/PlainTextRange.h"
96 #include "core/editing/SpellChecker.h" 96 #include "core/editing/SpellChecker.h"
97 #include "core/editing/SurroundingText.h"
97 #include "core/editing/TextAffinity.h" 98 #include "core/editing/TextAffinity.h"
98 #include "core/editing/TextIterator.h" 99 #include "core/editing/TextIterator.h"
99 #include "core/editing/htmlediting.h" 100 #include "core/editing/htmlediting.h"
100 #include "core/editing/markup.h" 101 #include "core/editing/markup.h"
101 #include "core/frame/Console.h" 102 #include "core/frame/Console.h"
102 #include "core/frame/DOMWindow.h" 103 #include "core/frame/DOMWindow.h"
103 #include "core/frame/FrameView.h" 104 #include "core/frame/FrameView.h"
104 #include "core/frame/Settings.h" 105 #include "core/frame/Settings.h"
105 #include "core/html/HTMLCollection.h" 106 #include "core/html/HTMLCollection.h"
106 #include "core/html/HTMLFormElement.h" 107 #include "core/html/HTMLFormElement.h"
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 styleElement->setAttribute(HTMLNames::hrefAttr, url); 1294 styleElement->setAttribute(HTMLNames::hrefAttr, url);
1294 1295
1295 frame()->document()->head()->appendChild(styleElement.release(), IGNORE_EXCE PTION); 1296 frame()->document()->head()->appendChild(styleElement.release(), IGNORE_EXCE PTION);
1296 } 1297 }
1297 1298
1298 void WebLocalFrameImpl::setCaretVisible(bool visible) 1299 void WebLocalFrameImpl::setCaretVisible(bool visible)
1299 { 1300 {
1300 frame()->selection().setCaretVisible(visible); 1301 frame()->selection().setCaretVisible(visible);
1301 } 1302 }
1302 1303
1304 WebString WebLocalFrameImpl::textSurroundingSelection(int maxLength, int* startO ffset, int* endOffset) const
1305 {
1306 ASSERT(maxLength > 0);
1307
1308 SurroundingText surroundingText(frame()->selection().start(), frame()->selec tion().end(), maxLength);
1309 *startOffset = surroundingText.startOffsetInContent();
1310 *endOffset = surroundingText.endOffsetInContent();
1311 return surroundingText.content();
1312 }
1313
1303 VisiblePosition WebLocalFrameImpl::visiblePositionForWindowPoint(const WebPoint& point) 1314 VisiblePosition WebLocalFrameImpl::visiblePositionForWindowPoint(const WebPoint& point)
1304 { 1315 {
1305 FloatPoint unscaledPoint(point); 1316 FloatPoint unscaledPoint(point);
1306 unscaledPoint.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFact or()); 1317 unscaledPoint.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFact or());
1307 1318
1308 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H itTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::Confusi ngAndOftenMisusedDisallowShadowContent; 1319 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H itTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::Confusi ngAndOftenMisusedDisallowShadowContent;
1309 HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(unsca ledPoint))); 1320 HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(unsca ledPoint)));
1310 frame()->document()->renderView()->layer()->hitTest(request, result); 1321 frame()->document()->renderView()->layer()->hitTest(request, result);
1311 1322
1312 if (Node* node = result.targetNode()) 1323 if (Node* node = result.targetNode())
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 1923
1913 void WebLocalFrameImpl::invalidateAll() const 1924 void WebLocalFrameImpl::invalidateAll() const
1914 { 1925 {
1915 ASSERT(frame() && frame()->view()); 1926 ASSERT(frame() && frame()->view());
1916 FrameView* view = frame()->view(); 1927 FrameView* view = frame()->view();
1917 view->invalidateRect(view->frameRect()); 1928 view->invalidateRect(view->frameRect());
1918 invalidateScrollbar(); 1929 invalidateScrollbar();
1919 } 1930 }
1920 1931
1921 } // namespace blink 1932 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698