| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010, 2011 Apple 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 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 } | 796 } |
| 797 #endif | 797 #endif |
| 798 | 798 |
| 799 WebContextMenu* WebPage::contextMenu() | 799 WebContextMenu* WebPage::contextMenu() |
| 800 { | 800 { |
| 801 if (!m_contextMenu) | 801 if (!m_contextMenu) |
| 802 m_contextMenu = WebContextMenu::create(this); | 802 m_contextMenu = WebContextMenu::create(this); |
| 803 return m_contextMenu.get(); | 803 return m_contextMenu.get(); |
| 804 } | 804 } |
| 805 | 805 |
| 806 void WebPage::getLocationAndLengthFromRange(Range* range, uint64_t& location, ui
nt64_t& length) | |
| 807 { | |
| 808 location = notFound; | |
| 809 length = 0; | |
| 810 | |
| 811 if (!range || !range->startContainer()) | |
| 812 return; | |
| 813 | |
| 814 Element* selectionRoot = range->ownerDocument()->frame()->selection()->rootE
ditableElement(); | |
| 815 Element* scope = selectionRoot ? selectionRoot : range->ownerDocument()->doc
umentElement(); | |
| 816 | |
| 817 // Mouse events may cause TSM to attempt to create an NSRange for a portion
of the view | |
| 818 // that is not inside the current editable region. These checks ensure we d
on't produce | |
| 819 // potentially invalid data when responding to such requests. | |
| 820 if (range->startContainer() != scope && !range->startContainer()->isDescenda
ntOf(scope)) | |
| 821 return; | |
| 822 if (range->endContainer() != scope && !range->endContainer()->isDescendantOf
(scope)) | |
| 823 return; | |
| 824 | |
| 825 RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->
startContainer(), range->startOffset()); | |
| 826 ASSERT(testRange->startContainer() == scope); | |
| 827 location = TextIterator::rangeLength(testRange.get()); | |
| 828 | |
| 829 ExceptionCode ec; | |
| 830 testRange->setEnd(range->endContainer(), range->endOffset(), ec); | |
| 831 ASSERT(testRange->startContainer() == scope); | |
| 832 length = TextIterator::rangeLength(testRange.get()) - location; | |
| 833 } | |
| 834 | |
| 835 // Events | 806 // Events |
| 836 | 807 |
| 837 static const WebEvent* g_currentEvent = 0; | 808 static const WebEvent* g_currentEvent = 0; |
| 838 | 809 |
| 839 // FIXME: WebPage::currentEvent is used by the plug-in code to avoid having to c
onvert from DOM events back to | 810 // FIXME: WebPage::currentEvent is used by the plug-in code to avoid having to c
onvert from DOM events back to |
| 840 // WebEvents. When we get the event handling sorted out, this should go away and
the Widgets should get the correct | 811 // WebEvents. When we get the event handling sorted out, this should go away and
the Widgets should get the correct |
| 841 // platform events passed to the event handler code. | 812 // platform events passed to the event handler code. |
| 842 const WebEvent* WebPage::currentEvent() | 813 const WebEvent* WebPage::currentEvent() |
| 843 { | 814 { |
| 844 return g_currentEvent; | 815 return g_currentEvent; |
| (...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2122 #endif | 2093 #endif |
| 2123 | 2094 |
| 2124 bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request) | 2095 bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request) |
| 2125 { | 2096 { |
| 2126 if (SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(request.url().protoco
l())) | 2097 if (SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(request.url().protoco
l())) |
| 2127 return true; | 2098 return true; |
| 2128 return platformCanHandleRequest(request); | 2099 return platformCanHandleRequest(request); |
| 2129 } | 2100 } |
| 2130 | 2101 |
| 2131 } // namespace WebKit | 2102 } // namespace WebKit |
| OLD | NEW |