Source/WebCore:
[Cocoa] Move Objective-C DOM bindings from WebCore to legacy WebKit
https://bugs.webkit.org/show_bug.cgi?id=160654

Patch by Darin Adler <darin@apple.com> on 2016-08-22
Reviewed by Alex Christensen.

* DerivedSources.cpp: Removed ExceptionCodeDescription.h from the list here.
It will be included by the .cpp files as appropriate and should not be included
without including config.h first.

* WebCore.xcodeproj/project.pbxproj: Removed the Objective-C DOM source files.
Added private exports of various headers that are now used directly or indirectly
by legacy WebKit to implement the bindings. Moved WebScriptObject.* files from
bindings/objc to bridge/objc. Moved WebKitAvailability.h into platform/cocoa; it
can be moved to WebKit of we move the Objective-C bridge there too. Also ran
sort-Xcode-project-file.

* bindings/js/JSDOMBinding.cpp:
(WebCore::valueToUSVString): Fixed a comment typo.

* bindings/js/JSDOMWindowShell.cpp:
(WebCore::JSDOMWindowShell::toWrapped): Added.
* bindings/js/JSDOMWindowShell.h: Added a toWrapped function for use by the
Objective-C bindings.

* bindings/js/JSMainThreadExecState.h: Exported symbols needed by the Objective-C bindings.
* bindings/js/JSNamedNodeMapCustom.cpp: Updated includes since NamedNodeMap.h no longer
includes Attr.h.

* bindings/js/ScriptController.h: Exported symbols needed by the Objective-C bindings.

* bindings/js/ScriptControllerMac.mm:
(WebCore::ScriptController::windowScriptObject): Removed code that asserted the type of the
object; this assertion can't be done in WebCore any more and is not critical to keep.
(WebCore::ScriptController::disconnectPlatformScriptObjects): Use the new
disconnectWindowWrapper function to call up to the Objective-C bindings code in WebKit.

