Changeset 172780 in webkit
- Timestamp:
- Aug 19, 2014 4:33:33 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/WebCore.exp.in
r172749 r172780 1322 1322 __ZN7WebCore8GradientC1ERKNS_10FloatPointES3_ 1323 1323 __ZN7WebCore8GradientD1Ev 1324 __ZN7WebCore8PositionC1EN3WTF10PassRefPtrINS_4NodeEEENS0_10AnchorTypeE 1324 1325 __ZN7WebCore8PositionC1EN3WTF10PassRefPtrINS_4NodeEEEiNS0_10AnchorTypeE 1325 1326 __ZN7WebCore8Settings13gQTKitEnabledE -
trunk/Source/WebKit2/ChangeLog
r172758 r172780 1 2014-08-19 Peyton Randolph <prandolph@apple.com> 2 3 Expose injected bundle SPI to get a node's URL element, get the visible selection range of that 4 element, and snapshot that range 5 https://bugs.webkit.org/show_bug.cgi?id=136076 6 7 Reviewed by Tim Horton. 8 9 * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp: 10 (WKBundleHitTestResultCopyURLElementHandle): Added. 11 * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h: 12 * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp: 13 (WKBundleNodeHandleCopyVisibleRange): Added. 14 * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h: 15 * WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp: 16 (WKBundleRangeHandleGetBoundingRectInWindowCoordinates): Added. 17 (WKBundleRangeHandleCopySnapshotWithOptions): Added. 18 * WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h: 19 * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp: 20 (WebKit::InjectedBundleNodeHandle::visibleRange): Added. 21 * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h: 22 * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp: 23 (WebKit::InjectedBundleRangeHandle::boundingRectInWindowCoordinates): Added. 24 (WebKit::InjectedBundleRangeHandle::renderedImage): Added. 25 * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h: 26 * WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp: 27 (WebKit::InjectedBundleHitTestResult::urlElementHandle): Added. 28 * WebProcess/InjectedBundle/InjectedBundleHitTestResult.h: 29 1 30 2014-08-19 Zalan Bujtas <zalan@apple.com> 2 31 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp
r151929 r172780 43 43 RefPtr<InjectedBundleNodeHandle> nodeHandle = toImpl(hitTestResultRef)->nodeHandle(); 44 44 return toAPI(nodeHandle.release().leakRef()); 45 } 46 47 WKBundleNodeHandleRef WKBundleHitTestResultCopyURLElementHandle(WKBundleHitTestResultRef hitTestResultRef) 48 { 49 RefPtr<InjectedBundleNodeHandle> urlElementNodeHandle = toImpl(hitTestResultRef)->urlElementHandle(); 50 return toAPI(urlElementNodeHandle.release().leakRef()); 45 51 } 46 52 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h
r168541 r172780 44 44 45 45 WK_EXPORT WKBundleNodeHandleRef WKBundleHitTestResultCopyNodeHandle(WKBundleHitTestResultRef hitTestResult); 46 WK_EXPORT WKBundleNodeHandleRef WKBundleHitTestResultCopyURLElementHandle(WKBundleHitTestResultRef hitTestResult); 46 47 47 48 WK_EXPORT WKBundleFrameRef WKBundleHitTestResultGetFrame(WKBundleHitTestResultRef hitTestResult); -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp
r146154 r172780 29 29 30 30 #include "InjectedBundleNodeHandle.h" 31 #include "InjectedBundleRangeHandle.h" 31 32 #include "WKAPICast.h" 32 33 #include "WKBundleAPICast.h" … … 62 63 RefPtr<WebImage> image = toImpl(nodeHandleRef)->renderedImage(toSnapshotOptions(options)); 63 64 return toAPI(image.release().leakRef()); 65 } 66 67 WKBundleRangeHandleRef WKBundleNodeHandleCopyVisibleRange(WKBundleNodeHandleRef nodeHandleRef) 68 { 69 RefPtr<InjectedBundleRangeHandle> rangeHandle = toImpl(nodeHandleRef)->visibleRange(); 70 return toAPI(rangeHandle.release().leakRef()); 64 71 } 65 72 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h
r168541 r172780 46 46 WK_EXPORT WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandle, bool* isReplaced); 47 47 WK_EXPORT WKImageRef WKBundleNodeHandleCopySnapshotWithOptions(WKBundleNodeHandleRef nodeHandle, WKSnapshotOptions options); 48 WK_EXPORT WKBundleRangeHandleRef WKBundleNodeHandleCopyVisibleRange(WKBundleNodeHandleRef nodeHandle); 48 49 49 50 /* Element Specific Operations */ -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp
r142900 r172780 31 31 #include "WKAPICast.h" 32 32 #include "WKBundleAPICast.h" 33 #include "WebImage.h" 34 #include <WebCore/IntRect.h> 33 35 34 36 using namespace WebKit; … … 44 46 return toAPI(rangeHandle.release().leakRef()); 45 47 } 48 49 WKRect WKBundleRangeHandleGetBoundingRectInWindowCoordinates(WKBundleRangeHandleRef rangeHandleRef) 50 { 51 WebCore::IntRect boundingRect = toImpl(rangeHandleRef)->boundingRectInWindowCoordinates(); 52 return WKRectMake(boundingRect.x(), boundingRect.y(), boundingRect.width(), boundingRect.height()); 53 } 54 55 WKImageRef WKBundleRangeHandleCopySnapshotWithOptions(WKBundleRangeHandleRef rangeHandleRef, WKSnapshotOptions options) 56 { 57 RefPtr<WebImage> image = toImpl(rangeHandleRef)->renderedImage(toSnapshotOptions(options)); 58 return toAPI(image.release().leakRef()); 59 } -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h
r168541 r172780 29 29 #include <JavaScriptCore/JavaScript.h> 30 30 #include <WebKit/WKBase.h> 31 #include <WebKit/WKGeometry.h> 32 #include <WebKit/WKImage.h> 31 33 32 34 #ifdef __cplusplus … … 36 38 WK_EXPORT WKBundleRangeHandleRef WKBundleRangeHandleCreate(JSContextRef context, JSObjectRef object); 37 39 40 WK_EXPORT WKRect WKBundleRangeHandleGetBoundingRectInWindowCoordinates(WKBundleRangeHandleRef rangeHandle); 41 WK_EXPORT WKImageRef WKBundleRangeHandleCopySnapshotWithOptions(WKBundleRangeHandleRef rangeHandle, WKSnapshotOptions options); 42 38 43 #ifdef __cplusplus 39 44 } -
trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
r172755 r172780 27 27 #include "InjectedBundleNodeHandle.h" 28 28 29 #include "InjectedBundleRangeHandle.h" 29 30 #include "ShareableBitmap.h" 30 31 #include "WebFrame.h" … … 47 48 #include <WebCore/Node.h> 48 49 #include <WebCore/Page.h> 50 #include <WebCore/Position.h> 51 #include <WebCore/Range.h> 49 52 #include <WebCore/RenderObject.h> 53 #include <WebCore/VisiblePosition.h> 50 54 #include <wtf/HashMap.h> 51 55 #include <wtf/NeverDestroyed.h> … … 185 189 } 186 190 191 PassRefPtr<InjectedBundleRangeHandle> InjectedBundleNodeHandle::visibleRange() const 192 { 193 VisiblePosition start = firstPositionInNode(m_node.get()); 194 VisiblePosition end = lastPositionInNode(m_node.get()); 195 196 RefPtr<Range> range = makeRange(start, end); 197 return InjectedBundleRangeHandle::getOrCreate(range.get()); 198 } 199 187 200 void InjectedBundleNodeHandle::setHTMLInputElementValueForUser(const String& value) 188 201 { -
trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h
r166936 r172780 41 41 namespace WebKit { 42 42 43 class InjectedBundleRangeHandle; 43 44 class InjectedBundleScriptWorld; 44 45 class WebFrame; … … 62 63 WebCore::IntRect renderRect(bool*) const; 63 64 PassRefPtr<WebImage> renderedImage(SnapshotOptions); 65 PassRefPtr<InjectedBundleRangeHandle> visibleRange() const; 64 66 void setHTMLInputElementValueForUser(const String&); 65 67 bool isHTMLInputElementAutofilled() const; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
r161045 r172780 27 27 #include "InjectedBundleRangeHandle.h" 28 28 29 #include "ShareableBitmap.h" 30 #include "WebImage.h" 29 31 #include <JavaScriptCore/APICast.h> 32 #include <WebCore/Document.h> 33 #include <WebCore/FloatRect.h> 34 #include <WebCore/Frame.h> 35 #include <WebCore/FrameSelection.h> 36 #include <WebCore/FrameView.h> 37 #include <WebCore/GraphicsContext.h> 38 #include <WebCore/IntRect.h> 30 39 #include <WebCore/JSRange.h> 40 #include <WebCore/Page.h> 31 41 #include <WebCore/Range.h> 42 #include <WebCore/VisibleSelection.h> 32 43 #include <wtf/HashMap.h> 33 44 #include <wtf/NeverDestroyed.h> … … 85 96 } 86 97 98 WebCore::IntRect InjectedBundleRangeHandle::boundingRectInWindowCoordinates() const 99 { 100 FloatRect boundingRect = m_range->boundingRect(); 101 Frame* frame = m_range->ownerDocument().frame(); 102 return frame->view()->contentsToWindow(enclosingIntRect(boundingRect)); 103 } 104 105 PassRefPtr<WebImage> InjectedBundleRangeHandle::renderedImage(SnapshotOptions options) 106 { 107 Document& ownerDocument = m_range->ownerDocument(); 108 Frame* frame = ownerDocument.frame(); 109 if (!frame) 110 return nullptr; 111 112 FrameView* frameView = frame->view(); 113 if (!frameView) 114 return nullptr; 115 116 VisibleSelection oldSelection = frame->selection().selection(); 117 frame->selection().setSelection(VisibleSelection(m_range.get())); 118 119 float scaleFactor = (options & SnapshotOptionsExcludeDeviceScaleFactor) ? 1 : frame->page()->deviceScaleFactor(); 120 IntRect paintRect = enclosingIntRect(m_range->boundingRect()); 121 IntSize backingStoreSize = paintRect.size(); 122 backingStoreSize.scale(scaleFactor); 123 124 RefPtr<ShareableBitmap> backingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha); 125 if (!backingStore) 126 return nullptr; 127 128 auto graphicsContext = backingStore->createGraphicsContext(); 129 graphicsContext->scale(FloatSize(scaleFactor, scaleFactor)); 130 131 paintRect.move(frameView->frameRect().x(), frameView->frameRect().y()); 132 paintRect.move(-frameView->scrollOffset()); 133 134 graphicsContext->translate(-paintRect.x(), -paintRect.y()); 135 136 PaintBehavior oldPaintBehavior = frameView->paintBehavior(); 137 PaintBehavior paintBehavior = oldPaintBehavior | PaintBehaviorSelectionOnly | PaintBehaviorFlattenCompositingLayers; 138 if (options & SnapshotOptionsForceBlackText) 139 paintBehavior |= PaintBehaviorForceBlackText; 140 if (options & SnapshotOptionsForceWhiteText) 141 paintBehavior |= PaintBehaviorForceWhiteText; 142 143 frameView->setPaintBehavior(paintBehavior); 144 ownerDocument.updateLayout(); 145 146 frameView->paint(graphicsContext.get(), paintRect); 147 frameView->setPaintBehavior(oldPaintBehavior); 148 149 frame->selection().setSelection(oldSelection); 150 151 return WebImage::create(backingStore); 152 } 153 87 154 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h
r160384 r172780 28 28 29 29 #include "APIObject.h" 30 #include "ImageOptions.h" 30 31 #include <JavaScriptCore/JSBase.h> 31 32 #include <wtf/PassRefPtr.h> … … 33 34 34 35 namespace WebCore { 35 class Range; 36 class IntRect; 37 class Range; 36 38 } 37 39 … … 39 41 40 42 class InjectedBundleScriptWorld; 43 class WebImage; 41 44 42 45 class InjectedBundleRangeHandle : public API::ObjectImpl<API::Object::Type::BundleRangeHandle> { … … 46 49 47 50 virtual ~InjectedBundleRangeHandle(); 51 52 WebCore::IntRect boundingRectInWindowCoordinates() const; 53 PassRefPtr<WebImage> renderedImage(SnapshotOptions); 48 54 49 55 WebCore::Range* coreRange() const; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp
r166262 r172780 50 50 { 51 51 return InjectedBundleNodeHandle::getOrCreate(m_hitTestResult.innerNonSharedNode()); 52 } 53 54 PassRefPtr<InjectedBundleNodeHandle> InjectedBundleHitTestResult::urlElementHandle() const 55 { 56 return InjectedBundleNodeHandle::getOrCreate(m_hitTestResult.URLElement()); 52 57 } 53 58 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h
r160384 r172780 45 45 const WebCore::HitTestResult& coreHitTestResult() const { return m_hitTestResult; } 46 46 47 PassRefPtr<InjectedBundleNodeHandle> nodeHandle() const; 47 PassRefPtr<InjectedBundleNodeHandle> nodeHandle() const; 48 PassRefPtr<InjectedBundleNodeHandle> urlElementHandle() const; 48 49 WebFrame* frame() const; 49 50 WebFrame* targetFrame() const;
Note: See TracChangeset
for help on using the changeset viewer.