2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2006 James G. Speth (speth@end.com)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #import "DOMInternal.h" // import first to make the private/public trick work
32 #import "CachedImage.h"
33 #import "DOMElementInternal.h"
34 #import "DOMHTMLCanvasElement.h"
35 #import "DOMHTMLTableCellElementInternal.h"
36 #import "DOMNodeInternal.h"
37 #import "DOMPrivate.h"
38 #import "DOMRangeInternal.h"
42 #import "HTMLElement.h"
44 #import "HTMLParserIdioms.h"
45 #import "HTMLTableCellElement.h"
48 #import "NodeFilter.h"
51 #import "RenderImage.h"
52 #import "ScriptController.h"
53 #import "WebScriptObjectPrivate.h"
54 #import <JavaScriptCore/APICast.h>
55 #import <wtf/HashMap.h>
58 #import "FocusController.h"
59 #import "HTMLLinkElement.h"
60 #import "KeyboardEvent.h"
63 #import "MediaQueryEvaluator.h"
64 #import "NodeRenderStyle.h"
66 #import "RenderView.h"
68 #import "WAKAppKitStubs.h"
70 #import "WebCoreThreadMessage.h"
74 using namespace WebCore;
76 // FIXME: Would be nice to break this up into separate files to match how other WebKit
79 //------------------------------------------------------------------------------------------
84 typedef HashMap<const QualifiedName::QualifiedNameImpl*, Class> ObjCClassMap;
85 static ObjCClassMap* elementClassMap;
87 static void addElementClass(const QualifiedName& tag, Class objCClass)
89 elementClassMap->set(tag.impl(), objCClass);
92 static void createElementClassMap()
95 elementClassMap = new ObjCClassMap;
97 // FIXME: Reflect marquee once the API has been determined.
99 // Populate it with HTML and SVG element classes.
100 addElementClass(HTMLNames::aTag, [DOMHTMLAnchorElement class]);
101 addElementClass(HTMLNames::appletTag, [DOMHTMLAppletElement class]);
102 addElementClass(HTMLNames::areaTag, [DOMHTMLAreaElement class]);
103 addElementClass(HTMLNames::baseTag, [DOMHTMLBaseElement class]);
104 addElementClass(HTMLNames::basefontTag, [DOMHTMLBaseFontElement class]);
105 addElementClass(HTMLNames::bodyTag, [DOMHTMLBodyElement class]);
106 addElementClass(HTMLNames::brTag, [DOMHTMLBRElement class]);
107 addElementClass(HTMLNames::buttonTag, [DOMHTMLButtonElement class]);
108 addElementClass(HTMLNames::canvasTag, [DOMHTMLCanvasElement class]);
109 addElementClass(HTMLNames::captionTag, [DOMHTMLTableCaptionElement class]);
110 addElementClass(HTMLNames::colTag, [DOMHTMLTableColElement class]);
111 addElementClass(HTMLNames::colgroupTag, [DOMHTMLTableColElement class]);
112 addElementClass(HTMLNames::delTag, [DOMHTMLModElement class]);
113 addElementClass(HTMLNames::dirTag, [DOMHTMLDirectoryElement class]);
114 addElementClass(HTMLNames::divTag, [DOMHTMLDivElement class]);
115 addElementClass(HTMLNames::dlTag, [DOMHTMLDListElement class]);
116 addElementClass(HTMLNames::embedTag, [DOMHTMLEmbedElement class]);
117 addElementClass(HTMLNames::fieldsetTag, [DOMHTMLFieldSetElement class]);
118 addElementClass(HTMLNames::fontTag, [DOMHTMLFontElement class]);
119 addElementClass(HTMLNames::formTag, [DOMHTMLFormElement class]);
120 addElementClass(HTMLNames::frameTag, [DOMHTMLFrameElement class]);
121 addElementClass(HTMLNames::framesetTag, [DOMHTMLFrameSetElement class]);
122 addElementClass(HTMLNames::h1Tag, [DOMHTMLHeadingElement class]);
123 addElementClass(HTMLNames::h2Tag, [DOMHTMLHeadingElement class]);
124 addElementClass(HTMLNames::h3Tag, [DOMHTMLHeadingElement class]);
125 addElementClass(HTMLNames::h4Tag, [DOMHTMLHeadingElement class]);
126 addElementClass(HTMLNames::h5Tag, [DOMHTMLHeadingElement class]);
127 addElementClass(HTMLNames::h6Tag, [DOMHTMLHeadingElement class]);
128 addElementClass(HTMLNames::headTag, [DOMHTMLHeadElement class]);
129 addElementClass(HTMLNames::hrTag, [DOMHTMLHRElement class]);
130 addElementClass(HTMLNames::htmlTag, [DOMHTMLHtmlElement class]);
131 addElementClass(HTMLNames::iframeTag, [DOMHTMLIFrameElement class]);
132 addElementClass(HTMLNames::imgTag, [DOMHTMLImageElement class]);
133 addElementClass(HTMLNames::inputTag, [DOMHTMLInputElement class]);
134 addElementClass(HTMLNames::insTag, [DOMHTMLModElement class]);
135 addElementClass(HTMLNames::labelTag, [DOMHTMLLabelElement class]);
136 addElementClass(HTMLNames::legendTag, [DOMHTMLLegendElement class]);
137 addElementClass(HTMLNames::liTag, [DOMHTMLLIElement class]);
138 addElementClass(HTMLNames::linkTag, [DOMHTMLLinkElement class]);
139 addElementClass(HTMLNames::listingTag, [DOMHTMLPreElement class]);
140 addElementClass(HTMLNames::mapTag, [DOMHTMLMapElement class]);
141 addElementClass(HTMLNames::marqueeTag, [DOMHTMLMarqueeElement class]);
142 addElementClass(HTMLNames::menuTag, [DOMHTMLMenuElement class]);
143 addElementClass(HTMLNames::metaTag, [DOMHTMLMetaElement class]);
144 addElementClass(HTMLNames::objectTag, [DOMHTMLObjectElement class]);
145 addElementClass(HTMLNames::olTag, [DOMHTMLOListElement class]);
146 addElementClass(HTMLNames::optgroupTag, [DOMHTMLOptGroupElement class]);
147 addElementClass(HTMLNames::optionTag, [DOMHTMLOptionElement class]);
148 addElementClass(HTMLNames::pTag, [DOMHTMLParagraphElement class]);
149 addElementClass(HTMLNames::paramTag, [DOMHTMLParamElement class]);
150 addElementClass(HTMLNames::preTag, [DOMHTMLPreElement class]);
151 addElementClass(HTMLNames::qTag, [DOMHTMLQuoteElement class]);
152 addElementClass(HTMLNames::scriptTag, [DOMHTMLScriptElement class]);
153 addElementClass(HTMLNames::selectTag, [DOMHTMLSelectElement class]);
154 addElementClass(HTMLNames::styleTag, [DOMHTMLStyleElement class]);
155 addElementClass(HTMLNames::tableTag, [DOMHTMLTableElement class]);
156 addElementClass(HTMLNames::tbodyTag, [DOMHTMLTableSectionElement class]);
157 addElementClass(HTMLNames::tdTag, [DOMHTMLTableCellElement class]);
158 addElementClass(HTMLNames::textareaTag, [DOMHTMLTextAreaElement class]);
159 addElementClass(HTMLNames::tfootTag, [DOMHTMLTableSectionElement class]);
160 addElementClass(HTMLNames::thTag, [DOMHTMLTableCellElement class]);
161 addElementClass(HTMLNames::theadTag, [DOMHTMLTableSectionElement class]);
162 addElementClass(HTMLNames::titleTag, [DOMHTMLTitleElement class]);
163 addElementClass(HTMLNames::trTag, [DOMHTMLTableRowElement class]);
164 addElementClass(HTMLNames::ulTag, [DOMHTMLUListElement class]);
165 addElementClass(HTMLNames::xmpTag, [DOMHTMLPreElement class]);
168 static Class lookupElementClass(const QualifiedName& tag)
170 // Do a special lookup to ignore element prefixes
172 return elementClassMap->get(QualifiedName(nullAtom, tag.localName(), tag.namespaceURI()).impl());
174 return elementClassMap->get(tag.impl());
177 static Class elementClass(const QualifiedName& tag, Class defaultClass)
179 if (!elementClassMap)
180 createElementClassMap();
181 Class objcClass = lookupElementClass(tag);
183 objcClass = defaultClass;
187 static NSArray *kit(const Vector<IntRect>& rects)
189 size_t size = rects.size();
190 NSMutableArray *array = [NSMutableArray arrayWithCapacity:size];
191 for (size_t i = 0; i < size; ++i)
192 [array addObject:[NSValue valueWithRect:rects[i]]];
197 static WKQuad wkQuadFromFloatQuad(const FloatQuad& inQuad)
200 theQuad.p1 = inQuad.p1();
201 theQuad.p2 = inQuad.p2();
202 theQuad.p3 = inQuad.p3();
203 theQuad.p4 = inQuad.p4();
208 static NSArray *kit(const Vector<FloatQuad>& quads)
210 size_t size = quads.size();
211 NSMutableArray *array = [NSMutableArray arrayWithCapacity:size];
212 for (size_t i = 0; i < size; ++i) {
213 WKQuadObject* quadObject = [[WKQuadObject alloc] initWithQuad:wkQuadFromFloatQuad(quads[i])];
214 [array addObject:quadObject];
215 [quadObject release];
220 static inline float min4(float a, float b, float c, float d)
222 return std::min(std::min(a, b), std::min(c, d));
225 static inline float max4(float a, float b, float c, float d)
227 return std::max(std::max(a, b), std::max(c, d));
230 static inline WKQuad emptyQuad()
232 WKQuad zeroQuad = { CGPointZero, CGPointZero, CGPointZero, CGPointZero };
237 } // namespace WebCore
240 @implementation WKQuadObject
242 - (id)initWithQuad:(WKQuad)quad
244 if ((self = [super init]))
256 - (CGRect)boundingBox
258 float left = WebCore::min4(_quad.p1.x, _quad.p2.x, _quad.p3.x, _quad.p4.x);
259 float top = WebCore::min4(_quad.p1.y, _quad.p2.y, _quad.p3.y, _quad.p4.y);
261 float right = WebCore::max4(_quad.p1.x, _quad.p2.x, _quad.p3.x, _quad.p4.x);
262 float bottom = WebCore::max4(_quad.p1.y, _quad.p2.y, _quad.p3.y, _quad.p4.y);
264 return CGRectMake(left, top, right - left, bottom - top);
270 @implementation DOMNode (WebCoreInternal)
272 #pragma clang diagnostic push
273 #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
275 - (NSString *)description
278 return [NSString stringWithFormat:@"<%@: null>", [[self class] description]];
280 NSString *value = [self nodeValue];
282 return [NSString stringWithFormat:@"<%@ [%@]: %p '%@'>",
283 [[self class] description], [self nodeName], _internal, value];
285 return [NSString stringWithFormat:@"<%@ [%@]: %p>", [[self class] description], [self nodeName], _internal];
288 #pragma clang diagnostic pop
290 - (JSC::Bindings::RootObject*)_rootObject
292 WebCore::Frame* frame = core(self)->document().frame();
295 return frame->script().bindingRootObject();
300 Class kitClass(WebCore::Node* impl)
302 switch (impl->nodeType()) {
303 case WebCore::Node::ELEMENT_NODE:
304 if (impl->isHTMLElement())
305 return WebCore::elementClass(toHTMLElement(impl)->tagQName(), [DOMHTMLElement class]);
306 return [DOMElement class];
307 case WebCore::Node::ATTRIBUTE_NODE:
308 return [DOMAttr class];
309 case WebCore::Node::TEXT_NODE:
310 return [DOMText class];
311 case WebCore::Node::CDATA_SECTION_NODE:
312 return [DOMCDATASection class];
313 case WebCore::Node::ENTITY_REFERENCE_NODE:
314 return [DOMEntityReference class];
315 case WebCore::Node::ENTITY_NODE:
316 return [DOMEntity class];
317 case WebCore::Node::PROCESSING_INSTRUCTION_NODE:
318 return [DOMProcessingInstruction class];
319 case WebCore::Node::COMMENT_NODE:
320 return [DOMComment class];
321 case WebCore::Node::DOCUMENT_NODE:
322 if (static_cast<WebCore::Document*>(impl)->isHTMLDocument())
323 return [DOMHTMLDocument class];
324 return [DOMDocument class];
325 case WebCore::Node::DOCUMENT_TYPE_NODE:
326 return [DOMDocumentType class];
327 case WebCore::Node::DOCUMENT_FRAGMENT_NODE:
328 return [DOMDocumentFragment class];
329 case WebCore::Node::NOTATION_NODE:
330 return [DOMNotation class];
331 case WebCore::Node::XPATH_NAMESPACE_NODE:
332 // FIXME: Create an XPath objective C wrapper
333 // See http://bugs.webkit.org/show_bug.cgi?id=8755
336 ASSERT_NOT_REACHED();
340 id <DOMEventTarget> kit(WebCore::EventTarget* eventTarget)
345 if (WebCore::Node* node = eventTarget->toNode())
348 // We don't have an ObjC binding for XMLHttpRequest.
353 @implementation DOMNode (DOMNodeExtensions)
356 - (CGRect)boundingBox
358 - (NSRect)boundingBox
361 // FIXME: Could we move this function to WebCore::Node and autogenerate?
362 core(self)->document().updateLayoutIgnorePendingStylesheets();
363 WebCore::RenderObject* renderer = core(self)->renderer();
370 return renderer->absoluteBoundingBoxRect();
373 - (NSArray *)lineBoxRects
375 return [self textRects];
379 // quad in page coordinates, taking transforms into account. c.f. - (NSRect)boundingBox;
380 - (WKQuad)absoluteQuad
382 return [self absoluteQuadAndInsideFixedPosition:0];
385 - (WKQuad)absoluteQuadAndInsideFixedPosition:(BOOL *)insideFixed
387 core(self)->document().updateLayoutIgnorePendingStylesheets();
388 WebCore::RenderObject *renderer = core(self)->renderer();
390 Vector<FloatQuad> quads;
391 bool wasFixed = false;
392 renderer->absoluteQuads(quads, &wasFixed);
394 *insideFixed = wasFixed;
396 if (quads.size() == 0)
397 return WebCore::emptyQuad();
399 if (quads.size() == 1)
400 return wkQuadFromFloatQuad(quads[0]);
402 FloatRect boundingRect = quads[0].boundingBox();
403 for (size_t i = 1; i < quads.size(); ++i)
404 boundingRect.unite(quads[i].boundingBox());
406 return wkQuadFromFloatQuad(boundingRect);
409 return WebCore::emptyQuad();
412 // this method is like - (CGRect)boundingBox, but it accounts for for transforms
413 - (CGRect)boundingBoxUsingTransforms
415 core(self)->document().updateLayoutIgnorePendingStylesheets();
416 WebCore::RenderObject* renderer = core(self)->renderer();
419 return renderer->absoluteBoundingBoxRect(true);
422 // returns array of WKQuadObject
423 - (NSArray *)lineBoxQuads
425 core(self)->document().updateLayoutIgnorePendingStylesheets();
426 WebCore::RenderObject *renderer = core(self)->renderer();
428 Vector<WebCore::FloatQuad> quads;
429 renderer->absoluteQuads(quads);
435 - (Element *)_linkElement
437 WebCore::Node* node = core(self);
441 return static_cast<WebCore::Element*>(node);
442 node = node->parentNode();
450 Element *link= [self _linkElement];
452 return link->document().completeURL(stripLeadingAndTrailingHTMLSpaces(link->getAttribute(HTMLNames::hrefAttr)));
457 - (NSString *)hrefTarget
459 Element *target = [self _linkElement];
461 if(target) return target->getAttribute(HTMLNames::targetAttr);
468 RenderObject *renderer = [self _linkElement]->renderer();
470 return renderer->absoluteBoundingBoxRect();
474 - (NSString *)hrefLabel
476 Element *link= [self _linkElement];
478 if (!link) return nil;
480 return link->textContent();
483 - (NSString *)hrefTitle
485 Element *link= [self _linkElement];
487 if (!link) return nil;
489 return link->document().displayStringModifiedByEncoding(static_cast<HTMLElement *>(link)->title());
492 - (CGRect)boundingFrame
494 return [self boundingBox];
497 - (WKQuad)innerFrameQuad // takes transforms into account
499 core(self)->document().updateLayoutIgnorePendingStylesheets();
500 RenderObject* renderer = core(self)->renderer();
504 RenderStyle& style = renderer->style();
505 IntRect boundingBox = renderer->absoluteBoundingBoxRect(true /* use transforms*/);
507 boundingBox.move(style.borderLeftWidth(), style.borderTopWidth());
508 boundingBox.setWidth(boundingBox.width() - style.borderLeftWidth() - style.borderRightWidth());
509 boundingBox.setHeight(boundingBox.height() - style.borderBottomWidth() - style.borderTopWidth());
511 // FIXME: This function advertises returning a quad, but it actually returns a bounding box (so there is no rotation, for instance).
512 return wkQuadFromFloatQuad(FloatQuad(boundingBox));
515 - (float)computedFontSize
517 WebCore::Node *node = core(self);
518 RenderStyle *style = node->renderStyle();
521 return style->fontDescription().computedSize();
524 - (DOMNode *)nextFocusNode
526 Page *page = core(self)->document().page();
530 RefPtr<KeyboardEvent> key = KeyboardEvent::create();
531 return kit(page->focusController().nextFocusableElement(FocusNavigationScope::focusNavigationScopeOf(&core(self)->document()), core(self), key.get()));
534 - (DOMNode *)previousFocusNode
536 Page *page = core(self)->document().page();
540 RefPtr<KeyboardEvent> key = KeyboardEvent::create();
541 return kit(page->focusController().previousFocusableElement(FocusNavigationScope::focusNavigationScopeOf(&core(self)->document()), core(self), key.get()));
544 #endif // PLATFORM(IOS)
548 @implementation DOMNode (DOMNodeExtensionsPendingPublic)
551 - (NSImage *)renderedImage
553 // FIXME: Could we move this function to WebCore::Node and autogenerate?
554 WebCore::Node* node = core(self);
555 WebCore::Frame* frame = node->document().frame();
558 return createDragImageForNode(*frame, *node).autorelease();
562 - (NSArray *)textRects
564 core(self)->document().updateLayoutIgnorePendingStylesheets();
565 if (!core(self)->renderer())
567 Vector<WebCore::IntRect> rects;
568 core(self)->textRects(rects);
574 @implementation DOMNode (WebPrivate)
576 + (id)_nodeFromJSWrapper:(JSObjectRef)jsWrapper
578 JSObject* object = toJS(jsWrapper);
580 if (!object->inherits(JSNode::info()))
583 WebCore::Node& node = jsCast<JSNode*>(object)->impl();
589 @implementation DOMRange (DOMRangeExtensions)
592 - (CGRect)boundingBox
594 - (NSRect)boundingBox
597 // FIXME: The call to updateLayoutIgnorePendingStylesheets should be moved into WebCore::Range.
598 core(self)->ownerDocument().updateLayoutIgnorePendingStylesheets();
599 return core(self)->boundingBox();
603 - (NSImage *)renderedImageForcingBlackText:(BOOL)forceBlackText
605 - (CGImageRef)renderedImageForcingBlackText:(BOOL)forceBlackText
608 WebCore::Range* range = core(self);
609 WebCore::Frame* frame = range->ownerDocument().frame();
613 RetainPtr<NSImage> renderedImage = createDragImageForRange(*frame, *range, forceBlackText);
615 IntSize size([renderedImage size]);
616 size.scale(1 / frame->page()->deviceScaleFactor());
617 [renderedImage setSize:size];
619 return renderedImage.autorelease();
622 - (NSArray *)textRects
624 // FIXME: The call to updateLayoutIgnorePendingStylesheets should be moved into WebCore::Range.
625 Vector<WebCore::IntRect> rects;
626 core(self)->ownerDocument().updateLayoutIgnorePendingStylesheets();
627 core(self)->textRects(rects);
631 - (NSArray *)lineBoxRects
633 // FIXME: Remove this once all clients stop using it and we drop Leopard support.
634 return [self textRects];
639 //------------------------------------------------------------------------------------------
642 @implementation DOMElement (DOMElementAppKitExtensions)
647 // FIXME: Could we move this function to WebCore::Node and autogenerate?
648 WebCore::RenderObject* renderer = core(self)->renderer();
649 if (!renderer || !renderer->isRenderImage())
651 WebCore::CachedImage* cachedImage = toRenderImage(renderer)->cachedImage();
652 if (!cachedImage || cachedImage->errorOccurred())
654 return cachedImage->imageForRenderer(toRenderImage(renderer))->getNSImage();
660 @implementation DOMElement (WebPrivate)
665 // FIXME: Could we move this function to WebCore::Element and autogenerate?
666 auto renderer = core(self)->renderer();
669 return renderer->style().font().primaryFont()->getNSFont();
674 RenderObject* renderer = core(self)->renderer();
677 return renderer->style().font().primaryFont()->getCTFont();
682 - (NSData *)_imageTIFFRepresentation
684 // FIXME: Could we move this function to WebCore::Element and autogenerate?
685 auto renderer = core(self)->renderer();
686 if (!renderer || !renderer->isRenderImage())
688 WebCore::CachedImage* cachedImage = toRenderImage(renderer)->cachedImage();
689 if (!cachedImage || cachedImage->errorOccurred())
691 return (NSData *)cachedImage->imageForRenderer(renderer)->getTIFFRepresentation();
695 - (NSURL *)_getURLAttribute:(NSString *)name
697 // FIXME: Could we move this function to WebCore::Element and autogenerate?
699 WebCore::Element* element = core(self);
701 return element->document().completeURL(stripLeadingAndTrailingHTMLSpaces(element->getAttribute(name)));
706 // FIXME: Could we move this function to WebCore::Element and autogenerate?
707 WebCore::Element* element = core(self);
708 return element->document().focusedElement() == element;
714 @implementation DOMHTMLLinkElement (WebPrivate)
715 - (BOOL)_mediaQueryMatchesForOrientation:(int)orientation
717 Document& document = static_cast<HTMLLinkElement*>(core(self))->document();
718 FrameView* frameView = document.frame() ? document.frame()->view() : 0;
721 int layoutWidth = frameView->layoutWidth();
722 int layoutHeight = frameView->layoutHeight();
723 IntSize savedFixedLayoutSize = frameView->fixedLayoutSize();
724 bool savedUseFixedLayout = frameView->useFixedLayout();
725 if ((orientation == WebMediaQueryOrientationPortrait && layoutWidth > layoutHeight) ||
726 (orientation == WebMediaQueryOrientationLandscape && layoutWidth < layoutHeight)) {
727 // temporarily swap the orientation for the evaluation
728 frameView->setFixedLayoutSize(IntSize(layoutHeight, layoutWidth));
729 frameView->setUseFixedLayout(true);
732 bool result = [self _mediaQueryMatches];
734 frameView->setFixedLayoutSize(savedFixedLayoutSize);
735 frameView->setUseFixedLayout(savedUseFixedLayout);
740 - (BOOL)_mediaQueryMatches
742 HTMLLinkElement* link = static_cast<HTMLLinkElement*>(core(self));
743 String media = link->getAttribute(HTMLNames::mediaAttr);
746 Document& document = link->document();
748 RefPtr<MediaQuerySet> mediaQuerySet = MediaQuerySet::createAllowingDescriptionSyntax(media);
749 MediaQueryEvaluator screenEval("screen", document.frame(), document.renderView() ? &document.renderView()->style() : 0);
751 return screenEval.eval(mediaQuerySet.get());
756 //------------------------------------------------------------------------------------------
759 @implementation DOMRange (WebPrivate)
761 - (NSString *)description
764 return @"<DOMRange: null>";
765 return [NSString stringWithFormat:@"<DOMRange: %@ %d %@ %d>",
766 [self startContainer], [self startOffset], [self endContainer], [self endOffset]];
769 // FIXME: This should be removed as soon as all internal Apple uses of it have been replaced with
770 // calls to the public method - (NSString *)text.
778 //------------------------------------------------------------------------------------------
781 @implementation DOMRGBColor (WebPrivate)
784 // FIXME: This should be removed as soon as all internal Apple uses of it have been replaced with
785 // calls to the public method - (NSColor *)color.
795 @implementation DOMHTMLTableCellElement (WebPrivate)
797 - (DOMHTMLTableCellElement *)_cellAbove
799 return kit(core(self)->cellAbove());
804 //------------------------------------------------------------------------------------------
807 DOMNodeFilter *kit(WebCore::NodeFilter* impl)
812 if (DOMNodeFilter *wrapper = getDOMWrapper(impl))
813 return [[wrapper retain] autorelease];
815 DOMNodeFilter *wrapper = [[DOMNodeFilter alloc] _init];
816 wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(impl);
818 addDOMWrapper(wrapper, impl);
819 return [wrapper autorelease];
822 WebCore::NodeFilter* core(DOMNodeFilter *wrapper)
824 return wrapper ? reinterpret_cast<WebCore::NodeFilter*>(wrapper->_internal) : 0;
827 @implementation DOMNodeFilter
832 reinterpret_cast<WebCore::NodeFilter*>(_internal)->deref();
839 reinterpret_cast<WebCore::NodeFilter*>(_internal)->deref();
843 - (short)acceptNode:(DOMNode *)node
845 return core(self)->acceptNode(core(node));