* bindings/objc/*: Moved all these files to WebKit/mac/DOM, except for a few that were moved
to bridge/objc.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader): Added support for the new ExportToWrappedFunction attribute so
classes that need to can export what is needed by WebKit.

* bindings/scripts/IDLAttributes.txt: Added ExportToWrappedFunction.

* bridge/objc/WebScriptObject.h: Moved from bindings/objc.
* bridge/objc/WebScriptObject.mm: Moved from bindings/objc.
(WebCore::initializeDOMWrapperHooks): Added. Used by WebKit to add the hooks needed so that
WebScriptObject can integrate with the DOM bindings.
(WebCore::disconnectWindowWrapper): Added.
(+[WebScriptObject scriptObjectForJSObject:originRootObject:rootObject:]): Added code that
uses createDOMWrapperFunction to set up wrappers that are found or created by WebKit.
* bridge/objc/WebScriptObjectPrivate.h: Moved from bindings/objc.

* css/CSSFontFaceRule.h: Exported symbols needed by the Objective-C bindings.
* css/CSSGroupingRule.h: Ditto.
* css/CSSImportRule.h: Ditto.
* css/CSSMediaRule.h: Ditto.
* css/CSSPageRule.h: Ditto.
* css/CSSPrimitiveValue.h: Ditto.
* css/CSSRule.h: Ditto.
* css/CSSRule.idl: Ditto.
* css/CSSRuleList.idl: Ditto.
* css/CSSStyleRule.h: Ditto.
* css/CSSStyleSheet.h: Ditto.
* css/CSSValue.h: Ditto.
* css/CSSValue.idl: Ditto.
* css/Counter.idl: Ditto.
* css/MediaList.h: Ditto.
* css/MediaList.idl: Ditto.
* css/MediaQueryEvaluator.h: Ditto.
* css/RGBColor.h: Ditto.
* css/RGBColor.idl: Ditto.
* css/Rect.idl: Ditto.
* css/StyleSheet.idl: Ditto.
* css/StyleSheetList.h: Ditto.
* css/StyleSheetList.idl: Ditto.
* dom/Attr.h: Ditto.
* dom/CharacterData.h: Ditto.
* dom/CollectionIndexCache.h: Ditto.
* dom/ContainerNode.h: Ditto.
* dom/DOMImplementation.cpp: Ditto.
* dom/DOMImplementation.h: Ditto.
* dom/DOMImplementation.idl: Ditto.
* dom/Document.h: Ditto.
* dom/DocumentFragment.h: Ditto.
* dom/Element.h: Ditto.
* dom/Event.h: Ditto.
* dom/Event.idl: Ditto.
* dom/EventTarget.h: Ditto.
* dom/KeyboardEvent.h: Ditto.
* dom/LifecycleCallbackQueue.h: Ditto.
* dom/MouseEvent.h: Ditto.
* dom/MouseRelatedEvent.h: Ditto.
* dom/MutationEvent.h: Ditto.
* dom/NamedNodeMap.h: Ditto.
* dom/NamedNodeMap.idl: Ditto.
* dom/NativeNodeFilter.h: Ditto.
* dom/Node.h: Ditto.
* dom/NodeIterator.h: Ditto.
* dom/NodeIterator.idl: Ditto.
* dom/NodeList.idl: Ditto.
* dom/NodeTraversal.h: Ditto.
* dom/OverflowEvent.h: Ditto.
* dom/QualifiedName.h: Ditto.
* dom/Range.h: Ditto.
* dom/ScriptElement.h: Ditto.
* dom/Text.h: Ditto.
* dom/TextEvent.h: Ditto.
* dom/TreeScope.h: Ditto.
* dom/TreeWalker.h: Ditto.
* dom/TreeWalker.idl: Ditto.
* dom/UIEvent.h: Ditto.
* dom/WheelEvent.h: Ditto.
* dom/make_dom_exceptions.pl: Ditto.
* editing/EditingStyle.h: Ditto.
* editing/FrameSelection.h: Ditto.

* editing/ios/EditorIOS.mm: Removed unneeded include of Objective-C DOM header.
* editing/mac/EditorMac.mm: Ditto.

* fileapi/Blob.h: Exported symbols needed by the Objective-C bindings.
* fileapi/File.h: Ditto.
* fileapi/FileList.h: Ditto.
* html/DOMTokenList.h: Ditto.
* html/HTMLAnchorElement.h: Ditto.
* html/HTMLAreaElement.h: Ditto.
* html/HTMLBaseElement.h: Ditto.
* html/HTMLButtonElement.h: Ditto.
* html/HTMLCanvasElement.h: Ditto.
* html/HTMLCollection.h: Ditto.
* html/HTMLCollection.idl: Ditto.
* html/HTMLDocument.h: Ditto.
* html/HTMLElement.h: Ditto.
* html/HTMLFormControlElement.h: Ditto.
* html/HTMLFormElement.h: Ditto.
* html/HTMLFrameElementBase.h: Ditto.
* html/HTMLFrameOwnerElement.h: Ditto.
* html/HTMLImageElement.h: Ditto.
* html/HTMLInputElement.h: Ditto.

* html/HTMLLabelElement.cpp:
(WebCore::HTMLLabelElement::setActive): Tweaked types a bit.
(WebCore::HTMLLabelElement::setHovered): Ditto.
(WebCore::HTMLLabelElement::defaultEventHandler): Ditto.
(WebCore::HTMLLabelElement::willRespondToMouseClickEvents): Ditto.
(WebCore::HTMLLabelElement::focus): Ditto.
(WebCore::HTMLLabelElement::accessKeyAction): Ditto.

* html/HTMLLabelElement.h: Exported symbols needed by the Objective-C bindings.
* html/HTMLLinkElement.h: Ditto.
* html/HTMLMapElement.h: Ditto.
* html/HTMLMarqueeElement.h: Ditto.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLOListElement.h: Ditto.
* html/HTMLOptionElement.h: Ditto.
* html/HTMLOptionsCollection.h: Ditto.
* html/HTMLOptionsCollection.idl: Ditto.
* html/HTMLScriptElement.h: Ditto.
* html/HTMLSelectElement.h: Ditto.
* html/HTMLStyleElement.h: Ditto.
* html/HTMLTableCellElement.h: Ditto.
* html/HTMLTableColElement.h: Ditto.
* html/HTMLTableElement.h: Ditto.
* html/HTMLTableRowElement.h: Ditto.
* html/HTMLTableSectionElement.h: Ditto.
* html/HTMLTextAreaElement.h: Ditto.
* html/HTMLTextFormControlElement.h: Ditto.
* html/HTMLTitleElement.h: Ditto.
* html/HTMLVideoElement.h: Ditto.
* html/LabelableElement.h: Ditto.

* loader/EmptyClients.h: Updated documentFragmentFromDelegate, which was
returning a newly created document fragment with a raw pointer. This works
because the implementation internally uses Objective-C and autorelease, but
is too fragile to rely on for the future.

* page/DOMWindow.h: Exported symbols needed by the Objective-C bindings.

* page/EditorClient.h: Updated document fragment functions.

* page/Frame.h: Removed indexCountOfWordPrecedingSelection, already unused.
Removed innerLineHeight and styleAtSelectionStart, formerly used by legacy WebKit,
which used Objective-C DOM objects in their interfaces.

* page/ios/FrameIOS.mm:
(WebCore::Frame::indexCountOfWordPrecedingSelection): Deleted.
(WebCore::Frame::innerLineHeight): Deleted.
(WebCore::Frame::styleAtSelectionStart): Deleted.

* platform/DragImage.h: Exported symbols needed by the Objective-C bindings.
* platform/ScrollView.h: Ditto.
* platform/URL.h: Ditto.

* platform/cocoa/WebKitAvailability.h: Moved from bindings/objc.

* platform/cocoa/WebPlaybackSessionModelMediaElement.mm: Removed unneeded includes
of Objective-C DOM headers.
* platform/cocoa/WebVideoFullscreenModelVideoElement.mm: Ditto.
* platform/ios/PasteboardIOS.mm: Ditto.

* platform/ios/wak/WebCoreThread.mm:
(StartWebThread): Took out the call to WebCoreObjCDeallocOnWebThread for DOMObject.
This class is now defined in legacy WebKit, so we do the code there there along
with the other WebKit classes.

* platform/ios/wak/WebCoreThreadSafe.h: Removed the unwise additional definition of
WebScriptObject and DOMObject in this file. Really this entire file needs to go.

* platform/text/TextEncoding.h: Exported symbols needed by the Objective-C bindings.
* rendering/HitTestResult.h: Ditto.
* rendering/RenderLayer.h: Ditto.
* rendering/RenderObject.h: Ditto.

* rendering/RenderThemeGtk.cpp: Rewrote code that was unnecessarily using
NamedNodeMap and Attr nodes just to get the value of an attribute.

* rendering/style/RenderStyle.h: Exported symbols needed by the Objective-C bindings.

* xml/XMLHttpRequest.cpp: Added include needed now that XMLDocument.h is not
included by DOMImplementation.h.

* xml/XPathExpression.h: Exported symbols needed by the Objective-C bindings.
* xml/XPathExpression.idl: Ditto.
* xml/XPathNSResolver.h: Ditto.

* xml/XPathResult.cpp:
(WebCore::XPathResult::snapshotLength): Use unsigned instead of unsigned long.
(WebCore::XPathResult::snapshotItem): Ditto.
* xml/XPathResult.h: Exported symbols needed by the Objective-C bindings. Also
updated types as above.
* xml/XPathResult.idl: Ditto.

Source/WebKit:
Move Objective-C DOM bindings from WebCore to legacy WebKit
https://bugs.webkit.org/show_bug.cgi?id=160654

Patch by Darin Adler <darin@apple.com> on 2016-08-22
Reviewed by Alex Christensen.

* WebKit.xcodeproj/project.pbxproj: Added the new source files to the project.
For now they all have project visibility, since MigrateHeaders.make takes care
of exporting them as public and private. Later, we can likely use the built-in
Xcode feature instead of that script. Also pass DOM as an acceptable prefix
when calling check-for-inappropriate-objc-class-names. Also sorted this file
with the sort-Xcode-project-file script.

Source/WebKit/mac:
Move Objective-C DOM bindings from WebCore to legacy WebKit
https://bugs.webkit.org/show_bug.cgi?id=160654

Patch by Darin Adler <darin@apple.com> on 2016-08-22
Reviewed by Alex Christensen.

* DOM: Added lots of files to the directory.
The files are just as they were in bindings/objc except that the paths of includes
have been updated as needed, and the code no longer is defined inside the WebCore
namespace, requring changes to various functions and their call sites. Also removed
all the WEBCORE_EXPORT since we export differently here in legacy WebKit.

* DOM/DOMInternal.h: Moved. Replaced createDOMWrapper with initializeDOMWrapperHooks.
* DOM/DOMUtility.mm: Moved.
(createDOMWrapper): Simplified to use toWrapped and not do unneeded namespace tricks.
(disconnectWindowWrapper): Added.
(initializeDOMWrapperHooks): Added.

* MigrateHeaders.make: Removed all the internal headers since they are now just
normal project headers. Added the "DOM" directory to the VPATH. Some of the headers
from WebCore are still being migrated, so we can't remove WebCorePrivateHeaders yet.

* WebCoreSupport/WebEditorClient.h: Updated to return RefPtr<DocumentFragment>.

* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::documentFragmentFromDelegate): Use RefPtr.

* WebKit.exp: Added exports for all the classes that used to use WEBCORE_EXPORT to
be exported from WebCore.

* WebView/WebFrame.mm:
(-[WebFrame innerLineHeight:]): Moved code from WebCore::Frame::innerLineHeight here.
No longer depend on whether this node happens to be in this frame. Also removed
unneeded null check since a node's document can't be null.

* WebView/WebHTMLView.mm: Removed uneeded include of ExceptionHandlers.h, which
is now here in WebKitLegacy instead of WebCore. But no need to include it at all.

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]): Call
initializeDOMWrapperHooks so WebScriptObject can create DOM binding wrappers when
making a script object for a DOM object, rather than just a generic script object.
(+[WebView enableWebThread]): Added a call to WebCoreObjCDeallocOnWebThread here for
DOMObject along with the other classes. This was done in WebCore before, but DOMObject is now
defined here in legacy WebKit.
(-[WebView styleAtSelectionStart]): Moved code from WebCore::Frame::styleAtSelectionStart here.
Replaced incorrect code that called "new PropertySetCSSStyleDeclaration" with a misleading comment
about reference counting; that code was leaking all the style declarations. Instead use
MutableStyleProperties::ensureCSSStyleDeclaration, which is designed for this purpose.

Source/WebKit2:
Move Objective-C DOM bindings from WebCore to legacy WebKit
https://bugs.webkit.org/show_bug.cgi?id=160654

Patch by Darin Adler <darin@apple.com> on 2016-08-22
Reviewed by Alex Christensen.

* WebProcess/WebCoreSupport/WebEditorClient.h: Updated to use RefPtr.
* WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
(WebKit::WebEditorClient::documentFragmentFromDelegate): Ditto.

* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: Removed unneeded includes
of Objective-C DOM headers that are now part of legacy WebKit, not WebCore.
But this file doesn't need to depend on those headers at all.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@204717 268f45cc-cd09-0410-ab3c-d52691b4dbfc
526 files changed