Changeset 225429 in webkit
- Timestamp:
- Dec 1, 2017 4:09:02 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r225427 r225429 1 2017-12-01 Daniel Bates <dabates@apple.com> 2 3 Alternative Presentation Button: Provide a way to query for the replaced elements 4 https://bugs.webkit.org/show_bug.cgi?id=180114 5 <rdar://problem/35710539> 6 7 Reviewed by Tim Horton. 8 9 Add a test to ensure that Editor::elementsReplacedByAlternativePresentationButton() 10 returns the same list of elements that were specified to Editor::substituteWithAlternativePresentationButton() 11 up to ordering. 12 13 * fast/forms/alternative-presentation-button/replaced-elements-expected.txt: Added. 14 * fast/forms/alternative-presentation-button/replaced-elements.html: Added. 15 1 16 2017-12-01 Youenn Fablet <youenn@apple.com> 2 17 -
trunk/Source/WebCore/ChangeLog
r225428 r225429 1 2017-12-01 Daniel Bates <dabates@apple.com> 2 3 Alternative Presentation Button: Provide a way to query for the replaced elements 4 https://bugs.webkit.org/show_bug.cgi?id=180114 5 <rdar://problem/35710539> 6 7 Reviewed by Tim Horton. 8 9 Add SPI to query for the elements that were replaced by an Alternative Presentation Button. 10 11 Test: fast/forms/alternative-presentation-button/replaced-elements.html 12 13 * editing/Editor.cpp: 14 (WebCore::Editor::elementsReplacedByAlternativePresentationButton): Added. 15 * editing/Editor.h: 16 * editing/cocoa/AlternativePresentationButtonSubstitution.cpp: 17 (WebCore::AlternativePresentationButtonSubstitution::replacedElements): Added. 18 * editing/cocoa/AlternativePresentationButtonSubstitution.h: 19 * testing/Internals.cpp: 20 (WebCore::Internals::elementsReplacedByAlternativePresentationButton): Added. 21 * testing/Internals.h: 22 * testing/Internals.idl: Expose internals function elementsReplacedByAlternativePresentationButton() 23 so as to test Editor::elementsReplacedByAlternativePresentationButton(). 24 1 25 2017-12-01 Said Abou-Hallawa <sabouhallawa@apple.com> 2 26 -
trunk/Source/WebCore/editing/Editor.cpp
r225422 r225429 3858 3858 } 3859 3859 3860 Vector<Ref<Element>> Editor::elementsReplacedByAlternativePresentationButton(const String& identifier) 3861 { 3862 if (!m_alternativePresentationButtonIdentifierToElementMap.contains(identifier)) 3863 return { }; 3864 auto* button = m_alternativePresentationButtonIdentifierToElementMap.get(identifier); 3865 ASSERT(m_alternativePresentationButtonElementToSubstitutionMap.contains(button)); 3866 auto substitution = m_alternativePresentationButtonElementToSubstitutionMap.get(button); 3867 return substitution->replacedElements(); 3868 } 3869 3860 3870 void Editor::didInsertAlternativePresentationButtonElement(AlternativePresentationButtonElement& button) 3861 3871 { -
trunk/Source/WebCore/editing/Editor.h
r225311 r225429 521 521 WEBCORE_EXPORT void removeAlternativePresentationButton(const String&); 522 522 523 WEBCORE_EXPORT Vector<Ref<Element>> elementsReplacedByAlternativePresentationButton(const String&); 524 523 525 void didInsertAlternativePresentationButtonElement(AlternativePresentationButtonElement&); 524 526 void didRemoveAlternativePresentationButtonElement(AlternativePresentationButtonElement&); -
trunk/Source/WebCore/editing/cocoa/AlternativePresentationButtonSubstitution.cpp
r225223 r225429 127 127 } 128 128 129 Vector<Ref<Element>> AlternativePresentationButtonSubstitution::replacedElements() 130 { 131 Vector<Ref<Element>> result; 132 result.reserveInitialCapacity(m_savedDisplayStyles.size() + 1); 133 result.uncheckedAppend(m_shadowHost.copyRef()); 134 for (auto& savedDisplayStyle : m_savedDisplayStyles) 135 result.uncheckedAppend(savedDisplayStyle.element.copyRef()); 136 return result; 137 } 138 129 139 } // namespace WebCore 130 140 -
trunk/Source/WebCore/editing/cocoa/AlternativePresentationButtonSubstitution.h
r225223 r225429 47 47 void unapply(); 48 48 49 Vector<Ref<Element>> replacedElements(); 50 49 51 private: 50 52 void initializeSavedDisplayStyles(Vector<Ref<Element>>&&); -
trunk/Source/WebCore/testing/Internals.cpp
r225403 r225429 4328 4328 return { }; 4329 4329 } 4330 4331 ExceptionOr<Vector<Ref<Element>>> Internals::elementsReplacedByAlternativePresentationButton(const String& identifier) 4332 { 4333 if (!frame()) 4334 return Exception { InvalidAccessError }; 4335 return frame()->editor().elementsReplacedByAlternativePresentationButton(identifier); 4336 } 4330 4337 #endif 4331 4338 -
trunk/Source/WebCore/testing/Internals.h
r225403 r225429 638 638 ExceptionOr<void> substituteWithAlternativePresentationButton(Vector<RefPtr<Element>>&&, const String&); 639 639 ExceptionOr<void> removeAlternativePresentationButton(const String&); 640 ExceptionOr<Vector<Ref<Element>>> elementsReplacedByAlternativePresentationButton(const String&); 640 641 #endif 641 642 -
trunk/Source/WebCore/testing/Internals.idl
r225403 r225429 577 577 [Conditional=ALTERNATIVE_PRESENTATION_BUTTON_ELEMENT, MayThrowException] void substituteWithAlternativePresentationButton(sequence<Element> elements, DOMString identifier); 578 578 [Conditional=ALTERNATIVE_PRESENTATION_BUTTON_ELEMENT, MayThrowException] void removeAlternativePresentationButton(DOMString identifier); 579 }; 579 [Conditional=ALTERNATIVE_PRESENTATION_BUTTON_ELEMENT, MayThrowException] sequence<Element> elementsReplacedByAlternativePresentationButton(DOMString identifier); 580 }; -
trunk/Source/WebKit/ChangeLog
r225427 r225429 1 2017-12-01 Daniel Bates <dabates@apple.com> 2 3 Alternative Presentation Button: Provide a way to query for the replaced elements 4 https://bugs.webkit.org/show_bug.cgi?id=180114 5 <rdar://problem/35710539> 6 7 Reviewed by Tim Horton. 8 9 Add SPI to query for the elements that were replaced by an Alternative Presentation Button. 10 11 * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm: 12 (-[WKWebProcessPlugInFrame elementsReplacedByAlternativePresentationButtonWithIdentifier:]): Added. 13 * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFramePrivate.h: 14 * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp: 15 (WKBundleElementsReplacedByAlternativePresentationButton): Added. 16 * WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h: 17 1 18 2017-12-01 Youenn Fablet <youenn@apple.com> 2 19 -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm
r225223 r225429 117 117 } 118 118 119 - (NSArray<WKWebProcessPlugInNodeHandle *> *)elementsReplacedByAlternativePresentationButtonWithIdentifier:(NSString *)identifier 120 { 121 #if ENABLE(ALTERNATIVE_PRESENTATION_BUTTON_ELEMENT) 122 auto replacedElements = _frame->coreFrame()->editor().elementsReplacedByAlternativePresentationButton(identifier); 123 if (replacedElements.isEmpty()) 124 return nil; 125 auto nodeHandles = adoptNS([NSMutableArray arrayWithCapacity:replacedElements.size()]); 126 for (auto& element : replacedElements) 127 [nodeHandles addObject:wrapper(InjectedBundleNodeHandle::getOrCreate(element).get())]; 128 return nodeHandles.autorelease(); 129 #else 130 return nil; 131 #endif 132 } 133 119 134 - (WKWebProcessPlugInBrowserContextController *)_browserContextController 120 135 { -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFramePrivate.h
r225223 r225429 45 45 - (void)substituteElements:(NSArray<WKWebProcessPlugInNodeHandle *> *)elements withAlternativePresentationButtonWithIdentifier:(NSString *)identifier; 46 46 - (void)removeAlternativePresentationButton:(NSString *)identifier; 47 - (NSArray<WKWebProcessPlugInNodeHandle *> *)elementsReplacedByAlternativePresentationButtonWithIdentifier:(NSString *)identifier; 47 48 48 49 @end -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
r225223 r225429 334 334 #endif 335 335 } 336 337 WKArrayRef WKBundleElementsReplacedByAlternativePresentationButton(WKBundleFrameRef frame, WKStringRef identifier) 338 { 339 #if ENABLE(ALTERNATIVE_PRESENTATION_BUTTON_ELEMENT) 340 auto* coreFrame = toImpl(frame)->coreFrame(); 341 if (!coreFrame) 342 return nullptr; 343 auto replacedElements = coreFrame->editor().elementsReplacedByAlternativePresentationButton(toWTFString(identifier)); 344 Vector<RefPtr<API::Object>> apiReplacedElements; 345 apiReplacedElements.reserveInitialCapacity(replacedElements.size()); 346 for (auto& element : replacedElements) 347 apiReplacedElements.uncheckedAppend(InjectedBundleNodeHandle::getOrCreate(element)); 348 return toAPI(&API::Array::create(WTFMove(apiReplacedElements)).leakRef()); 349 #else 350 UNUSED_PARAM(identifier); 351 return nullptr; 352 #endif 353 } -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h
r225223 r225429 59 59 WK_EXPORT void WKBundleSubstituteWithAlternativePresentationButton(WKBundleFrameRef frame, WKArrayRef elements, WKStringRef identifier); 60 60 WK_EXPORT void WKBundleRemoveAlternativePresentationButton(WKBundleFrameRef frame, WKStringRef identifier); 61 WK_EXPORT WKArrayRef WKBundleElementsReplacedByAlternativePresentationButton(WKBundleFrameRef frame, WKStringRef identifier); 61 62 62 63 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.