diff options
author | Steve Block <steveblock@google.com> | 2010-09-29 17:32:26 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-09-29 17:35:08 +0100 |
commit | 68513a70bcd92384395513322f1b801e7bf9c729 (patch) | |
tree | 161b50f75a5921d61731bb25e730005994fcec85 /WebCore/page | |
parent | fd5c6425ce58eb75211be7718d5dee960842a37e (diff) | |
download | external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.zip external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.tar.gz external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.tar.bz2 |
Merge WebKit at r67908: Initial merge by Git
Change-Id: I43a553e7b3299b28cb6ee8aa035ed70fe342b972
Diffstat (limited to 'WebCore/page')
35 files changed, 374 insertions, 877 deletions
diff --git a/WebCore/page/Chrome.cpp b/WebCore/page/Chrome.cpp index bff0100..8feedce 100644 --- a/WebCore/page/Chrome.cpp +++ b/WebCore/page/Chrome.cpp @@ -350,7 +350,7 @@ void Chrome::setToolTip(const HitTestResult& result) // Get tooltip representing form action, if relevant if (node->hasTagName(inputTag)) { HTMLInputElement* input = static_cast<HTMLInputElement*>(node); - if (input->inputType() == HTMLInputElement::SUBMIT) + if (input->isSubmitButton()) if (HTMLFormElement* form = input->form()) { toolTip = form->action(); if (form->renderer()) @@ -379,7 +379,7 @@ void Chrome::setToolTip(const HitTestResult& result) if (Node* node = result.innerNonSharedNode()) { if (node->hasTagName(inputTag)) { HTMLInputElement* input = static_cast<HTMLInputElement*>(node); - if (input->inputType() == HTMLInputElement::FILE) { + if (input->isFileUpload()) { FileList* files = input->files(); unsigned listSize = files->length(); if (files && listSize > 1) { diff --git a/WebCore/page/ContextMenuController.cpp b/WebCore/page/ContextMenuController.cpp index 4ce17bd..d2317d2 100644 --- a/WebCore/page/ContextMenuController.cpp +++ b/WebCore/page/ContextMenuController.cpp @@ -231,7 +231,7 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item) Document* document = frame->document(); RefPtr<ReplaceSelectionCommand> command = ReplaceSelectionCommand::create(document, createFragmentFromMarkup(document, item->title(), ""), true, false, true); applyCommand(command); - frame->revealSelection(ScrollAlignment::alignToEdgeIfNeeded); + frame->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded); } break; case ContextMenuItemTagIgnoreSpelling: diff --git a/WebCore/page/DOMTimer.cpp b/WebCore/page/DOMTimer.cpp index f9178c9..3ac6d15 100644 --- a/WebCore/page/DOMTimer.cpp +++ b/WebCore/page/DOMTimer.cpp @@ -60,9 +60,6 @@ DOMTimer::DOMTimer(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> double intervalMilliseconds = max(oneMillisecond, timeout * oneMillisecond); - // Use a minimum interval of 10 ms to match other browsers, but only once we've - // nested enough to notice that we're repeating. - // Faster timers might be "better", but they're incompatible. if (intervalMilliseconds < s_minTimerInterval && m_nestingLevel >= maxTimerNestingLevel) intervalMilliseconds = s_minTimerInterval; if (singleShot) diff --git a/WebCore/page/DOMTimer.h b/WebCore/page/DOMTimer.h index dc793da..c1d8d9e 100644 --- a/WebCore/page/DOMTimer.h +++ b/WebCore/page/DOMTimer.h @@ -49,8 +49,6 @@ namespace WebCore { virtual void stop(); // The lowest allowable timer setting (in seconds, 0.001 == 1 ms). - // Default is 10ms. - // Chromium uses a non-default timeout. static double minTimerInterval() { return s_minTimerInterval; } static void setMinTimerInterval(double value) { s_minTimerInterval = value; } diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp index eeb57c4..310ab25 100644 --- a/WebCore/page/DOMWindow.cpp +++ b/WebCore/page/DOMWindow.cpp @@ -1053,11 +1053,15 @@ int DOMWindow::innerHeight() const if (!view) return 0; +<<<<<<< HEAD #if PLATFORM(ANDROID) return static_cast<int>(view->actualHeight() / view->pageZoomFactor()); #else return static_cast<int>(view->height() / view->pageZoomFactor()); #endif +======= + return static_cast<int>(view->height() / m_frame->pageZoomFactor()); +>>>>>>> webkit.org at r67908 } int DOMWindow::innerWidth() const @@ -1069,11 +1073,15 @@ int DOMWindow::innerWidth() const if (!view) return 0; +<<<<<<< HEAD #if PLATFORM(ANDROID) return static_cast<int>(view->actualWidth() / view->pageZoomFactor()); #else return static_cast<int>(view->width() / view->pageZoomFactor()); #endif +======= + return static_cast<int>(view->width() / m_frame->pageZoomFactor()); +>>>>>>> webkit.org at r67908 } int DOMWindow::screenX() const @@ -1111,11 +1119,15 @@ int DOMWindow::scrollX() const m_frame->document()->updateLayoutIgnorePendingStylesheets(); +<<<<<<< HEAD #if PLATFORM(ANDROID) return static_cast<int>(view->actualScrollX() / view->pageZoomFactor()); #else return static_cast<int>(view->scrollX() / view->pageZoomFactor()); #endif +======= + return static_cast<int>(view->scrollX() / m_frame->pageZoomFactor()); +>>>>>>> webkit.org at r67908 } int DOMWindow::scrollY() const @@ -1129,11 +1141,15 @@ int DOMWindow::scrollY() const m_frame->document()->updateLayoutIgnorePendingStylesheets(); +<<<<<<< HEAD #if PLATFORM(ANDROID) return static_cast<int>(view->actualScrollY() / view->pageZoomFactor()); #else return static_cast<int>(view->scrollY() / view->pageZoomFactor()); #endif +======= + return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor()); +>>>>>>> webkit.org at r67908 } bool DOMWindow::closed() const @@ -1353,8 +1369,8 @@ void DOMWindow::scrollTo(int x, int y) const if (!view) return; - int zoomedX = static_cast<int>(x * view->pageZoomFactor()); - int zoomedY = static_cast<int>(y * view->pageZoomFactor()); + int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor()); + int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor()); view->setScrollPosition(IntPoint(zoomedX, zoomedY)); } diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl index 29d12cc..7ae948c 100644 --- a/WebCore/page/DOMWindow.idl +++ b/WebCore/page/DOMWindow.idl @@ -193,6 +193,8 @@ module window { const unsigned short TEMPORARY = 0; const unsigned short PERSISTENT = 1; [EnabledAtRuntime] void requestFileSystem(in unsigned short type, in long long size, in [Callback, Optional] FileSystemCallback successCallback, in [Callback, Optional] ErrorCallback errorCallback); + + attribute [EnabledAtRuntime=FileSystem] FlagsConstructor Flags; #endif #if defined(ENABLE_ORIENTATION_EVENTS) && ENABLE_ORIENTATION_EVENTS @@ -496,6 +498,7 @@ module window { attribute EventConstructor Event; attribute BeforeLoadEventConstructor BeforeLoadEvent; + attribute HashChangeEventConstructor HashChangeEvent; attribute KeyboardEventConstructor KeyboardEvent; attribute MouseEventConstructor MouseEvent; attribute MutationEventConstructor MutationEvent; @@ -755,13 +758,13 @@ module window { attribute DOMFormDataConstructor FormData; - attribute [Conditional=BLOB|FILE_WRITER] FileErrorConstructor FileError; + attribute [Conditional=BLOB|FILE_SYSTEM] FileErrorConstructor FileError; attribute [Conditional=BLOB] FileReaderConstructor FileReader; attribute [Conditional=BLOB] BlobBuilderConstructor BlobBuilder; #if defined(ENABLE_BLOB) && ENABLE_BLOB - DOMString createBlobURL(in Blob blob); + [ConvertNullStringTo=Undefined] DOMString createBlobURL(in Blob blob); void revokeBlobURL(in DOMString blobURL); #endif diff --git a/WebCore/page/DragController.cpp b/WebCore/page/DragController.cpp index c623bf6..2e7d241 100644 --- a/WebCore/page/DragController.cpp +++ b/WebCore/page/DragController.cpp @@ -255,23 +255,23 @@ static HTMLInputElement* asFileInput(Node* node) // The button for a FILE input is a sub element with no set input type // In order to get around this problem we assume any non-FILE input element // is this internal button, and try querying the shadow parent node. - if (node->hasTagName(HTMLNames::inputTag) && node->isShadowNode() && static_cast<HTMLInputElement*>(node)->inputType() != HTMLInputElement::FILE) - node = node->shadowParentNode(); + if (node->hasTagName(HTMLNames::inputTag) && node->isShadowNode() && !static_cast<HTMLInputElement*>(node)->isFileUpload()) + node = node->shadowParentNode(); if (!node || !node->hasTagName(HTMLNames::inputTag)) return 0; - HTMLInputElement* inputElem = static_cast<HTMLInputElement*>(node); - if (inputElem->inputType() == HTMLInputElement::FILE) - return inputElem; + HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(node); + if (!inputElement->isFileUpload()) + return 0; - return 0; + return inputElement; } static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint& p) { - FrameView* view = documentUnderMouse->view(); - float zoomFactor = view ? view->pageZoomFactor() : 1; + Frame* frame = documentUnderMouse->frame(); + float zoomFactor = frame ? frame->pageZoomFactor() : 1; IntPoint point = roundedIntPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor)); HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); @@ -455,7 +455,7 @@ bool DragController::concludeEditDrag(DragData* dragData) // NSTextView behavior is to always smart delete on moving a selection, // but only to smart insert if the selection granularity is word granularity. bool smartDelete = innerFrame->editor()->smartInsertDeleteEnabled(); - bool smartInsert = smartDelete && innerFrame->selectionGranularity() == WordGranularity && dragData->canSmartReplace(); + bool smartInsert = smartDelete && innerFrame->selection()->granularity() == WordGranularity && dragData->canSmartReplace(); applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base(), smartInsert, smartDelete)); } else { if (setSelectionToDragCaret(innerFrame, dragCaret, range, point)) @@ -636,7 +636,7 @@ static IntPoint dragLocForDHTMLDrag(const IntPoint& mouseDraggedPoint, const Int static IntPoint dragLocForSelectionDrag(Frame* src) { - IntRect draggingRect = enclosingIntRect(src->selectionBounds()); + IntRect draggingRect = enclosingIntRect(src->selection()->bounds()); int xpos = draggingRect.right(); xpos = draggingRect.x() < xpos ? draggingRect.x() : xpos; int ypos = draggingRect.bottom(); diff --git a/WebCore/page/EditorClient.h b/WebCore/page/EditorClient.h index 4a192d7..97b0902 100644 --- a/WebCore/page/EditorClient.h +++ b/WebCore/page/EditorClient.h @@ -37,12 +37,16 @@ #if PLATFORM(MAC) #ifdef __OBJC__ @class NSArray; +@class NSAttributedString; @class NSData; +@class NSPasteboard; @class NSString; @class NSURL; #else class NSArray; +class NSAttributedString; class NSData; +class NSPasteboard; class NSString; class NSURL; #endif @@ -50,7 +54,9 @@ class NSURL; namespace WebCore { +class ArchiveResource; class CSSStyleDeclaration; +class DocumentFragment; class EditCommand; class Editor; class Element; @@ -147,6 +153,8 @@ public: #if PLATFORM(MAC) virtual NSString* userVisibleString(NSURL*) = 0; + virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector< RefPtr<ArchiveResource> >&) = 0; + virtual void setInsertionPasteboard(NSPasteboard*) = 0; #ifdef BUILDING_ON_TIGER virtual NSArray* pasteboardTypesForSelection(Frame*) = 0; #endif @@ -183,6 +191,7 @@ public: #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) virtual void showCorrectionPanel(const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacmentString, Editor*) = 0; virtual void dismissCorrectionPanel(bool correctionAccepted) = 0; + virtual bool isShowingCorrectionPanel() = 0; #endif virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail& detail) = 0; diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp index 1464de6..b660918 100644 --- a/WebCore/page/EventHandler.cpp +++ b/WebCore/page/EventHandler.cpp @@ -270,7 +270,7 @@ void EventHandler::selectClosestWordFromMouseEvent(const MouseEventWithHitTestRe newSelection.appendTrailingWhitespace(); } - if (m_frame->shouldChangeSelection(newSelection)) + if (m_frame->selection()->shouldChangeSelection(newSelection)) m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); } } @@ -295,7 +295,7 @@ void EventHandler::selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHit m_beganSelectingText = true; } - if (m_frame->shouldChangeSelection(newSelection)) + if (m_frame->selection()->shouldChangeSelection(newSelection)) m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); } } @@ -340,7 +340,7 @@ bool EventHandler::handleMousePressEventTripleClick(const MouseEventWithHitTestR m_beganSelectingText = true; } - if (m_frame->shouldChangeSelection(newSelection)) + if (m_frame->selection()->shouldChangeSelection(newSelection)) m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); return true; @@ -398,16 +398,16 @@ bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR newSelection.setExtent(pos); } - if (m_frame->selectionGranularity() != CharacterGranularity) { - granularity = m_frame->selectionGranularity(); - newSelection.expandUsingGranularity(m_frame->selectionGranularity()); + if (m_frame->selection()->granularity() != CharacterGranularity) { + granularity = m_frame->selection()->granularity(); + newSelection.expandUsingGranularity(m_frame->selection()->granularity()); } m_beganSelectingText = true; } else newSelection = VisibleSelection(visiblePos); - if (m_frame->shouldChangeSelection(newSelection)) + if (m_frame->selection()->shouldChangeSelection(newSelection)) m_frame->selection()->setSelection(newSelection, granularity, MakeNonDirectionalSelection); return true; @@ -640,12 +640,12 @@ void EventHandler::updateSelectionForMouseDrag(Node* targetNode, const IntPoint& } newSelection.setExtent(targetPosition); - if (m_frame->selectionGranularity() != CharacterGranularity) - newSelection.expandUsingGranularity(m_frame->selectionGranularity()); + if (m_frame->selection()->granularity() != CharacterGranularity) + newSelection.expandUsingGranularity(m_frame->selection()->granularity()); - if (m_frame->shouldChangeSelection(newSelection)) { + if (m_frame->selection()->shouldChangeSelection(newSelection)) { m_frame->selection()->setIsDirectional(false); - m_frame->selection()->setSelection(newSelection, m_frame->selectionGranularity(), MakeNonDirectionalSelection); + m_frame->selection()->setSelection(newSelection, m_frame->selection()->granularity(), MakeNonDirectionalSelection); } } #endif // ENABLE(DRAG_SUPPORT) @@ -707,13 +707,13 @@ bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e VisiblePosition pos = node->renderer()->positionForPoint(event.localPoint()); newSelection = VisibleSelection(pos); } - if (m_frame->shouldChangeSelection(newSelection)) + if (m_frame->selection()->shouldChangeSelection(newSelection)) m_frame->selection()->setSelection(newSelection); handled = true; } - m_frame->notifyRendererOfSelectionChange(true); + m_frame->selection()->notifyRendererOfSelectionChange(true); m_frame->selection()->selectFrameElementInParentIfFullySelected(); @@ -1052,8 +1052,7 @@ Frame* EventHandler::subframeForTargetNode(Node* node) static bool isSubmitImage(Node* node) { - return node && node->hasTagName(inputTag) - && static_cast<HTMLInputElement*>(node)->inputType() == HTMLInputElement::IMAGE; + return node && node->hasTagName(inputTag) && static_cast<HTMLInputElement*>(node)->isImageButton(); } // Returns true if the node's editable block is not current focused for editing @@ -1389,17 +1388,12 @@ bool EventHandler::handleMouseDoubleClickEvent(const PlatformMouseEvent& mouseEv m_clickCount = mouseEvent.clickCount(); bool swallowMouseUpEvent = dispatchMouseEvent(eventNames().mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false); - bool swallowClickEvent = false; - // Don't ever dispatch click events for right clicks - if (mouseEvent.button() != RightButton && mev.targetNode() == m_clickNode) - swallowClickEvent = dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true); + bool swallowClickEvent = mouseEvent.button() == LeftButton && mev.targetNode() == m_clickNode && dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true); if (m_lastScrollbarUnderMouse) swallowMouseUpEvent = m_lastScrollbarUnderMouse->mouseUp(); - - bool swallowMouseReleaseEvent = false; - if (!swallowMouseUpEvent) - swallowMouseReleaseEvent = handleMouseReleaseEvent(mev); + + bool swallowMouseReleaseEvent = !swallowMouseUpEvent && handleMouseReleaseEvent(mev); invalidateClick(); @@ -1592,10 +1586,7 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent) bool swallowMouseUpEvent = dispatchMouseEvent(eventNames().mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false); - // Don't ever dispatch click events for right clicks - bool swallowClickEvent = false; - if (m_clickCount > 0 && mouseEvent.button() != RightButton && mev.targetNode() == m_clickNode) - swallowClickEvent = dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true); + bool swallowClickEvent = m_clickCount > 0 && mouseEvent.button() == LeftButton && mev.targetNode() == m_clickNode && dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true); if (m_resizeLayer) { m_resizeLayer->setInResizeMode(false); @@ -2179,12 +2170,7 @@ bool EventHandler::canMouseDownStartSelect(Node* node) if (!node->canStartSelection()) return false; - for (RenderObject* curr = node->renderer(); curr; curr = curr->parent()) { - if (Node* node = curr->node()) - return node->dispatchEvent(Event::create(eventNames().selectstartEvent, true, true)); - } - - return true; + return node->dispatchEvent(Event::create(eventNames().selectstartEvent, true, true)); } #if ENABLE(DRAG_SUPPORT) @@ -2193,12 +2179,7 @@ bool EventHandler::canMouseDragExtendSelect(Node* node) if (!node || !node->renderer()) return true; - for (RenderObject* curr = node->renderer(); curr; curr = curr->parent()) { - if (Node* node = curr->node()) - return node->dispatchEvent(Event::create(eventNames().selectstartEvent, true, true)); - } - - return true; + return node->dispatchEvent(Event::create(eventNames().selectstartEvent, true, true)); } #endif // ENABLE(DRAG_SUPPORT) @@ -2846,12 +2827,6 @@ static PassRefPtr<TouchList> assembleTargetTouches(Touch* touchTarget, TouchList return targetTouches.release(); } -static float pageZoomFactor(Frame* frame) -{ - FrameView* view = frame->view(); - return view ? view->pageZoomFactor() : 1.0f; -} - bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) { RefPtr<TouchList> touches = TouchList::create(); @@ -2908,8 +2883,8 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) pagePoint = documentPointForWindowPoint(doc->frame(), point.pos()); } - int adjustedPageX = lroundf(pagePoint.x() / pageZoomFactor(m_frame)); - int adjustedPageY = lroundf(pagePoint.y() / pageZoomFactor(m_frame)); + int adjustedPageX = lroundf(pagePoint.x() / m_frame->pageZoomFactor()); + int adjustedPageY = lroundf(pagePoint.y() / m_frame->pageZoomFactor()); // Increment the platform touch id by 1 to avoid storing a key of 0 in the hashmap. unsigned touchPointTargetKey = point.id() + 1; diff --git a/WebCore/page/FocusController.cpp b/WebCore/page/FocusController.cpp index aeb4fa0..1ac50cb 100644 --- a/WebCore/page/FocusController.cpp +++ b/WebCore/page/FocusController.cpp @@ -278,7 +278,7 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb if (caretBrowsing) { VisibleSelection newSelection(Position(node, 0), Position(node, 0), DOWNSTREAM); - if (frame->shouldChangeSelection(newSelection)) + if (frame->selection()->shouldChangeSelection(newSelection)) frame->selection()->setSelection(newSelection); } diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp index 3a03e9b..558f339 100644..100755 --- a/WebCore/page/Frame.cpp +++ b/WebCore/page/Frame.cpp @@ -133,6 +133,22 @@ static inline Frame* parentFromOwnerElement(HTMLFrameOwnerElement* ownerElement) return ownerElement->document()->frame(); } +static inline float parentPageZoomFactor(Frame* frame) +{ + Frame* parent = frame->tree()->parent(); + if (!parent) + return 1; + return parent->pageZoomFactor(); +} + +static inline float parentTextZoomFactor(Frame* frame) +{ + Frame* parent = frame->tree()->parent(); + if (!parent) + return 1; + return parent->textZoomFactor(); +} + inline Frame::Frame(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClient* frameLoaderClient) : m_page(page) , m_treeNode(this, parentFromOwnerElement(ownerElement)) @@ -145,6 +161,8 @@ inline Frame::Frame(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoader , m_eventHandler(this) , m_animationController(this) , m_lifeSupportTimer(this, &Frame::lifeSupportTimerFired) + , m_pageZoomFactor(parentPageZoomFactor(this)) + , m_textZoomFactor(parentTextZoomFactor(this)) #if ENABLE(ORIENTATION_EVENTS) , m_orientation(0) #endif @@ -290,16 +308,6 @@ Settings* Frame::settings() const return m_page ? m_page->settings() : 0; } -TextGranularity Frame::selectionGranularity() const -{ - return m_selectionController.granularity(); -} - -SelectionController* Frame::dragCaretController() const -{ - return m_page->dragCaretController(); -} - static RegularExpression* createRegExpForLabels(const Vector<String>& labels) { // REVIEW- version of this call in FrameMac.mm caches based on the NSArray ptrs being @@ -487,87 +495,6 @@ String Frame::matchLabelsAgainstElement(const Vector<String>& labels, Element* e return matchLabelsAgainstString(labels, element->getAttribute(idAttr)); } -void Frame::notifyRendererOfSelectionChange(bool userTriggered) -{ - RenderObject* renderer = 0; - - document()->updateStyleIfNeeded(); - - if (selection()->rootEditableElement()) - renderer = selection()->rootEditableElement()->shadowAncestorNode()->renderer(); - - // If the current selection is in a textfield or textarea, notify the renderer that the selection has changed - if (renderer && renderer->isTextControl()) - toRenderTextControl(renderer)->selectionChanged(userTriggered); -} - -// Helper function that tells whether a particular node is an element that has an entire -// Frame and FrameView, a <frame>, <iframe>, or <object>. -static bool isFrameElement(const Node *n) -{ - if (!n) - return false; - RenderObject *renderer = n->renderer(); - if (!renderer || !renderer->isWidget()) - return false; - Widget* widget = toRenderWidget(renderer)->widget(); - return widget && widget->isFrameView(); -} - -void Frame::setFocusedNodeIfNeeded() -{ - if (selection()->isNone() || !selection()->isFocused()) - return; - - bool caretBrowsing = settings() && settings()->caretBrowsingEnabled(); - if (caretBrowsing) { - Node* anchor = enclosingAnchorElement(selection()->base()); - if (anchor) { - page()->focusController()->setFocusedNode(anchor, this); - return; - } - } - - Node* target = selection()->rootEditableElement(); - if (target) { - RenderObject* renderer = target->renderer(); - - // Walk up the render tree to search for a node to focus. - // Walking up the DOM tree wouldn't work for shadow trees, like those behind the engine-based text fields. - while (renderer) { - // We don't want to set focus on a subframe when selecting in a parent frame, - // so add the !isFrameElement check here. There's probably a better way to make this - // work in the long term, but this is the safest fix at this time. - if (target && target->isMouseFocusable() && !isFrameElement(target)) { - page()->focusController()->setFocusedNode(target, this); - return; - } - renderer = renderer->parent(); - if (renderer) - target = renderer->node(); - } - document()->setFocusedNode(0); - } - - if (caretBrowsing) - page()->focusController()->setFocusedNode(0, this); -} - -void Frame::paintDragCaret(GraphicsContext* p, int tx, int ty, const IntRect& clipRect) const -{ -#if ENABLE(TEXT_CARET) - SelectionController* dragCaretController = m_page->dragCaretController(); - ASSERT(dragCaretController->selection().isCaret()); - if (dragCaretController->selection().start().node()->document()->frame() == this) - dragCaretController->paintCaret(p, tx, ty, clipRect); -#else - UNUSED_PARAM(p); - UNUSED_PARAM(tx); - UNUSED_PARAM(ty); - UNUSED_PARAM(clipRect); -#endif -} - void Frame::setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize) { m_doc->setPrinting(printing); @@ -615,11 +542,6 @@ void Frame::injectUserScriptsForWorld(DOMWrapperWorld* world, const UserScriptVe } } -bool Frame::shouldDeleteSelection(const VisibleSelection& selection) const -{ - return editor()->client()->shouldDeleteRange(selection.toNormalizedRange().get()); -} - bool Frame::isContentEditable() const { if (m_editor.clientIsEditable()) @@ -627,11 +549,6 @@ bool Frame::isContentEditable() const return m_doc->inDesignMode(); } -void Frame::setTypingStyle(CSSMutableStyleDeclaration *style) -{ - m_typingStyle = style; -} - #ifndef NDEBUG static HashSet<Frame*>& keepAliveSet() { @@ -710,123 +627,6 @@ RenderPart* Frame::ownerRenderer() const return toRenderPart(object); } -// returns FloatRect because going through IntRect would truncate any floats -FloatRect Frame::selectionBounds(bool clipToVisibleContent) const -{ - RenderView* root = contentRenderer(); - FrameView* view = m_view.get(); - if (!root || !view) - return IntRect(); - - IntRect selectionRect = root->selectionBounds(clipToVisibleContent); - return clipToVisibleContent ? intersection(selectionRect, view->visibleContentRect()) : selectionRect; -} - -void Frame::selectionTextRects(Vector<FloatRect>& rects, SelectionRectRespectTransforms respectTransforms, bool clipToVisibleContent) const -{ - RenderView* root = contentRenderer(); - if (!root) - return; - - RefPtr<Range> selectedRange = selection()->toNormalizedRange(); - - FloatRect visibleContentRect = m_view->visibleContentRect(); - - // FIMXE: we are appending empty rects to the list for those that fall outside visibleContentRect. - // We may not want to do that. - if (respectTransforms) { - Vector<FloatQuad> quads; - selectedRange->textQuads(quads, true); - - unsigned size = quads.size(); - for (unsigned i = 0; i < size; ++i) { - IntRect currRect = quads[i].enclosingBoundingBox(); - if (clipToVisibleContent) - rects.append(intersection(currRect, visibleContentRect)); - else - rects.append(currRect); - } - } else { - Vector<IntRect> intRects; - selectedRange->textRects(intRects, true); - - unsigned size = intRects.size(); - for (unsigned i = 0; i < size; ++i) { - if (clipToVisibleContent) - rects.append(intersection(intRects[i], visibleContentRect)); - else - rects.append(intRects[i]); - } - } -} - -// Scans logically forward from "start", including any child frames -static HTMLFormElement *scanForForm(Node *start) -{ - Node *n; - for (n = start; n; n = n->traverseNextNode()) { - if (n->hasTagName(formTag)) - return static_cast<HTMLFormElement*>(n); - else if (n->isHTMLElement() && static_cast<Element*>(n)->isFormControlElement()) - return static_cast<HTMLFormControlElement*>(n)->form(); - else if (n->hasTagName(frameTag) || n->hasTagName(iframeTag)) { - Node *childDoc = static_cast<HTMLFrameElementBase*>(n)->contentDocument(); - if (HTMLFormElement *frameResult = scanForForm(childDoc)) - return frameResult; - } - } - return 0; -} - -// We look for either the form containing the current focus, or for one immediately after it -HTMLFormElement *Frame::currentForm() const -{ - // start looking either at the active (first responder) node, or where the selection is - Node *start = m_doc ? m_doc->focusedNode() : 0; - if (!start) - start = selection()->start().node(); - - // try walking up the node tree to find a form element - Node *n; - for (n = start; n; n = n->parentNode()) { - if (n->hasTagName(formTag)) - return static_cast<HTMLFormElement*>(n); - else if (n->isHTMLElement() && static_cast<Element*>(n)->isFormControlElement()) - return static_cast<HTMLFormControlElement*>(n)->form(); - } - - // try walking forward in the node tree to find a form element - return start ? scanForForm(start) : 0; -} - -void Frame::revealSelection(const ScrollAlignment& alignment, bool revealExtent) -{ - IntRect rect; - - switch (selection()->selectionType()) { - case VisibleSelection::NoSelection: - return; - case VisibleSelection::CaretSelection: - rect = selection()->absoluteCaretBounds(); - break; - case VisibleSelection::RangeSelection: - rect = revealExtent ? VisiblePosition(selection()->extent()).absoluteCaretBounds() : enclosingIntRect(selectionBounds(false)); - break; - } - - Position start = selection()->start(); - ASSERT(start.node()); - if (start.node() && start.node()->renderer()) { - // FIXME: This code only handles scrolling the startContainer's layer, but - // the selection rect could intersect more than just that. - // See <rdar://problem/4799899>. - if (RenderLayer* layer = start.node()->renderer()->enclosingLayer()) { - layer->scrollRectToVisible(rect, false, alignment, alignment); - selection()->updateAppearance(); - } - } -} - Frame* Frame::frameForWidget(const Widget* widget) { ASSERT_ARG(widget, widget); @@ -857,22 +657,6 @@ void Frame::clearTimers() clearTimers(m_view.get(), document()); } -void Frame::setSelectionFromNone() -{ - // Put a caret inside the body if the entire frame is editable (either the - // entire WebView is editable or designMode is on for this document). - Document *doc = document(); - bool caretBrowsing = settings() && settings()->caretBrowsingEnabled(); - if (!selection()->isNone() || !(isContentEditable() || caretBrowsing)) - return; - - Node* node = doc->documentElement(); - while (node && !node->hasTagName(bodyTag)) - node = node->traverseNextNode(); - if (node) - selection()->setSelection(VisibleSelection(Position(node, 0), DOWNSTREAM)); -} - void Frame::setDOMWindow(DOMWindow* domWindow) { if (m_domWindow) { @@ -983,11 +767,6 @@ String Frame::documentTypeString() const return String(); } -bool Frame::shouldChangeSelection(const VisibleSelection& newSelection) const -{ - return editor()->shouldChangeSelection(selection()->selection(), newSelection, newSelection.affinity(), false); -} - VisiblePosition Frame::visiblePositionForPoint(const IntPoint& framePoint) { HitTestResult result = eventHandler()->hitTestResultAtPoint(framePoint, true); @@ -1119,18 +898,67 @@ String Frame::layerTreeAsText() const if (!contentRenderer()) return String(); - RenderLayerCompositor* compositor = contentRenderer()->compositor(); - if (compositor->compositingLayerUpdatePending()) - compositor->updateCompositingLayers(); - - GraphicsLayer* rootLayer = compositor->rootPlatformLayer(); - if (!rootLayer) - return String(); - - return rootLayer->layerTreeAsText(); + return contentRenderer()->compositor()->layerTreeAsText(); #else return String(); #endif } +void Frame::setPageZoomFactor(float factor) +{ + setPageAndTextZoomFactors(factor, m_textZoomFactor); +} + +void Frame::setTextZoomFactor(float factor) +{ + setPageAndTextZoomFactors(m_pageZoomFactor, factor); +} + +void Frame::setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor) +{ + if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor) + return; + + Page* page = this->page(); + if (!page) + return; + + Document* document = this->document(); + if (!document) + return; + +#if ENABLE(SVG) + // Respect SVGs zoomAndPan="disabled" property in standalone SVG documents. + // FIXME: How to handle compound documents + zoomAndPan="disabled"? Needs SVG WG clarification. + if (document->isSVGDocument()) { + if (!static_cast<SVGDocument*>(document)->zoomAndPanEnabled()) + return; + if (document->renderer()) + document->renderer()->setNeedsLayout(true); + } +#endif + + if (m_pageZoomFactor != pageZoomFactor) { + if (FrameView* view = this->view()) { + // Update the scroll position when doing a full page zoom, so the content stays in relatively the same position. + IntPoint scrollPosition = view->scrollPosition(); + float percentDifference = (pageZoomFactor / m_pageZoomFactor); + view->setScrollPosition(IntPoint(scrollPosition.x() * percentDifference, scrollPosition.y() * percentDifference)); + } + } + + m_pageZoomFactor = pageZoomFactor; + m_textZoomFactor = textZoomFactor; + + document->recalcStyle(Node::Force); + + for (Frame* child = tree()->firstChild(); child; child = child->tree()->nextSibling()) + child->setPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor); + + if (FrameView* view = this->view()) { + if (document->renderer() && document->renderer()->needsLayout() && view->didFirstLayout()) + view->layout(); + } +} + } // namespace WebCore diff --git a/WebCore/page/Frame.h b/WebCore/page/Frame.h index 1e6b9b6..c09c330 100644 --- a/WebCore/page/Frame.h +++ b/WebCore/page/Frame.h @@ -29,16 +29,13 @@ #define Frame_h #include "AnimationController.h" -#include "CSSMutableStyleDeclaration.h" #include "DragImage.h" #include "Editor.h" #include "EventHandler.h" #include "FrameLoader.h" #include "FrameTree.h" #include "ScriptController.h" -#include "ScrollBehavior.h" #include "UserScriptTypes.h" -#include "ZoomMode.h" #if PLATFORM(WIN) #include "FrameWin.h" @@ -67,38 +64,32 @@ namespace WebCore { class RenderPart; class TiledBackingStore; - class Frame : public RefCounted<Frame> -#if ENABLE(TILED_BACKING_STORE) - , public TiledBackingStoreClient +#if !ENABLE(TILED_BACKING_STORE) + class TiledBackingStoreClient { }; #endif - { + + class Frame : public RefCounted<Frame>, public TiledBackingStoreClient { public: static PassRefPtr<Frame> create(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*); - void setView(PassRefPtr<FrameView>); - ~Frame(); void init(); + void setView(PassRefPtr<FrameView>); + void createView(const IntSize&, const Color&, bool, const IntSize&, bool, + ScrollbarMode = ScrollbarAuto, bool horizontalLock = false, + ScrollbarMode = ScrollbarAuto, bool verticalLock = false); - Page* page() const; - void detachFromPage(); - void transferChildFrameToNewDocument(); - - HTMLFrameOwnerElement* ownerElement() const; + ~Frame(); + void detachFromPage(); void pageDestroyed(); void disconnectOwnerElement(); + Page* page() const; + HTMLFrameOwnerElement* ownerElement() const; + Document* document() const; FrameView* view() const; - void setDOMWindow(DOMWindow*); - void clearFormerDOMWindow(DOMWindow*); - - // Unlike many of the accessors in Frame, domWindow() always creates a new DOMWindow if m_domWindow is null. - // Callers that don't need a new DOMWindow to be created should use existingDOMWindow(). - DOMWindow* domWindow() const; - DOMWindow* existingDOMWindow() { return m_domWindow.get(); } - Editor* editor() const; EventHandler* eventHandler() const; FrameLoader* loader() const; @@ -108,31 +99,30 @@ namespace WebCore { AnimationController* animation() const; ScriptController* script(); - RenderView* contentRenderer() const; // root renderer for the document contained in this frame - RenderPart* ownerRenderer() const; // renderer for the element that contains this frame + RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame. + RenderPart* ownerRenderer() const; // Renderer for the element that contains this frame. + + void transferChildFrameToNewDocument(); + + // ======== All public functions below this point are candidates to move out of Frame into another class. ======== bool isDisconnected() const; void setIsDisconnected(bool); bool excludeFromTextSearch() const; void setExcludeFromTextSearch(bool); - void createView(const IntSize&, const Color&, bool, const IntSize &, bool, - ScrollbarMode = ScrollbarAuto, bool horizontalLock = false, - ScrollbarMode = ScrollbarAuto, bool verticalLock = false); - void injectUserScripts(UserScriptInjectionTime); String layerTreeAsText() const; - private: - void injectUserScriptsForWorld(DOMWrapperWorld*, const UserScriptVector&, UserScriptInjectionTime); - - private: - Frame(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*); - - // === undecided, would like to consider moving to another class + // Unlike most accessors in this class, domWindow() always creates a new DOMWindow if m_domWindow is null. + // Callers that don't need a new DOMWindow to be created should use existingDOMWindow(). + DOMWindow* domWindow() const; + DOMWindow* existingDOMWindow() { return m_domWindow.get(); } + void setDOMWindow(DOMWindow*); + void clearFormerDOMWindow(DOMWindow*); + void clearDOMWindow(); - public: static Frame* frameForWidget(const Widget*); Settings* settings() const; // can be NULL @@ -144,12 +134,16 @@ namespace WebCore { void setInViewSourceMode(bool = true); void keepAlive(); // Used to keep the frame alive when running a script that might destroy it. -#ifndef NDEBUG static void cancelAllKeepAlive(); -#endif void setDocument(PassRefPtr<Document>); + void setPageZoomFactor(float factor); + float pageZoomFactor() const { return m_pageZoomFactor; } + void setTextZoomFactor(float factor); + float textZoomFactor() const { return m_textZoomFactor; } + void setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor); + #if ENABLE(ORIENTATION_EVENTS) // Orientation is the interface orientation in degrees. Some examples are: // 0 is straight up; -90 is when the device is rotated 90 clockwise; @@ -163,95 +157,40 @@ namespace WebCore { String documentTypeString() const; - // This method -- and the corresponding list of former DOM windows -- - // should move onto ScriptController - void clearDOMWindow(); - String displayStringModifiedByEncoding(const String& str) const { return document() ? document()->displayStringModifiedByEncoding(str) : str; } -#if ENABLE(TILED_BACKING_STORE) - // FIXME: This should be in FrameView, not Frame. - TiledBackingStore* tiledBackingStore() const { return m_tiledBackingStore.get(); } - void setTiledBackingStoreEnabled(bool); -#endif - DragImageRef nodeImage(Node*); DragImageRef dragImageForSelection(); - private: - void lifeSupportTimerFired(Timer<Frame>*); - - // === to be moved into SelectionController - - public: - TextGranularity selectionGranularity() const; - - bool shouldChangeSelection(const VisibleSelection&) const; - bool shouldDeleteSelection(const VisibleSelection&) const; - void setFocusedNodeIfNeeded(); - void notifyRendererOfSelectionChange(bool userTriggered); - - void paintDragCaret(GraphicsContext*, int tx, int ty, const IntRect& clipRect) const; - bool isContentEditable() const; // if true, everything in frame is editable - CSSMutableStyleDeclaration* typingStyle() const; - void setTypingStyle(CSSMutableStyleDeclaration*); - void clearTypingStyle(); - - FloatRect selectionBounds(bool clipToVisibleContent = true) const; - enum SelectionRectRespectTransforms { RespectTransforms = true, IgnoreTransforms = false }; - void selectionTextRects(Vector<FloatRect>&, SelectionRectRespectTransforms respectTransforms, bool clipToVisibleContent = true) const; - - HTMLFormElement* currentForm() const; - - void revealSelection(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, bool revealExtent = false); - void setSelectionFromNone(); - - SelectionController* dragCaretController() const; + VisiblePosition visiblePositionForPoint(const IntPoint& framePoint); + Document* documentAtPoint(const IntPoint& windowPoint); String searchForLabelsAboveCell(RegularExpression*, HTMLTableCellElement*, size_t* resultDistanceFromStartOfCell); String searchForLabelsBeforeElement(const Vector<String>& labels, Element*, size_t* resultDistance, bool* resultIsInCellAbove); String matchLabelsAgainstElement(const Vector<String>& labels, Element*); - VisiblePosition visiblePositionForPoint(const IntPoint& framePoint); - Document* documentAtPoint(const IntPoint& windowPoint); - -#if ENABLE(TILED_BACKING_STORE) - // FIXME: This should be in FrameView, not Frame. - - private: - // TiledBackingStoreClient interface - virtual void tiledBackingStorePaintBegin(); - virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&); - virtual void tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea); - virtual IntRect tiledBackingStoreContentsRect(); - virtual IntRect tiledBackingStoreVisibleRect(); -#endif - #if PLATFORM(MAC) - - // === undecided, would like to consider moving to another class - - public: - NSString* searchForNSLabelsAboveCell(RegularExpression*, HTMLTableCellElement*, size_t* resultDistanceFromStartOfCell); NSString* searchForLabelsBeforeElement(NSArray* labels, Element*, size_t* resultDistance, bool* resultIsInCellAbove); NSString* matchLabelsAgainstElement(NSArray* labels, Element*); -#if ENABLE(DASHBOARD_SUPPORT) - NSMutableDictionary* dashboardRegionsDictionary(); -#endif - NSImage* selectionImage(bool forceBlackText = false) const; NSImage* snapshotDragImage(Node*, NSRect* imageRect, NSRect* elementRect) const; NSImage* imageFromRect(NSRect) const; - #endif + // ======== + private: + Frame(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*); + + void injectUserScriptsForWorld(DOMWrapperWorld*, const UserScriptVector&, UserScriptInjectionTime); + void lifeSupportTimerFired(Timer<Frame>*); + Page* m_page; mutable FrameTree m_treeNode; mutable FrameLoader m_loader; @@ -271,10 +210,11 @@ namespace WebCore { mutable EventHandler m_eventHandler; mutable AnimationController m_animationController; - RefPtr<CSSMutableStyleDeclaration> m_typingStyle; - Timer<Frame> m_lifeSupportTimer; + float m_pageZoomFactor; + float m_textZoomFactor; + #if ENABLE(ORIENTATION_EVENTS) int m_orientation; #endif @@ -283,7 +223,21 @@ namespace WebCore { bool m_isDisconnected; bool m_excludeFromTextSearch; -#if ENABLE(TILED_BACKING_STORE) +#if ENABLE(TILED_BACKING_STORE) + // FIXME: The tiled backing store belongs in FrameView, not Frame. + + public: + TiledBackingStore* tiledBackingStore() const { return m_tiledBackingStore.get(); } + void setTiledBackingStoreEnabled(bool); + + private: + // TiledBackingStoreClient interface + virtual void tiledBackingStorePaintBegin(); + virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&); + virtual void tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea); + virtual IntRect tiledBackingStoreContentsRect(); + virtual IntRect tiledBackingStoreVisibleRect(); + OwnPtr<TiledBackingStore> m_tiledBackingStore; #endif }; @@ -333,16 +287,6 @@ namespace WebCore { return &m_animationController; } - inline CSSMutableStyleDeclaration* Frame::typingStyle() const - { - return m_typingStyle.get(); - } - - inline void Frame::clearTypingStyle() - { - m_typingStyle = 0; - } - inline HTMLFrameOwnerElement* Frame::ownerElement() const { return m_ownerElement; diff --git a/WebCore/page/FrameView.cpp b/WebCore/page/FrameView.cpp index a808ab6..e881c94 100644 --- a/WebCore/page/FrameView.cpp +++ b/WebCore/page/FrameView.cpp @@ -29,9 +29,9 @@ #include "AXObjectCache.h" #include "CSSStyleSelector.h" +#include "CachedResourceLoader.h" #include "Chrome.h" #include "ChromeClient.h" -#include "CachedResourceLoader.h" #include "EventHandler.h" #include "FloatRect.h" #include "FocusController.h" @@ -120,17 +120,6 @@ struct ScheduledEvent : Noncopyable { RefPtr<Node> m_eventTarget; }; -static inline float parentZoomFactor(Frame* frame) -{ - Frame* parent = frame->tree()->parent(); - if (!parent) - return 1; - FrameView* parentView = parent->view(); - if (!parentView) - return 1; - return parentView->zoomFactor(); -} - FrameView::FrameView(Frame* frame) : m_frame(frame) , m_canHaveScrollbars(true) @@ -154,7 +143,6 @@ FrameView::FrameView(Frame* frame) , m_deferSetNeedsLayouts(0) , m_setNeedsLayoutWasDeferred(false) , m_scrollCorner(0) - , m_zoomFactor(parentZoomFactor(frame)) { init(); } @@ -226,7 +214,6 @@ void FrameView::reset() m_wasScrolledByUser = false; m_lastLayoutSize = IntSize(); m_lastZoomFactor = 1.0f; - m_pageHeight = 0; m_deferringRepaints = 0; m_repaintCount = 0; m_repaintRects.clear(); @@ -798,7 +785,7 @@ void FrameView::layout(bool allowSubtree) if (subtree) { RenderView* view = root->view(); - view->popLayoutState(); + view->popLayoutState(root); if (disableLayoutState) view->enableLayoutState(); } @@ -1815,6 +1802,13 @@ void FrameView::valueChanged(Scrollbar* bar) frame()->loader()->client()->didChangeScrollOffset(); } +void FrameView::valueChanged(const IntSize& scrollDelta) +{ + ScrollView::valueChanged(scrollDelta); + frame()->eventHandler()->sendScrollEvent(); + frame()->loader()->client()->didChangeScrollOffset(); +} + void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect) { // Add in our offset within the FrameView. @@ -2119,12 +2113,6 @@ void FrameView::flushDeferredRepaints() void FrameView::forceLayout(bool allowSubtree) { layout(allowSubtree); - // We cannot unschedule a pending relayout, since the force can be called with - // a tiny rectangle from a drawRect update. By unscheduling we in effect - // "validate" and stop the necessary full repaint from occurring. Basically any basic - // append/remove DHTML is broken by this call. For now, I have removed the optimization - // until we have a better invalidation stategy. -dwh - //unscheduleRelayout(); } void FrameView::forceLayoutForPagination(const FloatSize& pageSize, float maximumShrinkFactor, Frame::AdjustViewSizeOrNot shouldAdjustViewSize) @@ -2134,8 +2122,8 @@ void FrameView::forceLayoutForPagination(const FloatSize& pageSize, float maximu RenderView *root = toRenderView(m_frame->document()->renderer()); if (root) { int pageW = ceilf(pageSize.width()); - m_pageHeight = pageSize.height() ? pageSize.height() : visibleHeight(); root->setWidth(pageW); + root->setPageHeight(pageSize.height()); root->setNeedsLayoutAndPrefWidthsRecalc(); forceLayout(); @@ -2147,19 +2135,21 @@ void FrameView::forceLayoutForPagination(const FloatSize& pageSize, float maximu if (rightmostPos > pageSize.width()) { pageW = std::min<int>(rightmostPos, ceilf(pageSize.width() * maximumShrinkFactor)); if (pageSize.height()) - m_pageHeight = pageW / pageSize.width() * pageSize.height(); + root->setPageHeight(pageW / pageSize.width() * pageSize.height()); root->setWidth(pageW); root->setNeedsLayoutAndPrefWidthsRecalc(); forceLayout(); + int docHeight = root->bottomLayoutOverflow(); + root->clearLayoutOverflow(); + root->addLayoutOverflow(IntRect(0, 0, pageW, docHeight)); // This is how we clip in case we overflow again. } } if (shouldAdjustViewSize) adjustViewSize(); - m_pageHeight = 0; } -void FrameView::adjustPageHeight(float *newBottom, float oldTop, float oldBottom, float /*bottomLimit*/) +void FrameView::adjustPageHeightDeprecated(float *newBottom, float oldTop, float oldBottom, float /*bottomLimit*/) { RenderView* root = m_frame->contentRenderer(); if (root) { @@ -2167,10 +2157,12 @@ void FrameView::adjustPageHeight(float *newBottom, float oldTop, float oldBottom GraphicsContext context((PlatformGraphicsContext*)0); root->setTruncatedAt((int)floorf(oldBottom)); IntRect dirtyRect(0, (int)floorf(oldTop), root->rightLayoutOverflow(), (int)ceilf(oldBottom - oldTop)); + root->setPrintRect(dirtyRect); root->layer()->paint(&context, dirtyRect); *newBottom = root->bestTruncatedAt(); if (*newBottom == 0) *newBottom = oldBottom; + root->setPrintRect(IntRect()); } else *newBottom = oldBottom; } @@ -2313,75 +2305,6 @@ IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const return parentPoint; } -bool FrameView::shouldApplyTextZoom() const -{ - if (m_zoomFactor == 1) - return false; - if (!m_frame) - return false; - Page* page = m_frame->page(); - return page && page->settings()->zoomMode() == ZoomTextOnly; -} - -bool FrameView::shouldApplyPageZoom() const -{ - if (m_zoomFactor == 1) - return false; - if (!m_frame) - return false; - Page* page = m_frame->page(); - return page && page->settings()->zoomMode() == ZoomPage; -} - -void FrameView::setZoomFactor(float percent, ZoomMode mode) -{ - if (!m_frame) - return; - - Page* page = m_frame->page(); - if (!page) - return; - - if (m_zoomFactor == percent && page->settings()->zoomMode() == mode) - return; - - Document* document = m_frame->document(); - if (!document) - return; - -#if ENABLE(SVG) - // Respect SVGs zoomAndPan="disabled" property in standalone SVG documents. - // FIXME: How to handle compound documents + zoomAndPan="disabled"? Needs SVG WG clarification. - if (document->isSVGDocument()) { - if (!static_cast<SVGDocument*>(document)->zoomAndPanEnabled()) - return; - if (document->renderer()) - document->renderer()->setNeedsLayout(true); - } -#endif - - if (mode == ZoomPage) { - // Update the scroll position when doing a full page zoom, so the content stays in relatively the same position. - IntPoint scrollPosition = this->scrollPosition(); - float percentDifference = (percent / m_zoomFactor); - setScrollPosition(IntPoint(scrollPosition.x() * percentDifference, scrollPosition.y() * percentDifference)); - } - - m_zoomFactor = percent; - page->settings()->setZoomMode(mode); - - document->recalcStyle(Node::Force); - - for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) { - if (FrameView* childView = child->view()) - childView->setZoomFactor(m_zoomFactor, mode); - } - - if (document->renderer() && document->renderer()->needsLayout() && didFirstLayout()) - layout(); -} - - // Normal delay void FrameView::setRepaintThrottlingDeferredRepaintDelay(double p) { diff --git a/WebCore/page/FrameView.h b/WebCore/page/FrameView.h index f9a4bf3..22c05be 100644 --- a/WebCore/page/FrameView.h +++ b/WebCore/page/FrameView.h @@ -200,9 +200,24 @@ public: void forceLayout(bool allowSubtree = false); void forceLayoutForPagination(const FloatSize& pageSize, float maximumShrinkFactor, Frame::AdjustViewSizeOrNot); - int pageHeight() const { return m_pageHeight; } - void adjustPageHeight(float* newBottom, float oldTop, float oldBottom, float bottomLimit); + // FIXME: This method is retained because of embedded WebViews in AppKit. When a WebView is embedded inside + // some enclosing view with auto-pagination, no call happens to resize the view. The new pagination model + // needs the view to resize as a result of the breaks, but that means that the enclosing view has to potentially + // resize around that view. Auto-pagination uses the bounds of the actual view that's being printed to determine + // the edges of the print operation, so the resize is necessary if the enclosing view's bounds depend on the + // web document's bounds. + // + // This is already a problem if the view needs to be a different size because of printer fonts or because of print stylesheets. + // Mail/Dictionary work around this problem by using the _layoutForPrinting SPI + // to at least get print stylesheets and printer fonts into play, but since WebKit doesn't know about the page offset or + // page size, it can't actually paginate correctly during _layoutForPrinting. + // + // We can eventually move Mail to a newer SPI that would let them opt in to the layout-time pagination model, + // but that doesn't solve the general problem of how other AppKit views could opt in to the better model. + // + // NO OTHER PLATFORM BESIDES MAC SHOULD USE THIS METHOD. + void adjustPageHeightDeprecated(float* newBottom, float oldTop, float oldBottom, float bottomLimit); bool scrollToFragment(const KURL&); bool scrollToAnchor(const String&); @@ -217,13 +232,6 @@ public: bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; } void invalidateScrollCorner(); - void setZoomFactor(float scale, ZoomMode); - float zoomFactor() const { return m_zoomFactor; } - bool shouldApplyTextZoom() const; - bool shouldApplyPageZoom() const; - float pageZoomFactor() const { return shouldApplyPageZoom() ? m_zoomFactor : 1.0f; } - float textZoomFactor() const { return shouldApplyTextZoom() ? m_zoomFactor : 1.0f; } - // Normal delay static void setRepaintThrottlingDeferredRepaintDelay(double p); // Negative value would mean that first few repaints happen without a delay @@ -270,6 +278,7 @@ private: // ScrollBarClient interface virtual void valueChanged(Scrollbar*); + virtual void valueChanged(const IntSize&); virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&); virtual bool isActive() const; virtual void getTickmarks(Vector<IntRect>&) const; @@ -336,8 +345,6 @@ private: String m_mediaType; String m_mediaTypeWhenNotPrinting; - int m_pageHeight; - unsigned m_enqueueEvents; Vector<ScheduledEvent*> m_scheduledEvents; @@ -373,8 +380,6 @@ private: // Renderer to hold our custom scroll corner. RenderScrollbarPart* m_scrollCorner; - float m_zoomFactor; - static double s_deferredRepaintDelay; static double s_initialDeferredRepaintDelayDuringLoading; static double s_maxDeferredRepaintDelayDuringLoading; diff --git a/WebCore/page/PageGroupLoadDeferrer.cpp b/WebCore/page/PageGroupLoadDeferrer.cpp index 79554cf..98a4720 100644 --- a/WebCore/page/PageGroupLoadDeferrer.cpp +++ b/WebCore/page/PageGroupLoadDeferrer.cpp @@ -44,8 +44,10 @@ PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf) // This code is not logically part of load deferring, but we do not want JS code executed beneath modal // windows or sheets, which is exactly when PageGroupLoadDeferrer is used. + // NOTE: if PageGroupLoadDeferrer is ever used for tasks other than showing a modal window or sheet, + // the constructor will need to take a ActiveDOMObject::ReasonForSuspension. for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) { - frame->document()->suspendActiveDOMObjects(); + frame->document()->suspendActiveDOMObjects(ActiveDOMObject::WillShowDialog); frame->document()->asyncScriptRunner()->suspend(); } } diff --git a/WebCore/page/PrintContext.cpp b/WebCore/page/PrintContext.cpp index 7b0179d..8cc7dd6 100644 --- a/WebCore/page/PrintContext.cpp +++ b/WebCore/page/PrintContext.cpp @@ -95,26 +95,22 @@ void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz { if (!m_frame->document() || !m_frame->view() || !m_frame->document()->renderer()) return; + RenderView* root = toRenderView(m_frame->document()->renderer()); - const float pageWidth = pageSizeInPixels.width(); - const float docWidth = root->layer()->width(); - const float docHeight = root->layer()->height(); - float currPageHeight = pageSizeInPixels.height(); - - // always return at least one page, since empty files should print a blank page - float printedPagesHeight = 0; - do { - float proposedBottom = std::min(docHeight, printedPagesHeight + pageSizeInPixels.height()); - m_frame->view()->adjustPageHeight(&proposedBottom, printedPagesHeight, proposedBottom, printedPagesHeight); - currPageHeight = max(1.0f, proposedBottom - printedPagesHeight); + int docWidth = root->layer()->width(); + int docHeight = root->layer()->height(); + int pageWidth = pageSizeInPixels.width(); + int pageHeight = pageSizeInPixels.height(); + + unsigned pageCount = ceilf((float)docHeight / pageHeight); + for (unsigned i = 0; i < pageCount; ++i) { if (allowHorizontalMultiPages) { - for (float curWidth = 0; curWidth < docWidth; curWidth += pageWidth) - m_pageRects.append(IntRect(curWidth, (int)printedPagesHeight, (int)pageWidth, (int)currPageHeight)); + for (int currWidth = 0; currWidth < docWidth; currWidth += pageWidth) + m_pageRects.append(IntRect(currWidth, i * pageHeight, pageWidth, pageHeight)); } else - m_pageRects.append(IntRect(0, (int)printedPagesHeight, (int)pageWidth, (int)currPageHeight)); - printedPagesHeight += currPageHeight; - } while (printedPagesHeight < docHeight); + m_pageRects.append(IntRect(0, i * pageHeight, pageWidth, pageHeight)); + } } void PrintContext::begin(float width, float height) diff --git a/WebCore/page/SecurityOrigin.cpp b/WebCore/page/SecurityOrigin.cpp index b44a35e..6001983 100644 --- a/WebCore/page/SecurityOrigin.cpp +++ b/WebCore/page/SecurityOrigin.cpp @@ -125,7 +125,7 @@ PassRefPtr<SecurityOrigin> SecurityOrigin::create(const KURL& url, SandboxFlags if (!url.isValid()) return adoptRef(new SecurityOrigin(KURL(), sandboxFlags)); #if ENABLE(BLOB) - if (url.protocolIs("blob")) + if (url.protocolIs(BlobURL::blobProtocol())) return adoptRef(new SecurityOrigin(BlobURL::getOrigin(url), sandboxFlags)); #endif return adoptRef(new SecurityOrigin(url, sandboxFlags)); @@ -240,7 +240,7 @@ bool SecurityOrigin::canRequest(const KURL& url) const bool doUniqueOriginCheck = true; #if ENABLE(BLOB) // For blob scheme, we want to ignore this check. - doUniqueOriginCheck = !url.protocolIs("blob"); + doUniqueOriginCheck = !url.protocolIs(BlobURL::blobProtocol()); #endif if (doUniqueOriginCheck && targetOrigin->isUnique()) return false; @@ -284,32 +284,35 @@ bool SecurityOrigin::isAccessWhiteListed(const SecurityOrigin* targetOrigin) con return false; } -bool SecurityOrigin::canDisplay(const KURL& url, const String& referrer, Document* document) +bool SecurityOrigin::canDisplay(const KURL& url) const { #if ENABLE(BLOB) - if (url.protocolIs("blob") && document) { - SecurityOrigin* documentOrigin = document->securityOrigin(); - RefPtr<SecurityOrigin> targetOrigin = SecurityOrigin::create(url); - return documentOrigin->isSameSchemeHostPort(targetOrigin.get()); - } + if (url.protocolIs(BlobURL::blobProtocol())) + return canRequest(url); #endif + if (!restrictAccessToLocal()) + return true; + if (!SchemeRegistry::shouldTreatURLAsLocal(url.string())) return true; - // If we were provided a document, we first check if the access has been white listed. - // Then we let its local file police dictate the result. - // Otherwise we allow local loads only if the supplied referrer is also local. - if (document) { - SecurityOrigin* documentOrigin = document->securityOrigin(); - RefPtr<SecurityOrigin> targetOrigin = SecurityOrigin::create(url); - if (documentOrigin->isAccessWhiteListed(targetOrigin.get())) - return true; - return documentOrigin->canLoadLocalResources(); - } - if (!referrer.isEmpty()) - return SchemeRegistry::shouldTreatURLAsLocal(referrer); - return false; + RefPtr<SecurityOrigin> targetOrigin = SecurityOrigin::create(url); + if (isAccessWhiteListed(targetOrigin.get())) + return true; + + return canLoadLocalResources(); +} + +bool SecurityOrigin::deprecatedCanDisplay(const String& referrer, const KURL& url) +{ + if (!restrictAccessToLocal()) + return true; + + if (!SchemeRegistry::shouldTreatURLAsLocal(url.string())) + return true; + + return SchemeRegistry::shouldTreatURLAsLocal(referrer); } void SecurityOrigin::grantLoadLocalResources() diff --git a/WebCore/page/SecurityOrigin.h b/WebCore/page/SecurityOrigin.h index 132fa5f..4789d3c 100644 --- a/WebCore/page/SecurityOrigin.h +++ b/WebCore/page/SecurityOrigin.h @@ -86,9 +86,11 @@ public: // Returns true if |document| can display content from the given URL (e.g., // in an iframe or as an image). For example, web sites generally cannot - // display content from the user's files system. If |document| is 0, - // |referrer| is used to make this determination. - static bool canDisplay(const KURL&, const String& referrer, Document* document); + // display content from the user's files system. + bool canDisplay(const KURL&) const; + + // FIXME: Remove this function. This function exists only to service FrameLoader. + static bool deprecatedCanDisplay(const String& referrer, const KURL& targetURL); // Returns true if this SecurityOrigin can load local resources, such // as images, iframes, and style sheets, and can link to local URLs. diff --git a/WebCore/page/Settings.cpp b/WebCore/page/Settings.cpp index 210c97e..147e9e1 100644 --- a/WebCore/page/Settings.cpp +++ b/WebCore/page/Settings.cpp @@ -27,8 +27,9 @@ #include "Settings.h" #include "BackForwardList.h" -#include "Database.h" #include "CachedResourceLoader.h" +#include "DOMTimer.h" +#include "Database.h" #include "Frame.h" #include "FrameTree.h" #include "FrameView.h" @@ -87,7 +88,6 @@ Settings::Settings(Page* page) , m_sessionStorageQuota(StorageMap::noQuota) #endif , m_pluginAllowedRunTime(numeric_limits<unsigned>::max()) - , m_zoomMode(ZoomPage) , m_isSpatialNavigationEnabled(false) , m_isJavaEnabled(false) , m_loadsImagesAutomatically(false) @@ -158,12 +158,16 @@ Settings::Settings(Page* page) #endif , m_memoryInfoEnabled(false) , m_interactiveFormValidation(false) +<<<<<<< HEAD #if ENABLE(WEB_AUTOFILL) , m_autoFillEnabled(false) #endif #ifdef ANDROID_PLUGINS , m_pluginsOnDemand(false) #endif +======= + , m_usePreHTML5ParserQuirks(false) +>>>>>>> webkit.org at r67908 { // A Frame may not have been created yet, so we initialize the AtomicString // hash before trying to use it. @@ -434,6 +438,11 @@ void Settings::setDOMPasteAllowed(bool DOMPasteAllowed) m_isDOMPasteAllowed = DOMPasteAllowed; } +void Settings::setMinDOMTimerInterval(double interval) +{ + DOMTimer::setMinTimerInterval(interval); +} + void Settings::setUsesPageCache(bool usesPageCache) { if (m_usesPageCache == usesPageCache) @@ -713,15 +722,6 @@ void Settings::setShouldPaintCustomScrollbars(bool shouldPaintCustomScrollbars) m_shouldPaintCustomScrollbars = shouldPaintCustomScrollbars; } -void Settings::setZoomMode(ZoomMode mode) -{ - if (mode == m_zoomMode) - return; - - m_zoomMode = mode; - setNeedsRecalcStyleInAllFrames(m_page); -} - void Settings::setEnforceCSSMIMETypeInNoQuirksMode(bool enforceCSSMIMETypeInNoQuirksMode) { m_enforceCSSMIMETypeInNoQuirksMode = enforceCSSMIMETypeInNoQuirksMode; diff --git a/WebCore/page/Settings.h b/WebCore/page/Settings.h index 6f18616..a0d07ff 100644 --- a/WebCore/page/Settings.h +++ b/WebCore/page/Settings.h @@ -30,7 +30,6 @@ #include "EditingBehaviorTypes.h" #include "FontRenderingMode.h" #include "KURL.h" -#include "ZoomMode.h" #include <wtf/text/AtomicString.h> namespace WebCore { @@ -229,6 +228,8 @@ namespace WebCore { void setDOMPasteAllowed(bool); bool isDOMPasteAllowed() const { return m_isDOMPasteAllowed; } + void setMinDOMTimerInterval(double); // Interval specified in seconds. + void setUsesPageCache(bool); bool usesPageCache() const { return m_usesPageCache; } @@ -319,9 +320,6 @@ namespace WebCore { void setShouldPaintCustomScrollbars(bool); bool shouldPaintCustomScrollbars() const { return m_shouldPaintCustomScrollbars; } - - void setZoomMode(ZoomMode); - ZoomMode zoomMode() const { return m_zoomMode; } void setEnforceCSSMIMETypeInNoQuirksMode(bool); bool enforceCSSMIMETypeInNoQuirksMode() { return m_enforceCSSMIMETypeInNoQuirksMode; } @@ -396,6 +394,9 @@ namespace WebCore { // and http://webkit.org/b/40908 void setInteractiveFormValidationEnabled(bool flag) { m_interactiveFormValidation = flag; } bool interactiveFormValidationEnabled() const { return m_interactiveFormValidation; } + + void setUsePreHTML5ParserQuirks(bool flag) { m_usePreHTML5ParserQuirks = flag; } + bool usePreHTML5ParserQuirks() const { return m_usePreHTML5ParserQuirks; } #if ENABLE(WEB_AUTOFILL) void setAutoFillEnabled(bool flag) { m_autoFillEnabled = flag; } @@ -465,7 +466,6 @@ namespace WebCore { unsigned m_sessionStorageQuota; #endif unsigned m_pluginAllowedRunTime; - ZoomMode m_zoomMode; bool m_isSpatialNavigationEnabled : 1; bool m_isJavaEnabled : 1; bool m_loadsImagesAutomatically : 1; @@ -527,12 +527,16 @@ namespace WebCore { #endif bool m_memoryInfoEnabled: 1; bool m_interactiveFormValidation: 1; +<<<<<<< HEAD #ifdef ANDROID_PLUGINS bool m_pluginsOnDemand : 1; #endif #if ENABLE(WEB_AUTOFILL) bool m_autoFillEnabled: 1; #endif +======= + bool m_usePreHTML5ParserQuirks: 1; +>>>>>>> webkit.org at r67908 #if USE(SAFARI_THEME) static bool gShouldPaintNativeControls; diff --git a/WebCore/page/SuspendableTimer.cpp b/WebCore/page/SuspendableTimer.cpp index 532b0ed..23f00b0 100644 --- a/WebCore/page/SuspendableTimer.cpp +++ b/WebCore/page/SuspendableTimer.cpp @@ -55,7 +55,7 @@ void SuspendableTimer::stop() TimerBase::stop(); } -void SuspendableTimer::suspend() +void SuspendableTimer::suspend(ReasonForSuspension) { #if !ASSERT_DISABLED ASSERT(!m_suspended); diff --git a/WebCore/page/SuspendableTimer.h b/WebCore/page/SuspendableTimer.h index eae6153..cc90b62 100644 --- a/WebCore/page/SuspendableTimer.h +++ b/WebCore/page/SuspendableTimer.h @@ -41,7 +41,7 @@ public: virtual bool hasPendingActivity() const; virtual void stop(); virtual bool canSuspend() const; - virtual void suspend(); + virtual void suspend(ReasonForSuspension); virtual void resume(); private: diff --git a/WebCore/page/ZoomMode.h b/WebCore/page/ZoomMode.h deleted file mode 100644 index 3f02184..0000000 --- a/WebCore/page/ZoomMode.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2010 Research in Motion Ltd. http://www.rim.com/ - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef ZoomMode_h -#define ZoomMode_h - -namespace WebCore { - -enum ZoomMode { - ZoomPage, - ZoomTextOnly -}; - -} - -#endif diff --git a/WebCore/page/animation/AnimationBase.cpp b/WebCore/page/animation/AnimationBase.cpp index 6efed8e..ade68b5 100644 --- a/WebCore/page/animation/AnimationBase.cpp +++ b/WebCore/page/animation/AnimationBase.cpp @@ -1180,6 +1180,10 @@ void AnimationBase::fireAnimationEventsIfNeeded() // Check for end timeout if (m_totalDuration >= 0 && elapsedDuration >= m_totalDuration) { + // We may still be in AnimationStateLooping if we've managed to skip a + // whole iteration, in which case we should jump to the end state. + m_animState = AnimationStateEnding; + // Fire an end event updateStateMachine(AnimationStateInputEndTimerFired, m_totalDuration); } else { diff --git a/WebCore/page/animation/AnimationBase.h b/WebCore/page/animation/AnimationBase.h index 182cb3c..f5f3172 100644 --- a/WebCore/page/animation/AnimationBase.h +++ b/WebCore/page/animation/AnimationBase.h @@ -42,7 +42,7 @@ class Element; class Node; class RenderObject; class RenderStyle; -struct TimingFunction; +class TimingFunction; class AnimationBase : public RefCounted<AnimationBase> { friend class CompositeAnimation; diff --git a/WebCore/page/chromium/ChromeClientChromium.h b/WebCore/page/chromium/ChromeClientChromium.h index 7765472..44e005f 100644 --- a/WebCore/page/chromium/ChromeClientChromium.h +++ b/WebCore/page/chromium/ChromeClientChromium.h @@ -31,6 +31,7 @@ #ifndef ChromeClientChromium_h #define ChromeClientChromium_h +#include "AXObjectCache.h" #include "ChromeClient.h" #include <wtf/Forward.h> @@ -58,6 +59,9 @@ public: // Notified embedder that the children of an accessibility object has changed. virtual void didChangeAccessibilityObjectChildren(AccessibilityObject*) = 0; + + // Notifies embedder about an accessibility notification. + virtual void postAccessibilityNotification(AccessibilityObject*, AXObjectCache::AXNotification) = 0; }; } // namespace WebCore diff --git a/WebCore/page/chromium/EventHandlerChromium.cpp b/WebCore/page/chromium/EventHandlerChromium.cpp index 719163f..dd6cf99 100644 --- a/WebCore/page/chromium/EventHandlerChromium.cpp +++ b/WebCore/page/chromium/EventHandlerChromium.cpp @@ -63,7 +63,7 @@ bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m VisiblePosition visiblePos( mev.targetNode()->renderer()->positionForPoint(mev.localPoint())); VisibleSelection newSelection(visiblePos); - if (m_frame->shouldChangeSelection(newSelection)) + if (m_frame->selection()->shouldChangeSelection(newSelection)) m_frame->selection()->setSelection(newSelection); } diff --git a/WebCore/page/chromium/FrameChromium.cpp b/WebCore/page/chromium/FrameChromium.cpp index 4146b39..15ff8b4 100644 --- a/WebCore/page/chromium/FrameChromium.cpp +++ b/WebCore/page/chromium/FrameChromium.cpp @@ -86,7 +86,7 @@ DragImageRef Frame::nodeImage(Node* node) buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); buffer->context()->clip(FloatRect(0, 0, paintingRect.right(), paintingRect.bottom())); - m_view->paint(buffer->context(), paintingRect); + m_view->paintContents(buffer->context(), paintingRect); RefPtr<Image> image = buffer->copyImage(); return createDragImageFromImage(image.get()); @@ -101,7 +101,7 @@ DragImageRef Frame::dragImageForSelection() m_view->setPaintBehavior(PaintBehaviorSelectionOnly); m_doc->updateLayout(); - IntRect paintingRect = enclosingIntRect(selectionBounds()); + IntRect paintingRect = enclosingIntRect(selection()->bounds()); OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size())); if (!buffer) @@ -109,7 +109,7 @@ DragImageRef Frame::dragImageForSelection() buffer->context()->translate(-paintingRect.x(), -paintingRect.y()); buffer->context()->clip(FloatRect(0, 0, paintingRect.right(), paintingRect.bottom())); - m_view->paint(buffer->context(), paintingRect); + m_view->paintContents(buffer->context(), paintingRect); RefPtr<Image> image = buffer->copyImage(); return createDragImageFromImage(image.get()); diff --git a/WebCore/page/gtk/DragControllerGtk.cpp b/WebCore/page/gtk/DragControllerGtk.cpp index c064a87..5f9044f 100644 --- a/WebCore/page/gtk/DragControllerGtk.cpp +++ b/WebCore/page/gtk/DragControllerGtk.cpp @@ -58,8 +58,7 @@ DragOperation DragController::dragOperation(DragData* dragData) const IntSize& DragController::maxDragImageSize() { - static const IntSize maxDragImageSize(400, 400); - + static const IntSize maxDragImageSize(200, 200); return maxDragImageSize; } diff --git a/WebCore/page/mac/EventHandlerMac.mm b/WebCore/page/mac/EventHandlerMac.mm index bb466db..584f38f 100644 --- a/WebCore/page/mac/EventHandlerMac.mm +++ b/WebCore/page/mac/EventHandlerMac.mm @@ -447,14 +447,25 @@ static void selfRetainingNSScrollViewScrollWheel(NSScrollView *self, SEL selecto [self release]; } -bool EventHandler::passWheelEventToWidget(PlatformWheelEvent&, Widget* widget) +bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& wheelEvent, Widget* widget) { BEGIN_BLOCK_OBJC_EXCEPTIONS; - - if ([currentNSEvent() type] != NSScrollWheel || m_sendingEventToSubview || !widget) + + if (!widget) return false; NSView* nodeView = widget->platformWidget(); + if (!nodeView) { + // WebKit2 code path. + if (!widget->isFrameView()) + return false; + + return static_cast<FrameView*>(widget)->frame()->eventHandler()->handleWheelEvent(wheelEvent); + } + + if ([currentNSEvent() type] != NSScrollWheel || m_sendingEventToSubview) + return false; + ASSERT(nodeView); ASSERT([nodeView superview]); NSView *view = [nodeView hitTest:[[nodeView superview] convertPoint:[currentNSEvent() locationInWindow] fromView:nil]]; @@ -615,19 +626,49 @@ void EventHandler::mouseMoved(NSEvent *event) END_BLOCK_OBJC_EXCEPTIONS; } +static bool frameHasPlatformWidget(Frame* frame) +{ + if (FrameView* frameView = frame->view()) { + if (frameView->platformWidget()) + return true; + } + + return false; +} + bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) { - return passSubframeEventToSubframe(mev, subframe); + // WebKit1 code path. + if (frameHasPlatformWidget(m_frame)) + return passSubframeEventToSubframe(mev, subframe); + + // WebKit2 code path. + subframe->eventHandler()->handleMousePressEvent(mev.event()); + return true; } bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode) { - return passSubframeEventToSubframe(mev, subframe, hoveredNode); + // WebKit1 code path. + if (frameHasPlatformWidget(m_frame)) + return passSubframeEventToSubframe(mev, subframe, hoveredNode); + + // WebKit2 code path. + if (m_mouseDownMayStartDrag && !m_mouseDownWasInSubframe) + return false; + subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode); + return true; } bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) { - return passSubframeEventToSubframe(mev, subframe); + // WebKit1 code path. + if (frameHasPlatformWidget(m_frame)) + return passSubframeEventToSubframe(mev, subframe); + + // WebKit2 code path. + subframe->eventHandler()->handleMouseReleaseEvent(mev.event()); + return true; } PlatformMouseEvent EventHandler::currentPlatformMouseEvent() const diff --git a/WebCore/page/mac/FrameMac.mm b/WebCore/page/mac/FrameMac.mm index 510cb96..d4e4098 100644 --- a/WebCore/page/mac/FrameMac.mm +++ b/WebCore/page/mac/FrameMac.mm @@ -55,10 +55,6 @@ #import <Carbon/Carbon.h> #import <wtf/StdLibExtras.h> -#if ENABLE(DASHBOARD_SUPPORT) -#import "WebDashboardRegion.h" -#endif - @interface NSView (WebCoreHTMLDocumentView) - (void)drawSingleRect:(NSRect)rect; @end @@ -140,43 +136,6 @@ static RegularExpression* regExpForLabels(NSArray* labels) return result; } -NSString* Frame::searchForNSLabelsAboveCell(RegularExpression* regExp, HTMLTableCellElement* cell, size_t* resultDistanceFromStartOfCell) -{ - RenderObject* cellRenderer = cell->renderer(); - - if (cellRenderer && cellRenderer->isTableCell()) { - RenderTableCell* tableCellRenderer = toRenderTableCell(cellRenderer); - RenderTableCell* cellAboveRenderer = tableCellRenderer->table()->cellAbove(tableCellRenderer); - - if (cellAboveRenderer) { - HTMLTableCellElement* aboveCell = - static_cast<HTMLTableCellElement*>(cellAboveRenderer->node()); - - if (aboveCell) { - // search within the above cell we found for a match - size_t lengthSearched = 0; - for (Node* n = aboveCell->firstChild(); n; n = n->traverseNextNode(aboveCell)) { - if (n->isTextNode() && n->renderer() && n->renderer()->style()->visibility() == VISIBLE) { - // For each text chunk, run the regexp - String nodeString = n->nodeValue(); - int pos = regExp->searchRev(nodeString); - if (pos >= 0) { - if (resultDistanceFromStartOfCell) - *resultDistanceFromStartOfCell = lengthSearched; - return nodeString.substring(pos, regExp->matchedLength()); - } - lengthSearched += nodeString.length(); - } - } - } - } - } - // Any reason in practice to search all cells in that are above cell? - if (resultDistanceFromStartOfCell) - *resultDistanceFromStartOfCell = notFound; - return nil; -} - NSString* Frame::searchForLabelsBeforeElement(NSArray* labels, Element* element, size_t* resultDistance, bool* resultIsInCellAbove) { RegularExpression* regExp = regExpForLabels(labels); @@ -195,7 +154,7 @@ NSString* Frame::searchForLabelsBeforeElement(NSArray* labels, Element* element, *resultIsInCellAbove = false; // walk backwards in the node tree, until another element, or form, or end of tree - int unsigned lengthSearched = 0; + unsigned lengthSearched = 0; Node* n; for (n = element->traversePreviousNode(); n && lengthSearched < charsSearchedThreshold; @@ -347,7 +306,7 @@ NSImage* Frame::selectionImage(bool forceBlackText) const { m_view->setPaintBehavior(PaintBehaviorSelectionOnly | (forceBlackText ? PaintBehaviorForceBlackText : 0)); m_doc->updateLayout(); - NSImage* result = imageFromRect(selectionBounds()); + NSImage* result = imageFromRect(selection()->bounds()); m_view->setPaintBehavior(PaintBehaviorNormal); return result; } @@ -395,44 +354,6 @@ DragImageRef Frame::nodeImage(Node* node) return result; } -#if ENABLE(DASHBOARD_SUPPORT) -NSMutableDictionary* Frame::dashboardRegionsDictionary() -{ - Document* doc = document(); - - const Vector<DashboardRegionValue>& regions = doc->dashboardRegions(); - size_t n = regions.size(); - - // Convert the Vector<DashboardRegionValue> into a NSDictionary of WebDashboardRegions - NSMutableDictionary* webRegions = [NSMutableDictionary dictionaryWithCapacity:n]; - for (size_t i = 0; i < n; i++) { - const DashboardRegionValue& region = regions[i]; - - if (region.type == StyleDashboardRegion::None) - continue; - - NSString *label = region.label; - WebDashboardRegionType type = WebDashboardRegionTypeNone; - if (region.type == StyleDashboardRegion::Circle) - type = WebDashboardRegionTypeCircle; - else if (region.type == StyleDashboardRegion::Rectangle) - type = WebDashboardRegionTypeRectangle; - NSMutableArray *regionValues = [webRegions objectForKey:label]; - if (!regionValues) { - regionValues = [[NSMutableArray alloc] initWithCapacity:1]; - [webRegions setObject:regionValues forKey:label]; - [regionValues release]; - } - - WebDashboardRegion *webRegion = [[WebDashboardRegion alloc] initWithRect:region.bounds clip:region.clip type:type]; - [regionValues addObject:webRegion]; - [webRegion release]; - } - - return webRegions; -} -#endif - DragImageRef Frame::dragImageForSelection() { if (!selection()->isRange()) diff --git a/WebCore/page/mac/WebDashboardRegion.h b/WebCore/page/mac/WebDashboardRegion.h deleted file mode 100644 index 4963d04..0000000 --- a/WebCore/page/mac/WebDashboardRegion.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(ENABLE_DASHBOARD_SUPPORT) -#define ENABLE_DASHBOARD_SUPPORT 1 -#endif - -#if ENABLE_DASHBOARD_SUPPORT - -typedef enum { - WebDashboardRegionTypeNone, - WebDashboardRegionTypeCircle, - WebDashboardRegionTypeRectangle, - WebDashboardRegionTypeScrollerRectangle -} WebDashboardRegionType; - -@interface WebDashboardRegion : NSObject <NSCopying> -{ - NSRect rect; - NSRect clip; - WebDashboardRegionType type; -} -- initWithRect:(NSRect)rect clip:(NSRect)clip type:(WebDashboardRegionType)type; -- (NSRect)dashboardRegionClip; -- (NSRect)dashboardRegionRect; -- (WebDashboardRegionType)dashboardRegionType; -@end - -#endif diff --git a/WebCore/page/mac/WebDashboardRegion.m b/WebCore/page/mac/WebDashboardRegion.m deleted file mode 100644 index a6b9872..0000000 --- a/WebCore/page/mac/WebDashboardRegion.m +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2004 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WebDashboardRegion.h" - -#import <wtf/UnusedParam.h> - -#if ENABLE(DASHBOARD_SUPPORT) - -@implementation WebDashboardRegion - -- initWithRect:(NSRect)r clip:(NSRect)c type:(WebDashboardRegionType)t -{ - self = [super init]; - rect = r; - clip = c; - type = t; - return self; -} - -- (id)copyWithZone:(NSZone *)unusedZone -{ - UNUSED_PARAM(unusedZone); - - return [self retain]; -} - -- (NSRect)dashboardRegionClip -{ - return clip; -} - -- (NSRect)dashboardRegionRect -{ - return rect; -} - -- (WebDashboardRegionType)dashboardRegionType -{ - return type; -} - -static const char* typeName(WebDashboardRegionType type) -{ - switch (type) { - case WebDashboardRegionTypeNone: - return "None"; - case WebDashboardRegionTypeCircle: - return "Circle"; - case WebDashboardRegionTypeRectangle: - return "Rectangle"; - case WebDashboardRegionTypeScrollerRectangle: - return "ScrollerRectangle"; - } - return "Unknown"; -} - -- (NSString *)description -{ - return [NSString stringWithFormat:@"rect:%@ clip:%@ type:%s", NSStringFromRect(rect), NSStringFromRect(clip), typeName(type)]; -} - -// FIXME: Overriding isEqual: without overriding hash will cause trouble if this ever goes into a NSSet or is the key in an NSDictionary. -- (BOOL)isEqual:(id)other -{ - return NSEqualRects(rect, [other dashboardRegionRect]) && NSEqualRects(clip, [other dashboardRegionClip]) && type == [other dashboardRegionType]; -} - -@end - -#endif diff --git a/WebCore/page/win/FrameCGWin.cpp b/WebCore/page/win/FrameCGWin.cpp index b61deef..62d33ef 100644 --- a/WebCore/page/win/FrameCGWin.cpp +++ b/WebCore/page/win/FrameCGWin.cpp @@ -87,7 +87,7 @@ HBITMAP imageFromSelection(Frame* frame, bool forceBlackText) frame->document()->updateLayout(); frame->view()->setPaintBehavior(PaintBehaviorSelectionOnly | (forceBlackText ? PaintBehaviorForceBlackText : 0)); - FloatRect fr = frame->selectionBounds(); + FloatRect fr = frame->selection()->bounds(); IntRect ir(static_cast<int>(fr.x()), static_cast<int>(fr.y()), static_cast<int>(fr.width()), static_cast<int>(fr.height())); HBITMAP image = imageFromRect(frame, ir); diff --git a/WebCore/page/wince/FrameWince.cpp b/WebCore/page/wince/FrameWinCE.cpp index 7cfbae0..dfea864 100644 --- a/WebCore/page/wince/FrameWince.cpp +++ b/WebCore/page/wince/FrameWinCE.cpp @@ -96,7 +96,7 @@ void computePageRectsForFrame(Frame* frame, const IntRect& printRect, float head float printedPagesHeight = 0.0; do { float proposedBottom = min(docHeight, printedPagesHeight + pageHeight); - frame->view()->adjustPageHeight(&proposedBottom, printedPagesHeight, proposedBottom, printedPagesHeight); + frame->view()->adjustPageHeightDeprecated(&proposedBottom, printedPagesHeight, proposedBottom, printedPagesHeight); currPageHeight = max(1.0f, proposedBottom - printedPagesHeight); pages.append(IntRect(0, printedPagesHeight, currPageWidth, currPageHeight)); @@ -109,8 +109,8 @@ HBITMAP imageFromSelection(Frame* frame, bool forceBlackText) if (!frame->view()) return 0; - frame->view()->setPaintRestriction(forceBlackText ? PaintRestrictionSelectionOnlyBlackText : PaintRestrictionSelectionOnly); - FloatRect fr = frame->selectionBounds(); + frame->view()->setPaintBehavior(PaintBehaviorSelectionOnly | (forceBlackText ? PaintBehaviorForceBlackText : 0)); + FloatRect fr = frame->selection()->bounds(); IntRect ir((int)fr.x(), (int)fr.y(), (int)fr.width(), (int)fr.height()); if (ir.isEmpty()) return 0; @@ -120,8 +120,8 @@ HBITMAP imageFromSelection(Frame* frame, bool forceBlackText) FrameView* view = frame->view(); if (view->parent()) { ir.setLocation(view->parent()->convertChildToSelf(view, ir.location())); - w = ir.width() * view->zoomFactor() + 0.5; - h = ir.height() * view->zoomFactor() + 0.5; + w = ir.width() * frame->pageZoomFactor() + 0.5; + h = ir.height() * frame->pageZoomFactor() + 0.5; } else { ir = view->contentsToWindow(ir); w = ir.width(); @@ -143,7 +143,7 @@ HBITMAP imageFromSelection(Frame* frame, bool forceBlackText) SelectObject(bmpDC.get(), hbmpOld); - frame->view()->setPaintRestriction(PaintRestrictionNone); + frame->view()->setPaintBehavior(PaintBehaviorNormal); return hBmp; } |