Changeset 121713 in webkit


Ignore:
Timestamp:
Jul 2, 2012 5:53:26 PM (12 years ago)
Author:
leandrogracia@chromium.org
Message:

[Chromium] Implement a Layout Test for editing/SurroundingText
https://bugs.webkit.org/show_bug.cgi?id=82461

Reviewed by Ryosuke Niwa.

Source/WebKit/chromium:

Allow passing nodes as arguments for layout test methods.

  • public/WebBindings.h:

(WebBindings):

  • src/WebBindings.cpp:

(WebKit::getNodeImpl):
(WebKit):
(WebKit::WebBindings::getNode):

Tools:

Add a new method to the layout test controller in order to retrieve the
text surrounding a provided element.

  • DumpRenderTree/chromium/LayoutTestController.cpp:

(LayoutTestController::LayoutTestController):
(LayoutTestController::textSurroundingElement):

  • DumpRenderTree/chromium/LayoutTestController.h:

(LayoutTestController):

LayoutTests:

Add a new layout test for the surrounding text feature.

  • platform/chromium/editing/surrounding-text/surrounding-text-expected.txt: Added.
  • platform/chromium/editing/surrounding-text/surrounding-text.html: Added.
Location:
trunk
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r121711 r121713  
     12012-07-02  Leandro Gracia Gil  <leandrogracia@chromium.org>
     2
     3        [Chromium] Implement a Layout Test for editing/SurroundingText
     4        https://bugs.webkit.org/show_bug.cgi?id=82461
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Add a new layout test for the surrounding text feature.
     9
     10        * platform/chromium/editing/surrounding-text/surrounding-text-expected.txt: Added.
     11        * platform/chromium/editing/surrounding-text/surrounding-text.html: Added.
     12
    1132012-07-02  Emil A Eklund  <eae@chromium.org>
    214
  • trunk/Source/WebKit/chromium/ChangeLog

    r121707 r121713  
     12012-07-02  Leandro Gracia Gil  <leandrogracia@chromium.org>
     2
     3        [Chromium] Implement a Layout Test for editing/SurroundingText
     4        https://bugs.webkit.org/show_bug.cgi?id=82461
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Allow passing nodes as arguments for layout test methods.
     9
     10        * public/WebBindings.h:
     11        (WebBindings):
     12        * src/WebBindings.cpp:
     13        (WebKit::getNodeImpl):
     14        (WebKit):
     15        (WebKit::WebBindings::getNode):
     16
    1172012-07-02  Benjamin Poulain  <bpoulain@apple.com>
    218
  • trunk/Source/WebKit/chromium/public/WebBindings.h

    r101896 r121713  
    153153    WEBKIT_EXPORT static bool getArrayBufferView(NPObject* arrayBufferView, WebArrayBufferView*);
    154154
     155    // Return true (success) if the given npobj is a node.
     156    // If so, return that node as a WebNode object.
     157    WEBKIT_EXPORT static bool getNode(NPObject* element, WebNode*);
     158
    155159    // Return true (success) if the given npobj is an element.
    156160    // If so, return that element as a WebElement object.
  • trunk/Source/WebKit/chromium/src/WebBindings.cpp

    r121610 r121713  
    224224}
    225225
     226static bool getNodeImpl(NPObject* object, WebNode* webNode)
     227{
     228    if (!object || (object->_class != npScriptObjectClass))
     229        return false;
     230
     231    V8NPObject* v8NPObject = reinterpret_cast<V8NPObject*>(object);
     232    v8::Handle<v8::Object> v8Object(v8NPObject->v8Object);
     233    Node* native = V8Node::HasInstance(v8Object) ? V8Node::toNative(v8Object) : 0;
     234    if (!native)
     235        return false;
     236
     237    *webNode = WebNode(native);
     238    return true;
     239}
     240
    226241static bool getElementImpl(NPObject* object, WebElement* webElement)
    227242{
     
    325340#else
    326341    // Not supported on other ports (JSC, etc).
     342    return false;
     343#endif
     344}
     345
     346bool WebBindings::getNode(NPObject* node, WebNode* webNode)
     347{
     348#if USE(V8)
     349    return getNodeImpl(node, webNode);
     350#else
     351    // Not supported on other ports (JSC, etc.).
    327352    return false;
    328353#endif
  • trunk/Tools/ChangeLog

    r121706 r121713  
     12012-07-02  Leandro Gracia Gil  <leandrogracia@chromium.org>
     2
     3        [Chromium] Implement a Layout Test for editing/SurroundingText
     4        https://bugs.webkit.org/show_bug.cgi?id=82461
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Add a new method to the layout test controller in order to retrieve the
     9        text surrounding a provided element.
     10
     11        * DumpRenderTree/chromium/LayoutTestController.cpp:
     12        (LayoutTestController::LayoutTestController):
     13        (LayoutTestController::textSurroundingElement):
     14        * DumpRenderTree/chromium/LayoutTestController.h:
     15        (LayoutTestController):
     16
    1172012-07-02  Ojan Vafai  <ojan@chromium.org>
    218
  • trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp

    r121489 r121713  
    3939#include "WebAnimationController.h"
    4040#include "WebBindings.h"
    41 #include "WebWorkerInfo.h"
    4241#include "WebConsoleMessage.h"
    43 #include "platform/WebData.h"
    4442#include "WebDeviceOrientation.h"
    4543#include "WebDeviceOrientationClientMock.h"
     
    5957#include "WebScriptSource.h"
    6058#include "WebSecurityPolicy.h"
     59#include "WebSettings.h"
     60#include "WebSurroundingText.h"
     61#include "WebView.h"
     62#include "WebViewHost.h"
     63#include "WebWorkerInfo.h"
     64#include "platform/WebData.h"
    6165#include "platform/WebSerializedScriptValue.h"
    62 #include "WebSettings.h"
    6366#include "platform/WebSize.h"
    6467#include "platform/WebURL.h"
    65 #include "WebView.h"
    66 #include "WebViewHost.h"
    6768#include "v8/include/v8.h"
    6869#include "webkit/support/webkit_support.h"
     
    7374#include <limits>
    7475#include <sstream>
     76#include <wtf/OwnArrayPtr.h>
    7577#include <wtf/text/WTFString.h>
    76 #include <wtf/OwnArrayPtr.h>
    7778
    7879#if OS(LINUX) || OS(ANDROID)
     
    276277    bindMethod("selectionAsMarkup", &LayoutTestController::selectionAsMarkup);
    277278    bindMethod("setHasCustomFullScreenBehavior", &LayoutTestController::setHasCustomFullScreenBehavior);
    278    
     279    bindMethod("textSurroundingElement", &LayoutTestController::textSurroundingElement);
     280
    279281    // The fallback method is called when an unknown method is invoked.
    280282    bindFallbackMethod(&LayoutTestController::fallbackMethod);
     
    23442346}
    23452347#endif
     2348
     2349void LayoutTestController::textSurroundingElement(const CppArgumentList& arguments, CppVariant* result)
     2350{
     2351    result->setNull();
     2352    if (arguments.size() < 3 || !arguments[0].isObject() || !arguments[1].isNumber() || !arguments[2].isNumber())
     2353        return;
     2354
     2355    WebNode node;
     2356    if (!WebBindings::getNode(arguments[0].value.objectValue, &node))
     2357        return;
     2358
     2359    if (node.isNull() || !node.isTextNode())
     2360        return;
     2361
     2362    unsigned offset = arguments[1].toInt32();
     2363    if (offset >= node.nodeValue().length()) {
     2364        result->set(WebString().utf8());
     2365        return;
     2366    }
     2367
     2368    WebSurroundingText surroundingText;
     2369    unsigned maxLength = arguments[2].toInt32();
     2370    surroundingText.initialize(node, offset, maxLength);
     2371    result->set(surroundingText.textContent().utf8());
     2372}
  • trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h

    r121453 r121713  
    456456    // Used to set the device scale factor.
    457457    void setBackingScaleFactor(const CppArgumentList&, CppVariant*);
     458
     459    // Retrieves the text surrounding a position in a text node.
     460    // The first child of the element given y its id will be used as reference,
     461    // or its next sibling if not present. It must be a text node.
     462    void textSurroundingElement(const CppArgumentList&, CppVariant*);
    458463
    459464public:
Note: See TracChangeset for help on using the changeset viewer.